Kubernetes pod DNS resolution

6/18/2020

The /etc/resolv.conf in my containers show "default.svc.cluster.local", if I do an nslookup on one of my services, it shows {servicename}.default.svc.cluster.local. I was wondering what the 'svc' in the search path was referring to as I am doing an nslookup on the servicename already. I.e. is it not duplicated?

For the "cluster.local" part, how do you find the name of your cluster? I would like to know so that I can define it in my Helm template.

-- xbfh0516
kubernetes
kubernetes-helm

1 Answer

6/18/2020

cluster.local is defined in a configMap coredns in kube-system namespace.

kubectl get cm coredns -n kube-system -o yaml
apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health {
           lameduck 5s
        }
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
           pods insecure
           fallthrough in-addr.arpa ip6.arpa
           ttl 30
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }

Check the docs if you want to customize it.

-- Arghya Sadhu
Source: StackOverflow