Add a Zone File to Kubernetes CoreDNS
Jump to navigation
Jump to search
Internal
Overview
The zone file is added as a ConfigMap entry which will be projected in CoreDNS pods as a file, under the zone file name. The Corefile projected as part of the same ConfigMap should be also modified to refer the new zone file with the "file" directive.
The CoreDNS deployment is then scaled down, the new configuration file is added as an "item" in configMap volume mount, and the deployment is then scaled up.
Procedure
Add the Zone File to ConfigMap
Get the content of the coredns ConfigMap "Corefile" entry:
kubectl -n kube-system get configmap coredns -o jsonpath='{.data.Corefile}' > ./Corefile
You should get something similar to:
.:53 {
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
prometheus :9153
forward . /etc/resolv.conf
cache 30
loop
reload
loadbalance
}
Add the following configuration extension:
.:53 { errors health kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure upstream fallthrough in-addr.arpa ip6.arpa ttl 30 } prometheus :9153 forward . /etc/resolv.conf cache 30 loop reload loadbalance file /etc/coredns/blue-zone.db blue.test { upstream } }
This will add a zone file for the "blue.test" domain.