Kubernetes the hard way on bare metal/VMs — Setting up DNS
Part of the Kubernetes the hard way on bare metal/VM. This is designed for beginners.
Introduction
This guide is part of the Kubernetes the hard way on bare metal/VMs series. On its own this may be useful to you however since it’s tailored for the series, it may not be completely suited to your needs.
Setting up DNS
You’ll be using CoreDNS from Kelsey’s guide
curl https://raw.githubusercontent.com/coredns/deployment/coredns-1.14.0/kubernetes/coredns.yaml.sed -o coredns.yaml.sedcurl https://raw.githubusercontent.com/coredns/deployment/coredns-1.14.0/kubernetes/deploy.sh -o deploy.shbash ./deploy.sh -s -i 10.32.0.10 > coredns.yamlkubectl apply -f coredns.yaml
Check it has been deployed
kubectl get pods -l k8s-app=kube-dns -n kube-system -w#Results
NAME READY STATUS RESTARTS AGE
coredns-699f8ddd77-fmc67 1/1 Running 0 40s
coredns-699f8ddd77-zb7gw 1/1 Running 0 42
DNS Tests
Of course, you should test everything to make sure your new DNS bits work as expected, so let’s do just that.
kubectl apply -f https://k8s.io/examples/admin/dns/dnsutils.yamlkubectl exec -ti dnsutils -- nslookup kubernetes##Results
Server: 10.32.0.10
Address: 10.32.0.10#53Name: kubernetes.default.svc.cluster.local
Address: 10.32.0.1
If you don’t see the results above, it’s likely the coredns pods have errors. use kubectl describe & logs to diagnose these.
Conclusion
You’ve configured the DNS for the cluster and without realising it, just finished setting up the entire cluster!
Next: Testing everything