今天在Kubernetes的从节点上运行命令【kubectl】出现了如下错误
[root@k8snode1 kubernetes]# kubectl get pod
The connection to the server localhost:8080 was refused - did you specify the right host or port?出现这个问题的原因是kubectl命令需要使用kubernetes-admin来运行,解决方法如下,将主节点中的【/etc/kubernetes/admin.conf】文件拷贝到从节点相同目录下,然后配置环境变量:
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile立即生效
source ~/.bash_profile在运行kubectl命令就成功了

版权声明:本文为qq_24046745原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。