Kubernetes 部署可视化dashboard管理面板

官方参考连接:https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md

 

 

 

前提:按照官方的文档启动kubectl proxy之后并且访问ui界面的时候提示输入token,获取方法如下:

 

 

第一步:创建serviceaccount  serviceaccount.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard

kubectl apply -f  serviceaccount.yaml

第二步:角色绑定 rolebinding.yaml

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kubernetes-dashboard

kubectl apply -f  rolebinding.yaml

 

第三步:获取token

kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"
执行完毕后会输出很长的字符串复制使用即可。
 

 

posted @ 2022-02-09 17:18  忙碌在路上  阅读(302)  评论(0编辑  收藏  举报