Day 20/100daysofK8s

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.

:53 {
prometheus :9153
cache 30
proxy . /etc/resolv.conf
kubernetes cluster.local{
pods insecure

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



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store