为什么在只配置了default服务帐户的主机上使用带有模拟--as=的kubectl会导致“连接到服务器本地主机:8080被拒绝”?
我已经将kubectl下载到只配置了default服务帐户的主机上。如果我试图模拟任何用户,例如system:anonymous,将返回以下错误消息:“连接到服务器本地主机:8080被拒绝”。
我可以通过使用kubectl proxy --port=8080启动本地代理来解决此问题,但是,我希望避免这种情况。
当使用模拟(--as=)时,为什么kubectl尝试连接到localhost:8080?
kube@ctf1-k8s-deploy1-545977f47-g9dpl:~$ kubectl config view
apiVersion: v1
clusters: null
contexts: null
current-context: ""
kind: Config
preferences: {}
users: null
kube@ctf1-k8s-deploy1-545977f47-g9dpl:~$ ls /var/run/secrets/kubernetes.io/serviceaccount/
ca.crt namespace token
kube@ctf1-k8s-deploy1-545977f47-g9dpl:~$ kubectl auth can-i --list --as=system:anonymous
The connection to the server localhost:8080 was refused - did you specify the right host or port?发布于 2020-03-24 17:01:44
clusters需要拥有Kubernetes API Server的主机和端口。
clusters:
- cluster:
certificate-authority-data: DATA+OMITTED
server: https://API_SERVER_HOST:PORT编辑:
当--as作为参数添加到kubectl auth can-i中时,kubectl不再使用集群内配置,这就是为什么它引用localhost:8080而不是正确的API Server IP。
https://stackoverflow.com/questions/60827632
复制相似问题