现象:
[root@localhost shell]# kubectl version Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"} The connection to the server 192.168.111.104:8443 was refused - did you specify the right host or port?
查看进程
[root@localhost kubernetes]# ps -aux|grep kube root 14558 0.0 1.1 46972 21372 pts/0 Sl 15:17 0:00 kubectl proxy --port=8443 root 18251 0.0 0.0 112708 980 pts/0 S+ 15:22 0:00 grep --color=auto kube kube 127353 0.8 4.6 141504 85872 ? Ssl 11:43 1:52 /usr/bin/kube-apiserver --logtostderr=true --v=0 --etcd-servers=http://127.0.0.1:2379 --insecure-bind-address=127.0.0.1 --allow-privileged=false --service-cluster-ip-range=10.254.0.0/16 --admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota kube 127368 2.2 2.4 169288 44860 ? Ssl 11:43 4:58 /usr/bin/kube-controller-manager --logtostderr=true --v=0 --master=http://127.0.0.1:8080 kube 127381 0.2 1.8 157404 34404 ? Ssl 11:43 0:29 /usr/bin/kube-scheduler --logtostderr=true --v=0 --master=http://127.0.0.1:8080 root 127412 0.9 2.2 301156 41720 ? Ssl 11:43 2:04 /usr/bin/kube-proxy --logtostderr=true --v=0 --master=http://127.0.0.1:8080
关键进程kube-apiserver,kube-controller-manager,kube-scheduler,kube-proxy都在
解决
删除/etc/kubernetes/config
[root@localhost kubernetes]# cd /root/.kube [root@localhost .kube]# ls config [root@localhost .kube]# cat config apiVersion: v1 clusters: - cluster: certificate-authority: /root/.minikube/ca.crt server: https://192.168.111.104:8443 name: minikube contexts: - context: cluster: minikube user: minikube name: minikube current-context: minikube kind: Config preferences: {} users: - name: minikube user: client-certificate: /root/.minikube/client.crt client-key: /root/.minikube/client.key [root@localhost .kube]# ls config [root@localhost .kube]# rm config rm: remove regular file ‘config’? y
重启服务
[root@localhost .kube]# systemctl restart kube-apiserver [root@localhost .kube]# systemctl restart kube-controller-manager [root@localhost .kube]# systemctl restart kube-scheduler [root@localhost .kube]# systemctl restart kube-proxy
验证
[root@localhost .kube]# kubectl version Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-07-03T15:31:10Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"} [root@localhost .kube]# ls http-cache [root@localhost .kube]# pwd /root/.kube [root@localhost .kube]# ls http-cache [root@localhost .kube]# cat http-cache/ cat: http-cache/: Is a directory [root@localhost .kube]# kubectl get nodes No resources found.
[root@localhost .kube]# kubectl get componentstatus
NAME STATUS MESSAGE ERROR
etcd-0 Healthy {"health":"true"}
scheduler Healthy ok
controller-manager Healthy ok
[root@localhost .kube]#
问题解决
网上方法k8s V1.11.1报错:The connection to the server localhost:8080 was refused,不过没有解决我的问题