在k8s集群初始化中,出现访问端口失败问题
现象:
[root@node3 ~]# kubectl get node
The connection to the server localhost:8080 was refused - did you specify the right host or port?
解决方案:
[root@node3 ~]# echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> /etc/profile
[root@node3 ~]# source /etc/profile
[root@node3 ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
node2 NotReady <none> 7m35s v1.23.17
node3 Ready control-plane,master 26m v1.23.17
原因:这是重新搭建的k8s集群 这次更换了master节点, kubernetes-admin命令没有同步过来,没有将node3(master)节点与本机绑定, 需要重新声明环境变量,