K8S报错——The connection to the server localhost:8080 was refused

问题描述

执行

kubectl get pod

报错

The connection to the server localhost:8080 was refused - did you specify the right host or port?

问题解决

出现这个问题的原因是kubectl命令需要使用kubernetes-admin来运行,解决方法如下,配置环境变量:

echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
# 立即生效
source ~/.bash_profile
发布了36 篇原创文章 · 获赞 3 · 访问量 2921

猜你喜欢

转载自blog.csdn.net/weixin_39836585/article/details/102586750