If you have installed Docker Desktop, you will see that Kubernetes is using CoreDNS DNS server.
The DNS server is used as the internal Kubernetes DNS service (cluster DNS) that provides naming and discovery for all Kubernetes Services that are created in the cluster.
The CoreDNS is running as a Kubernetes Deployment (replicas of Pods) and has a Service (acts as a load balancer for the DNS server).
The CoreDNS server components run in the "kube-system" namespace (can be filtered with the label "k8s-app=kube-dns").
To see the CoreDNS Deployment:
$ kubectl get deployments -n kube-system -l k8s-app=kube-dns -o wide
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
coredns 2/2 2 2 9h coredns registry.k8s.io/coredns/coredns:v1.11.3 k8s-app=kube-dns
To see the CoreDNS Pods:
$ kubectl get pods -n kube-system -l k8s-app=kube-dns -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
coredns-668d6bf9bc-mjgnv 1/1 Running 0 9h 10.1.0.26 docker-desktop <none> <none>
coredns-668d6bf9bc-mrs79 1/1 Running 0 9h 10.1.0.27 docker-desktop <none> <none>
To see the CoreDNS Service (kube-dns):
$ kubectl get services -n kube-system -l k8s-app=kube-dns -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 9h k8s-app=kube-dns
Let's install dnsutils utility to help debuging the DNS name resolution for services:
$ kubectl apply -f https://k8s.io/examples/admin/dns/dnsutils.yaml
pod/dnsutils created
Check that Pod was created properly:
$ kubectl get pod dnsutils
NAME READY STATUS RESTARTS AGE
dnsutils 1/1 Running 0 56s
First let's validate that the DNS resolution is working correctly.
The nslookup command can be used to resolve the "kubernetes" Service of the API Server (you should get something like the following):
$ kubectl exec -i -t dnsutils -- nslookup kubernetes
Server: 10.96.0.10 <- The IP address of the Kubernetes DNS
Address: 10.96.0.10#53
Name: kubernetes.default.svc.cluster.local <- The FQDN of the "kubernetes" Service
Address: 10.96.0.1 <- The clusterIP of the "kubernetes" Service
Let's check the "/etc/resolv.conf" file (the search path and name server should look like the following):
$ kubectl exec dnsutils -- cat /etc/resolv.conf
nameserver 10.96.0.10 <- Kubernetes DNS IP address (kube-dns Service ClusterIP)
search default.svc.cluster.local svc.cluster.local cluster.local <- Kubernetes DNS search domains
options ndots:5
The "nameserver" (DNS IP address) and "search" (DNS search domains) are saved in the "/etc/resolv.conf" file of all containers.