github地址:

​​       ​​​https://github.com/kubernetes/dashboard/releases​

安装说明

上面由当前dashboard的匹配信息和安装yaml文件。

下载yaml文件到本地

wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.1/aio/deploy/recommended.yaml
mv recommended.yaml dashboardv2.6.1.ymal

修改dashboard service,更改service类型为NodePort,并暴露30110端口


spec:
type: NodePort
ports:
- port: 443
targetPort: 8443
nodePort: 30110
selector:

安装

kubectl allpy -f dashboardv2.6.1.ymal

 创建sa账户并绑定为cluster-admin的clusterrolebinding,1.24版本之前会自动生成绑定成功后的sa账户secret。新版需要手动创建

 

  创建sa账户 admin

#切换 namespace
root@deploy:/dashboar# kubectl config set-context --namespace kubernetes-dashboard --current
Context "context-cluster1" modified.

root@deploy:/dashboar# kubectl create serviceaccount admin
serviceaccount/admin created

将sa账户admin绑定到集群角色cluster-admin

root@deploy:/dashboar# kubectl create clusterrolebinding admin --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:admin
clusterrolebinding.rbac.authorization.k8s.io/admin created

 查看admin集群角色

kubectl get clusterrolebindings.rbac.authorization.k8s.io |grep admin


创建secret创建的用户token

root@deploy:/dashboar# vim usercrendentitals.yaml 
apiVersion: v1
kind: Secret
type: kubernetes.io/service-account-token
metadata:
  name: dashboard-admin-user
  namespace: kubernetes-dashboard 
  annotations:
    kubernetes.io/service-account.name: "admin"

root@deploy:/dashboar# kubectl apply -f usercrendentitals.yaml

获取secret创建的用户token

root@deploy:/dashboar# kubectl describe secrets dashboard-admin-user |grep token

​kubectl describe secrets dashboard-admin-user |grep token

登录界面