kubectl配置token认证
2020-12-06 本文已影响0人
wwq2020
如果没有account
kubectl create namespace accounttest
kubectl create serviceaccount myaccount -n accounttest
kubectl create clusterrolebinding myaccount --clusterrole=cluster-admin --serviceaccount=accounttest:myaccount
查看token
kubectl describe secrets -n accounttest $(kubectl -n accounttest get secret | awk '/myaccount/{print $1}')
配置kubectl config
kubectl config set-credentials myaccount --token=查到的token
kubectl config set-cluster mycluster --insecure-skip-tls-verify=true --server=集群地址
kubectl config set-context mycontext --cluster=mycluster --user=myaccount
使用
kubectl config use-context mycontext
kubectl get pods -A