PyratLabs / ansible-role-k3s

Ansible role for installing k3s as either a standalone server or HA cluster.
BSD 3-Clause "New" or "Revised" License
638 stars 134 forks source link

Is there support for --resolv-conf or custom coredns forward? #228

Closed mreiche closed 1 month ago

mreiche commented 1 month ago

In reference to https://github.com/k3s-io/k3s/issues/4087 and https://github.com/k3s-io/k3s/discussions/7822: It looks like that coredns's /etc/resolv.conf differs from the host. Is it possible to configure the forward DNS or set up a different resolv.conf?

dbrennand commented 1 month ago

Hi @mreiche

Yes, it's possible to pass the --resolv-conf flag using the k3s_server and k3s_agent group/host variables.

https://github.com/PyratLabs/ansible-role-k3s?tab=readme-ov-file#grouphost-variables

dbrennand commented 1 month ago

@mreiche

Alternatively, I saw in the post you linked that somebody was creating a coredns-custom configmap. If you needed to configure this, I think you could use the k3s_server_manifests_templates variable:

# Relative to your playbook
# templates/coredns-custom.yml
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: coredns-custom
  namespace: kube-system
data:
  forward.override: |-
    forward . /etc/resolv.conf {
      policy sequential
    }

Then, configure your k3s_server_manifests_templates variable to apply this configmap to the cluster:

# ...
k3s_server_manifests_templates:
   - coredns-custom.yml
mreiche commented 1 month ago

Hi @dbrennand. k3s coredns reads the coredns-custom ConfigMap already. My problem is, that I can't override the default forward like described here: https://github.com/k3s-io/k3s/issues/10951