Add nodes ip resolve to HA's api-server's /etc/hosts
See original GitHub issueHi, After create the HA,I notice that when I use kubectl port-forward or exec to some container, if the container locates on other nodes rather than on api-server node, dns lookup fails. The message shows that:
kubectl port-forward -n kube-system service/kubernetes-dashboard 10443:443
error: error upgrading connection: error dialing backend: dial tcp: lookup machine5 on 127.0.0.53:53: server misbehaving
After some digging, I found that after microk8s join, the node only add mater’s ip and itself’s ip to the /etc/hosts, so lookup the hostname of other node would failed due to the config of the lan router.
So I add all nodes to the /etc/file of the node which api-server is on.
So maybe add all nodes hostname automaticly to /etc/hosts would be nice.
Thanks in advance
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Add nodes ip resolve to HA's api-server's /etc/hosts #1566
I have been using RKE clusters and I don't see this problem. ubuntu@k-one:~$ microk8s kubectl port-forward po/argocd-server-86f7f94488-2zntt ...
Read more >Adding entries to Pod /etc/hosts with HostAliases - Kubernetes
Adding entries to a Pod's /etc/hosts file provides Pod-level override of hostname resolution when DNS and other options are not applicable.
Read more >Using hostAliases to Configure /etc/hosts in a Pod - 华为云
If DNS or other related settings are inappropriate, you can use hostAliases to overwrite the resolution of the host name at the pod...
Read more >How should the /etc/hosts file be set up on RHEL cluster nodes?
Resolution. In Red Hat Enterprise Linux with the High Availability Add-On, the /etc/hosts file should be used to define the IP address and ......
Read more >Kubeadm join not working with the hostname of the device
It actually using a hostname for discovery - lookup device1.local on ... has to be an apiserver hostname, resolvable on all your nodes, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The problem is that CoreDNS does not resolve the hostname of the nodes (and even though the feature was requested it was marked as WONTFIX basically), and thus there really isn’t any service that knows it besides the k8s apiserver.
Editing the hosts file is not ideal, but at least can be done with this on each node:
If your nodes going to change frequently, then probably you need to put something like this into a CRON script (or systemd timer unit). It’s the same as the previous one-liner with before-after guard lines to be able to replace multiple lines.
It’s also possible to somehow put all this into the Corefile of CoreDNS (which is basically in the coredns configmap in the kube-system NS), and use the in-cluster DNS service from the hosts, but it’s left as exercise for the reader, because it seems even more fragile than manipulating the hosts file.
To give some weight to this issue, it is one of only 2 reasons why I migrated everything from microk8s to k3s