现象描述
K8s集群初始化成功后,kubectl get nodes 查看节点信息时报错:
报错信息:文章来源:https://www.toymoban.com/news/detail-509724.html
The connection to the server localhost:8080 was refused - did you specify the right host or port?
解决办法:
执行以下命令文章来源地址https://www.toymoban.com/news/detail-509724.html
[root@slave1 ~]# kubectl get pod,svc
The connection to the server localhost:8080 was refused - did you specify the right host or port?
[root@slave1 ~]# mkdir -p $HOME/.kube
[root@slave1 ~]# cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[root@slave1 ~]# echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
[root@slave1 ~]# source ~/.bash_profile
[root@slave1 ~]# chown $(id -u):$(id -g) $HOME/.kube/config
[root@slave1 ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-6867cdf567-966sx 1/1 Running 0 15m
到了这里,关于K8s ❉ The connection to the server 报错localhost:8080 was refused的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!