1、獲取k8s版本:
2、訪問dashboard的github:https://github.com/kubernetes/dashboard/releases,然后找到對應的版本
3、然后將yaml文件下載到服務器上:wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta3/aio/deploy/recommended.yaml
4、修改yaml文件,將svc的類型修改為NodePort
5、部署:kubectl apply -f recommended.yaml
6、獲取NodePort:
7、后通過https://ip:NodePort的方式訪問
8、創建admin-token:
kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: name: admin annotations: rbac.authorization.kubernetes.io/autoupdate: "true" roleRef: kind: ClusterRole name: cluster-admin apiGroup: rbac.authorization.k8s.io subjects: - kind: ServiceAccount name: admin namespace: kubernetes-dashboard --- apiVersion: v1 kind: ServiceAccount metadata: name: admin namespace: kubernetes-dashboard labels: kubernetes.io/cluster-service: "true" addonmanager.kubernetes.io/mode: Reconcile
然后部署:kubectl create -f admin-token.yaml
9、獲取token信息:
復制token信息,粘貼到ui端的token處即可,注意token復制的時候不要有空格,否則認證失敗