Kubernetes DNS Service

Kubernetes cluster by default automatically configures an internal DNS service to provide a mechanism for service discovery.

Applications will find and communicate with each other on Kubernetes clusters by service discovery.

Kubernetes DNS Service

Before K8S 1.11, the Kubernetes DNS Service was based on kube-dns, from 1.11, we have CoreDNS to address some security and stability concerns with Kubernetes.

The full DNS A record of a Kubernetes service will look like:

1
<service>.<namespace>.svc.cluster.local

And the pod will look like

1
pod_id.namespace.pod.cluster.local

E.g: In the current application, I am using Helm to generate application configuration and setup Postgres chart as a dependency. Postgres chart will have its own service. By using K8S DNS Service, I will able to connect the Postgres from the application, the Pg hostname in the application will be:

1
pg_full_name.default.svc.cluster.local/db_name

Want to know more about how CoreDNS or Kube-dns works, check the DO blog: https://www.digitalocean.com/community/tutorials/an-introduction-to-the-kubernetes-dns-service