In this lab you will deploy the DNS add-on which provides DNS based service discovery, backed by CoreDNS, to applications running inside the Kubernetes cluster.
Deploy the coredns
cluster add-on:
helm repo add coredns https://coredns.github.io/helm
helm --namespace=kube-system install coredns coredns/coredns --set=service.clusterIP=10.32.0.10
Wait until coredns pods are up:
kubectl -n kube-system get po -w
Create a busybox
deployment:
kubectl run busybox --image=busybox:1.28 --command -- sleep 3600
List the pod created by the busybox
deployment:
kubectl get pods -l run=busybox
output
NAME READY STATUS RESTARTS AGE
busybox 1/1 Running 0 3s
Retrieve the full name of the busybox
pod:
POD_NAME=$(kubectl get pods -l run=busybox -o jsonpath="{.items[0].metadata.name}")
Execute a DNS lookup for the kubernetes
service inside the busybox
pod:
kubectl exec -ti $POD_NAME -- nslookup kubernetes
output
Server: 10.32.0.10
Address 1: 10.32.0.10 kube-dns.kube-system.svc.cluster.local
Name: kubernetes
Address 1: 10.32.0.1 kubernetes.default.svc.cluster.local
Next: Smoke Test