How does one install the kube-dns addon for minikube?
The kube-dns addon should be enabled by default in minikube. You can run kubectl get po -n kube-system
to check if the pod the addon-manager launches is there. If you don't see the pod listed, make sure that the addon is enabled in minikube by running minikube addons list
and verifying that kube-dns
is enabled
Edit:For me kubectl get po -n kube-system
is a valid command, here is the output:
$ kubectl get po -n kube-systemNAME READY STATUS RESTARTS AGEkube-addon-manager-minikube 1/1 Running 2 5dkube-dns-v20-7ddvt 3/3 Running 6 5dkubernetes-dashboard-rn54g 1/1 Running 2 5d
You can see from this that the kube-dns pods are running correctly. Can you verify that your kube-dns pods are in the Running
state?
This fix is for VirtualBox drivers only - confirm your driver with
cat ~/.minikube/machines/minikube/config.json | grep DriverName
The accepted answer is correct that kube-dns is installed and enabled by default. But it seems to be a common problem that the pods to manage DNS are not created, making it seem that kube-dns has not been installed.
Eg:
$ kubectl get po -n kube-systemkube-addon-manager-minikube 1/1 Running 1 1m
You can confirm kube-dns is installed and enabled (even though not working) with:
$ minikube addons list- addon-manager: enabled- dashboard: enabled- kube-dns: enabled{snipped}
The underlying problem is VirtualBox related, as described here: https://forums.virtualbox.org/viewtopic.php?f=7&t=50368
Fix:
minikube stop VBoxManage modifyvm "VM name" --natdnshostresolver1 onminikube startkubectl get all -n kube-system
VM name is probably "minikube".If the last command doesn't return a large list of pods (including kube-dns and kube-dashboard), wait a few moments - I have a few blank results before success.
For Windows users, VBoxManage is installed by default at c:\Program Files\Oracle\VirtualBox
Further information at https://superuser.com/questions/641933