When you deploy many pods to a Kubernetes cluster, service discovery is one of the most important functions, because podsmay depend on other pods but the IP address of a pod willbe changedwhen it restarts. You need to have a flexible way to communicate a pod's IP address to other pods. Kubernetes has an add-on featurecalledkube-dns
that helps in this scenario. It can register and look up an IP address for pods and Kubernetes Services.
In this section, we will explore how to usekube-dns
, which gives you a flexible way to configure DNS in your Kubernetes cluster.
Since Kubernetes version 1.3, kube-dns
has come with Kubernetes and is enabled by default.To check whether kube-dns
is working or not, check the kube-system
namespace with the following command:
$ kubectl get deploy kube-dns --namespace=kube-system NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE kube-dns 1 1 1 1 1d
If you are using minikube, type...