Day 20/100daysofK8s

Parthvi Vala
1 min readApr 27, 2021

--

For 2 pods to communicate with each other via a hostname, we can add a mapping in their respective /etc/hosts file. But then it would become difficult to deal with when there are 1000s of pods and a lot of them being created and deleted ever so frequently. Adding 1000s of mappings to all the pods is not feasible. To fix that we have a nameserver for the cluster which would have the mapping of a hostname and IP address, which is more manageable. The mapping for this nameserver is added inside every pod in /etc/resolv.conf.

For pods, the hostname is mostly the dashed IP address, but for services, we use their name as the hostname.

Kubernetes recommends using CoreDNS as its nameserver for its version higher than 1.12, prior to this, it used kube-dns. CoreDNS is deployed as a pod on the cluster, inside which it runs the CoreDNS program. This program uses the Corefile config file located at /etc/coredns which contains a bunch of configured plugins. These plugins are used for monitoring metrics(prometheus), reporting health(health), errors, cache, etc. The plugin that makes CoreDNS work with K8s is kubernetes.

/etc/coredns/Corefile
-------
:53 {
errors
health
prometheus :9153
cache 30
proxy . /etc/resolv.conf
reload
kubernetes cluster.local in-addr.arpa ip6.arpa{
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
}
}

The root domain is defined here, ‘cluster.local’.

--

--

No responses yet