kubernetes v1.2.0进行kubectl version和kubectl get nodes出现localhost:8080 connection refused的问题

zhang_gq 发布于 2016/03/24 14:10
阅读 29K+
收藏 0

Kubernetes组网为一个Master(安装etcd kubernetes-master)+一个minion(安装kubernetes-node docker flannel bridge-utils),配置完成后,Master节点似乎正常:

# kubectl get nodes
NAME             LABELS                                  STATUS    AGE
172.16.182.185   kubernetes.io/hostname=172.16.182.185   Ready     3h
# kubectl version
Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.0", GitCommit:"86327329213fed4af2661c5ae1e92f9956b24f55", GitTreeState:"clean"}
Server Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.0", GitCommit:"86327329213fed4af2661c5ae1e92f9956b24f55", GitTreeState:"clean"}

而minion节点

#kubectl version

Client Version: version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.0", GitCommit:"86327329213fed4af2661c5ae1e92f9956b24f55", GitTreeState:"clean"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

# kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?

检查本地的8080端口如下:

# lsof -i:8080
COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
kube-prox 16201 root    5u  IPv4  82287      0t0  TCP 172.16.182.185:45862->172.16.182.184:webcache (ESTABLISHED)
kube-prox 16201 root    6u  IPv4  83079      0t0  TCP 172.16.182.185:45861->172.16.182.184:webcache (ESTABLISHED)
kubelet   16336 root    8u  IPv4  77991      0t0  TCP 172.16.182.185:45753->172.16.182.184:webcache (ESTABLISHED)
kubelet   16336 root    9u  IPv4  77992      0t0  TCP 172.16.182.185:45754->172.16.182.184:webcache (ESTABLISHED)
kubelet   16336 root   10u  IPv4  77993      0t0  TCP 172.16.182.185:45755->172.16.182.184:webcache (ESTABLISHED)
kubelet   16336 root   12u  IPv4  77997      0t0  TCP 172.16.182.185:45756->172.16.182.184:webcache (ESTABLISHED)
kubelet   16336 root   13u  IPv4  77112      0t0  TCP 172.16.182.185:45757->172.16.182.184:webcache (ESTABLISHED)

加载中
0
atlasfly
atlasfly
我也是碰到和你一样的问题解决不了,但是你在minion主机上用kebuctl -s http://apiserverIP:8080 version的时候就能查看到了
笨鸟不想飞
笨鸟不想飞
果然好使!
zhang_gq
zhang_gq
回复 @atlasfly : 果然好使!
atlasfly
atlasfly
通过-s 指定连接的server就能解决,貌似是minion主机上默认去连接localhost的8080端口
0
zhang_gq
zhang_gq

另外之前有个帖子说设置 alias kubectl='kubectl --kubeconfig=/etc/kubernetes/kubelet.kubeconfig',事实发现没用

# alias kubectl='kubectl --kubeconfig=/etc/kubernetes/kubelet.kubeconfig'
[root@minion1 kubernetes]# kubectl get nodes
error: stat /etc/kubernetes/kubelet.kubeconfig: no such file or directory

0
叫我查尔斯好了
叫我查尔斯好了

执行

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

返回顶部
顶部