Skip to content

Latest commit

 

History

History
53 lines (42 loc) · 1.88 KB

setup-kube-dns.md

File metadata and controls

53 lines (42 loc) · 1.88 KB

Setup Kube DNS

kube-dns is a Kubernetes plugin that helps Pods find other Services/Pods by domain names. It is just required to create a Pod and a Service to install this plugin. This is the link to the file.

Run below command to install the plugin:

$ kubectl create -f kubedns.yaml

This will create a Pod and a Service in kube-system namespace. To verify, run the following commands:

$ kubectl get pods
NAME      READY     STATUS    RESTARTS   AGE
nginx     1/1       Running   0          1m

$ get svc --all-namespaces
NAMESPACE     NAME            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)         AGE
default       kubernetes      ClusterIP   10.254.0.1       <none>        443/TCP         11d
kube-system   kube-dns        ClusterIP   10.254.0.2       <none>        53/UDP,53/TCP   1m

Note that kube-dns is installed inside kube-system namespace. The Pod and the Service look good, to verify they are working correctly, we need to deploy pod-busybox, pod-nginx and service-nginx to the cluster.

# create the services
$ kubectl create -f pod-busybox.yaml

$ kubectl create -f pod-nginx.yaml

$ kubectl create -f service-nginx.yaml

# log on to busybox
$ kubectl exec -it busybox /bin/sh

# check the nameserver
$ cat /etc/resolv.conf
nameserver 10.254.0.2
search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5

# ping nginx
$ ping nginx-service
PING nginx-service (10.254.189.113): 56 data bytes
^C
--- nginx-service ping statistics ---
5 packets transmitted, 0 packets received, 100% packet loss

# ping kube-dns server in kube-system namespace
$ ping kube-dns.kube-system
PING kube-dns.kube-system (10.254.0.2): 56 data bytes
^C
--- kube-dns.kube-system ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss