AKS uses CoreDNS for all DNS functions within the cluster. As AKS is a managed cluster, making changes to the main configuration (CoreFile) is not supported.
Customised configuration is possible using ConfigMaps. The default set of properties can be seen using:
> kubectl -n kube-system get configmaps coredns -o yaml (snipped example below):
apiVersion: v1 data: Corefile: | .:53 { errors ready health kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } prometheus :9153 forward . /etc/resolv.conf cache 30 loop reload loadbalance import custom/*.override } import custom/*.server kind: ConfigMap
As you can see, name resolution is via /etc/resolv.conf (DNS settings on the underlying cluster nodes).
This works fine for many cases, but what happens when you need to use specific DNS servers for your internal hosts? In this case, you can add customisations via the coredns-custom configmap.
To add new configuration follow the steps below :
1. Create a new yaml file with the following contents:
internaldns.yaml
apiVersion: v1 kind: ConfigMap metadata: name: coredns-custom namespace: kube-system data: myinternal.server: | # you may select any name here, but it must end with the .server file extension myinternal.com.au:53 { errors cache 30 forward . 10.1.0.1 10.1.0.2 # Your internal DNS server(s) }
2. Apply the new configuration using kubectl :
> kubectl apply -f internaldns.yaml
Expected output :
configmap/coredns-custom configured
3. Kill existing coredns pods
To save waiting for the changes to propagate, kill the existing pods :
> kubectl delete pod --namespace kube-system --selector k8s-app=kube-dns
4. Complete!
You now have your internal hosts being resolved by your internal DNS servers.
To check:
- Ensure coredns pods are showing the mount for coredns-custom
- Ensure config from your yaml file is present in the running configmap