1

I'm using rke2 cluster, i.e. a k8s distribution.

And I want to add a nameserver for '*.example.org' to the cluster DNS system, for which I should change the core file of coredns like below.

.:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
           pods insecure
           fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        forward . 172.16.0.1
        cache 30
        loop
        reload
        loadbalance
    }
    example.org:53 { #加一个block
        errors
        cache 30
        forward . 10.150.0.1
    }

However, rke2 install coredns with helm system, so I should change the helm values to add somethings to the corefile.

How should I achieve this. Thank you a lot.

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
Dai Zhang
  • 71
  • 7

1 Answers1

1

You map or edit the configmap like

you can map the domain to the service name using rewrite, rewrite name example.io service.default.svc.cluster.local

rewrite name example.io service.default.svc.cluster.local
loadbalance round_robin
prometheus {$POD_IP}:9153
forward . /etc/resolv.conf
reload

YAML for ref

apiVersion: v1
data:
  Corefile: |-
    .:5353 {
        bind {$POD_IP}
        cache 30
        errors
        health {$POD_IP}:8080
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          fallthrough in-addr.arpa ip6.arpa
        }
        rewrite name example.io service.default.svc.cluster.local
        loadbalance round_robin
        prometheus {$POD_IP}:9153
        forward . /etc/resolv.conf
        reload
    }
kind: ConfigMap
metadata:
  labels:
    app: coredns
    k8s-app: coredns
  name: coredns
  namespace: kube-system

Other answers for ref :

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102