• -------------------------------------------------------------
  • ====================================

Kubernetes-kubectl命令出现错误The connection to the server localhost:8080 was refused – did you specif…

docker dewbay 4年前 (2020-08-10) 2222次浏览 已收录 0个评论 扫描二维码

今天在 Kubernetes 的从节点上运行命令【kubectl】出现了如下错误

  1. [root@k8snode1 kubernetes]# kubectl get pod
  2. 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命令就成功了


露水湾 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Kubernetes-kubectl命令出现错误The connection to the server localhost:8080 was refused – did you specif…
喜欢 (1)
[]
分享 (0)
关于作者:
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址