I ran into trouble today, without any reason, my apps in Microk8s cluster cannot resolve domain name
java.lang.RuntimeException: java.net.UnknownHostException: xxx.example.com: Temporary failure in name resolution
And then I go to check the coredns log and see below log. 10.152.183.1:443
is the apiserver address
E0528 13:48:20.680081 1 reflector.go:125] pkg/mod/k8s.io/client-go@v0.0.0-20190620085101-78d2af792bab/tools/cache/reflector.go:98: Failed to list *v1.Service: Get https://10.152.183.1:443/api/v1/services?limit=500&resourceVersion=0: dial tcp 10.152.183.1:443: connect: no route to host
I don't know what the root cause excactly is, but here is the solution
# For Kubernetessystemctl stop kubeletsystemctl stop dockeriptables --flushiptables -tnat --flushsystemctl start kubeletsystemctl start docker
# For Microk8smicrok8s stopsystemctl stop dockeriptables --flushiptables -tnat --flushsystemctl start dockermicrok8s start
https://github.com/kubernetes/kubeadm/issues/193#issuecomment-330060848