Skip to main content
1 of 2

kubectl uses wrong IP

My kubectl suddenly stopped working. Any commands results in "no route to host".

For example, getting logs kubectl logs mypod-746cfd667b-tdrnt

Error from server: Get "https://hades:10250/containerLogs/default/mypod-746cfd667b-tdrnt/mypod": dial tcp 10.0.0.10:10250: connect: no route to host

That's no wonder, because my server is located at 10.0.0.102, and for some reason, it is going to 10.0.0.10. Why?

  • I tried removing kubectl (with purge) and reinstalling it. No difference.
  • I tried deleting the ~/.kube folder. No difference.
  • I CAN manage my cluster using Kubernetes Lens, which uses the same ~/.kube/config file. However, when trying to get the logs it fallbacks to using kubectl and I get the same issue.
# ping hades

PING hades (10.0.0.102) 56(84) bytes of data.
64 bytes from hades (10.0.0.102): icmp_seq=1 ttl=64 time=0.199 ms

Any idea how I can force kubectl to refresh its DNS cache?

Any idea how I can force kubectl to use a specific IP address, bypassing the DNS entirely?