Kubernetes: Pods Can't Resolve Hostnames

前端 未结 4 1204
忘掉有多难
忘掉有多难 2021-02-05 21:40

I am encountering an issue with Kubernetes where my pods cannot resolve hostnames (such as google.com or kubernetes.default).

I currently have

相关标签:
4条回答
  • 2021-02-05 22:18

    Encountered the same issue. I followed this doc dns-debugging-resolution and checked DNS related pods, services, endpoints, all was running without error messages. Finally, I found my calico service was dead. After I started calico service and waited several minutes, It worked.

    0 讨论(0)
  • 2021-02-05 22:28

    I had a similar problem. Restarting the coredns deployment solved it for me:

    kubectl -n kube-system rollout restart deployment coredns
    
    0 讨论(0)
  • 2021-02-05 22:29

    Some ideas come to mind:

    • Maybe the kube-proxy service is not working correctly and hence the kube-dns service is not acccessible. Could you check that it is working?
    • You did not install a network overlay correctly, for example Calico: https://docs.projectcalico.org/v2.4/getting-started/kubernetes/installation/hosted/kubeadm/. Did you install it and it is working?
    0 讨论(0)
  • 2021-02-05 22:31

    Check coredns pods log, if you see errors like:

    # kubectl logs --namespace=kube-system coredns-XXX
      ...
      [ERROR] plugin/errors ... HINFO: read udp ... read: no route to host
    

    Then make sure firewalld masquerade is enabled on the host:

    # firewall-cmd --list-all
      ... 
      masquerade: yes
    
    Enable if it's "no":
    # firewall-cmd --add-masquerade --permanent
    # firewall-cmd --reload
    

    *You may need to restart/reboot after this

    0 讨论(0)
提交回复
热议问题