[英]How to configure kubectl in kubernetes cluster
I have provisioned a kuberenetes cluster using this saltstack repo: 我已经使用此saltstack存储库配置了kuberenetes集群:
https://github.com/valentin2105/Kubernetes-Saltstack https://github.com/valentin2105/Kubernetes-Saltstack
Now, I am not able to configure my kubectl CLI to access the cluster. 现在,我无法配置kubectl CLI来访问集群。 Is there a way to reset the credentials?
有没有办法重置凭据? Is there a way to get configure properly the .kube/config with the right context, user, credentials and cluster name retrieving the info from the servers?
有没有一种方法可以通过正确的上下文,用户,凭据和群集名称从服务器中检索信息来正确配置.kube / config?
I am new to kubernetes, so maybe I am missing something here. 我是kubernetes的新手,所以也许我在这里错过了一些东西。
To be able to set your cluster you can do as follow: 要设置集群,您可以执行以下操作:
kubectl config set-cluster k8s-cluster --server=${CLUSTER} [--insecure-skip-tls-verify=true]
Then you need to set your context ( depending on your kubernetes configuration 然后您需要设置上下文(取决于您的kubernetes配置
kubectl config set-context k8s-context --cluster=k8s-cluster --namespace=${NS}
If you are using a RBAC, you might need to specify your user and pass your connection token or your login password: 如果使用的是RBAC,则可能需要指定用户并传递连接令牌或登录密码:
For this advanced usage you can see the docs https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-context-and-configuration 对于此高级用法,您可以参阅docs https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-context-and-configuration
Now and finally to use your context you only have to: 现在最后要使用您的上下文,您只需:
kubectl config use-context ${USER}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.