mac 本地k8s命令报错:The connection to the server localhost:8080 was refused - did you specify the right ho

mac 本地装的docker 自带的k8s,之前一直没问题,突然有一次使用k8s命令时报错:The connection to the server localhost:8080 was refused - did you specify the right host or port?

kubectl get node   //这样就报错

命令中指定config文件就没问题:

kubectl --kubeconfig ./config get node   //这样就ok

查询k8s config配置为空:

kubectl config view显示如下:

apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []

解决方法:

1、unset KUBECONFIG     //使用该命令解决,临时解决,每次打开新的终端都要使用一次

2、export KUBECONFIG=~/.kube/config   //同上

后来发现 配置文件 .bashfile 文件里配置了KUBECONFIG的环境变量,把不用的删去即可,或者export KUBECONFIG=~/.kube/config写入,保存.bashfile

解决。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值