解决k8s集群在节点运行kubectl出现的错误:The connection to the server localhost:8080 was refused - did you specify the right host or port?
今天开机后测试k8s集群,在节点上运行kubectl出现如下错误:
百度了一下发现是kubernetes master 没有与主机绑定,即集群初始化的时候没有绑定,在本机环境变量中再次绑定下即可解决。
#方式一 #编辑环境变量文件,在文件最后添加一行 vim /etc/profile export KUBECONFIG=/etc/kubernetes/admin.conf #方式二 #直接追加文件内容 echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> /etc/profile
添加完成后source一下使之生效即可。
source /etc/profile
、、、