我是靠谱客的博主 多情母鸡,这篇文章主要介绍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
解决。。。。
最后
以上就是多情母鸡最近收集整理的关于mac 本地k8s命令报错:The connection to the server localhost:8080 was refused - did you specify the right ho的全部内容,更多相关mac内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复