安装dashboard

helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard

修改NodePort

kubectl edit svc  -n kube-system kubernetes-dashboard-kong-proxy

ClusterIP 改为NodePort

创建token

cat > dashboard-user-token.yaml << EOF
apiVersion: v1
kind: ServiceAccount
metadata:
  name: dashboard-user
  namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: dashboard-cluster-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: dashboard-user
  namespace: kubernetes-dashboard
---
apiVersion: v1
kind: Secret
metadata:
  name: dashboard-user
  namespace: kubernetes-dashboard
  annotations:
    kubernetes.io/service-account.name: "dashboard-user"
type: kubernetes.io/service-account-token
EOF
kubectl apply -f dashboard-user-token.yaml

获取token

kubectl get secret -n kubernetes-dashboard dashboard-user -o jsonpath={".data.token"} | base64 -d