为什么Kubectl与sudo会有不同的行为? [英] Why does kubectl have different behavior with sudo?
本文介绍了为什么Kubectl与sudo会有不同的行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用sudo运行kubectl get pods
:
sudo kubectl get pods
The connection to the server localhost:8080 was refused - did you specify the right host or port?
以普通用户身份运行:
kubectl get pods
No resources found.
推荐答案
默认情况下,kubectl在〜/.kube/config(或指向$ KUBECONFIG的文件)中查找以确定要连接的服务器.以超级用户身份运行命令时,您的主目录和环境是不同的.当找不到连接信息时,kubectl默认为localhost:8080
By default, kubectl looks in ~/.kube/config (or the file pointed to be $KUBECONFIG) to determine what server to connect to. Your home directory and environment are different when running commands as root. When no connection info is found, kubectl defaults to localhost:8080
这篇关于为什么Kubectl与sudo会有不同的行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文