kubectl get nodes` returns `与服务器的连接 10.xxxxxxxxx 被拒绝

kubectl get nodes` returns `The connection to the server 10.xxxxxxxxx was refused

kubectl get pods -o wide --all-namespaces

它给 kubectl get nodes returns 'The connection to the server 10.xxxxxxxxx was refused. did you specify right host or port?'

敬请指导。

谢谢

看起来你的 kubeconfig 在执行 kubeadm init 后不正确,你没有执行以下步骤。

Your Kubernetes master has initialized successfully!
To start using your cluster, you need to run (as a regular user):
sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf

尝试并检查

如果您使用的是 GKE,请尝试执行以下步骤来自动生成 kubeconfig

gcloud container clusters get-credentials "CLUSTER NAME"