Skip to main content

DNS

Each node has a node name, and an IP address.

Whenever a service is created, Kubernetes DNS creates a record for the service. it maps the service name to the IP.

Within the cluster, any pod can reach the service using the service name.

Named according to namespace

http://{serviceName}.{namespace}.svc.cluster.local

Type: svc: Services

Root domain: cluster.local

Records for pods are not created by default. However it can be enabled. In this case pods would get IP addresses like:

10-244-2-5.{namespace}.pod.cluster.local

This will resolve to the IP address of the pod.

DNS service is referenced in /etc/resolv.conf

Kubernetes 1.12 moved away from kube-dns and into coreDNS

CoreDNS

CoreDns is configured at /etc/coredns/Corefile

Plugins are configured for metrics, errors, cache, health, etc.

The kubernetes plugin makes CoreDNS work with k8s. This is where you set the kubernetes DNS name cluster.local

pods insecure can add the option to resolve pod IPs

The Corefile is passed into the pod as a configmap!

There is a service named kube-dns that points to the DNS entry.

Kubelet config points to the IP address of DNS server.