can Kubectl remember me?

大兔子大兔子 提交于 2019-12-07 15:36:02

问题


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?


回答1:


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

instead of

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



来源:https://stackoverflow.com/questions/35951253/can-kubectl-remember-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!