??今天在Kubernetes的從節(jié)點上運行命令【kubectl】出現(xiàn)了如下錯誤
[root@k8snode1 kubernetes]# kubectl get pod
The connection to the server localhost:8080 was refused - did you specify the right host or port?
??出現(xiàn)這個問題的原因是kubectl命令需要使用kubernetes-admin來運行,解決方法如下,將主節(jié)點中的【/etc/kubernetes/admin.conf】文件拷貝到從節(jié)點相同目錄下,然后配置環(huán)境變量:
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
立即生效
source ~/.bash_profile
接著再運行kubectl命令就OK了

get pod