創(chuàng)建集群用戶
1妖异、創(chuàng)建用戶
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: admin-user
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kube-system
2荣恐、獲取管理員用戶的Token春贸,通過執(zhí)行如下命令獲取系統(tǒng)Token信息
kubectl describe secret admin-user --namespace=kube-system
3待秃、導(dǎo)入kubeconfig文件
DASH_TOCKEN=$(kubectl get secret -n kube-system admin-user-token-4j272 -o jsonpath={.data.token}|base64 -d)
kubectl config set-cluster kubernetes --server=https://172.16.0.9:6443 --kubeconfig=/root/kube-admin.conf
kubectl config set-credentials admin-user --token=$DASH_TOCKEN --kubeconfig=/root/kube-admin.conf
kubectl config set-context admin-user@kubernetes --cluster=kubernetes --user=admin-user --kubeconfig=/root/kube-admin.conf
kubectl config use-context admin-user@kubernetes --kubeconfig=/root/kube-admin.conf
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者