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.
nameserver 172.xx.x.xx
search kube-system.svc.cluster.local svc.cluster.local cluster.local
options ndots:5

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.
- For more information about how to configure CoreDNS in ACK clusters, see Configure CoreDNS.
- For more information about how to use CoreDNS to improve the performance of DNS resolutions for an ACK cluster, see Optimize DNS resolution for an ACK cluster.
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.