Workloads in a Kubernetes cluster use Domain Name System (DNS) services to resolve domain names. This topic introduces how DNS resolution works in Kubernetes clusters and describes CoreDNS, which is the default DNS resolver that is preinstalled in Container Service for Kubernetes (ACK) clusters.

How DNS resolution works in Kubernetes clusters

The startup parameters of kubelet in an ACK cluster include --cluster-dns=<dns-service-ip> and --cluster-domain=<default-local-domain>. The parameters are used to configure the IP address and the suffix of the base domain name for the DNS server in the ACK cluster.

By default, ACK deploys a set of workloads in a cluster to run CoreDNS. A Service named kube-dns is deployed to expose these workloads to DNS queries in the cluster. Two backend pods named coredns are deployed for CoreDNS. DNS queries in the cluster are sent to the DNS server that is specified in the coredns pod configuration. The DNS configuration file in the pod is /etc/resolv.conf. The file contains the following content:
nameserver 172.xx.x.xx
search kube-system.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
Figure 1. The following figure shows how domain names are resolved in an ACK cluster.
How CoreDNS resolves domain names
No. Description
When a client pod attempts to access Service Nginx, the pod sends a request to the DNS server that is specified in the DNS configuration file /etc/resolv.conf. In this example, the DNS server address is 172.21.0.10, which is the IP address of Service kube-dns. The result of the resolution is 172.21.0.30.
The client pod sends another request to 172.21.0.30, which is the IP address of Service Nginx. Then, the request is forwarded to the backend pods Nginx-1 and Nginx-2.

For more information about DNS resolutions in Kubernetes clusters, see How DNS resolution works in ACK clusters.

Introduction to CoreDNS

CoreDNS is a DNS resolver for Kubernetes clusters. CoreDNS can resolve custom internal domain names and external domain names. CoreDNS provides a variety of plug-ins that you can use to configure custom DNS settings and customize host records, Canonical Name (CNAME) records, and rewrite rules for Kubernetes clusters. CoreDNS is hosted by Cloud Native Computing Foundation (CNCF), which also hosts Kubernetes. For more information about CoreDNS, see CoreDNS: DNS and Service Discovery.

ACK uses CoreDNS to implement service discovery in clusters. You can configure CoreDNS based on your requirements to support higher numbers of DNS queries in different scenarios.
Note

You can also use NodeLocal DNSCache to improve the stability and performance of service discovery in ACK clusters. NodeLocal DNSCache improves DNS performance by running a DNS caching agent on nodes as a DaemonSet. For more information about how to deploy NodeLocal DNSCache in an ACK cluster, see Configure NodeLocal DNSCache.