Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

[Quick Start] Failed to connect to cluster #74

Closed
gyliu513 opened this issue May 23, 2021 · 7 comments · Fixed by #76
Closed

[Quick Start] Failed to connect to cluster #74

gyliu513 opened this issue May 23, 2021 · 7 comments · Fixed by #76
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@gyliu513
Copy link
Contributor

Guangyas-MacBook-Pro:kubernetes-sigs guangyaliu$ kubectl --kubeconfig kubeconfig get all -A
Unable to connect to the server: dial tcp: lookup cluster-sample-apiserver on 1.1.1.2:53: server misbehaving
Guangyas-MacBook-Pro:kubernetes-sigs guangyaliu$ kubectl get svc
NAME                       TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
cluster-sample-apiserver   ClusterIP   10.96.206.199   <none>        6443/TCP   5m7s
cluster-sample-etcd        ClusterIP   None            <none>        <none>     5m9s
kubernetes                 ClusterIP   10.96.0.1       <none>        443/TCP    24m

@charleszheng44 ^^

@charleszheng44
Copy link
Contributor

charleszheng44 commented May 23, 2021

@gyliu513 could you try to run nslookup cluster-sample-apiserver and share the output?

@christopherhein
Copy link
Contributor

@christopherhein
Copy link
Contributor

christopherhein commented May 24, 2021

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label May 24, 2021
@gyliu513
Copy link
Contributor Author

@christopherhein @charleszheng44 seems Linux also does not work.

root@gyliu-dev21:~/go/src/github.com/kubernetes-sigs# cat /root/.hosts
127.0.0.1 cluster-sample-apiserver
root@gyliu-dev21:~/go/src/github.com/kubernetes-sigs# env | grep HOST
HOSTALIASES=/root/.hosts
root@gyliu-dev21:~/go/src/github.com/kubernetes-sigs# nslookup cluster-sample-apiserver
Server:		172.16.200.52
Address:	172.16.200.52#53

** server can't find cluster-sample-apiserver: NXDOMAIN
root@gyliu-dev21:~/go/src/github.com/kubernetes-sigs# kubectl --kubeconfig kubeconfig get all -A
Unable to connect to the server: dial tcp: lookup cluster-sample-apiserver on 172.16.200.52:53: no such host

@christopherhein
Copy link
Contributor

Interesting, yeah I think we just need to have this say the instructions (for now) should tell you to just add it to /etc/hosts so it will actually work or at least that is what I do.

@gyliu513
Copy link
Contributor Author

gyliu513 commented May 24, 2021

Thanks @christopherhein , /etc/hosts works for me, but not sure why nslookup cluster-sample-apiserver always failed.

Any side impact if we update /etc/hosts?

root@gyliu-dev21:~/go/src/github.com/kubernetes-sigs# kubectl --kubeconfig kubeconfig get all -A
NAMESPACE   NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
default     service/kubernetes   ClusterIP   10.32.0.1    <none>        443/TCP   159m
root@gyliu-dev21:~/go/src/github.com/kubernetes-sigs# nslookup cluster-sample-apiserver
Server:		172.16.200.52
Address:	172.16.200.52#53

** server can't find cluster-sample-apiserver: NXDOMAIN
root@gyliu-dev21:~/go/src/github.com/kubernetes-sigs# cat /etc/hosts
127.0.0.1 localhost
127.0.0.1 cluster-sample-apiserver

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.16.164.91 gyliu-dev21.fyre.ibm.com gyliu-dev21

@christopherhein
Copy link
Contributor

Seems like nslookup does purely DNS resolution but when you just add to the hosts file that's not populated in DNS. For /etc/hosts you should use ping or at least that's what https://askubuntu.com/questions/627906/why-is-my-etc-hosts-file-not-queried-when-nslookup-tries-to-resolve-an-address says.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants