Kubectl可以记住我吗? [英] can Kubectl remember me?

查看:382
本文介绍了Kubectl可以记住我吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在kubernetes api服务器上实现了基本身份验证,现在我正尝试以一种可以简单运行kubectl get pods

I have implemented basic authentication on my kubernetes api-server, now I am trying to configure my ./kube/config file in a way I could simply run, kubectl get pods

 kubectl config set-cluster digitalocean \
                      --server=https://SERVER:6443 \
                      --insecure-skip-tls-verify=true \
                      --api-version="v1" 
 kubectl config set-context digitalocean --cluster=digitalocean --user=admin
 kubectl config set-credentials admin --password="PASSWORD" 
 kubectl config use-context digitalocean

但是现在,它两次要求输入凭据:

But now, it asks for credentials twice like :

dev@desktop: ~/code/go/src/bitbucket.org/cescoferraro                                                                   
$ kubectl get pods                                                                                                      
Please enter Username: admin                                                                                             
enter Password: PASSWORD
Please enter Username: admin                                                                                            
Please enter Password: PASSWORD                                                                                      
NAME                                                READY     STATUS    RESTARTS   AGE 

或者我需要像这样传递标志

or I need to pass the flags like

kubectl get pods --username=admin --password=PASSWORD

这是默认行为吗?我希望我的配置了解我.我该怎么办?

is this the default behavior? I want my config to know me. What can I do?

推荐答案

可以提供kubectl config view的输出吗?我认为问题可能是您需要执行类似的操作

Can you provide the output of kubectl config view? I think the problem might be you need to do something like

kubectl config set-credentials cluster-admin --username=admin --password=PASSWORD

代替

kubectl config set-credentials admin --password="PASSWORD".

这篇关于Kubectl可以记住我吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆