Search code examples
dnskuberneteskubectl

Tell kubectl to use /etc/hosts for looking up hosts


When executing into a pod I get following message

Error from server: error dialing backend: dial tcp: lookup k8s-worker-node-a on 192.168.1.1:53: no such host

Is it possible to tell kubectl to use /etc/hosts to lookup machines as I have saved them inside there.


Solution

  • Can the API server resolve that hostname? It's insufficient for just your workstation to know the hostname, since the API server must be able to contact kubelet on the Node to construct the URL used to view the logs

    Turning up the verbosity of kubectl will show the actual handshaking that goes on between your machine, the API server, and the kubelet on the Node, which is how we discovered a similar misconfiguration in our cluster.