Add a Zone File to Kubernetes CoreDNS: Difference between revisions
Jump to navigation
Jump to search
Line 62: | Line 62: | ||
This will add a zone file for the "blue.test" domain. | This will add a zone file for the "blue.test" domain. | ||
In the same directory, add a "blue-zone.db" file with the following content: | |||
<syntaxhighlight lang='text'> | |||
; blue.test zone | |||
blue.test. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2019101701 7200 3600 1209600 3600 | |||
blue.test. IN NS b.iana-servers.net. | |||
blue.test. IN NS b.iana-servers.net. | |||
blue.test. IN A 127.0.0.1 | |||
something.blue.test. IN CNAME myservice.svc.cluster.local. | |||
</syntaxhighlight> |
Revision as of 20:59, 24 October 2019
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.
In the same directory, add a "blue-zone.db" file with the following content:
; blue.test zone
blue.test. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2019101701 7200 3600 1209600 3600
blue.test. IN NS b.iana-servers.net.
blue.test. IN NS b.iana-servers.net.
blue.test. IN A 127.0.0.1
something.blue.test. IN CNAME myservice.svc.cluster.local.