#One key to build port: 32000 Host: master
kubectl apply -f https://gitee.com/zmhcode/k8s-config/raw/master/dashboard.yaml
#You can also modify the port and deploy the host after downloading, execute the creation
kubectl create -f dashboard.yaml
#Display running means normal
kubectl get pod -A
#Create a service account If an error message indicates that it already exists, it does not matter, continue to the next step
kubectl create serviceaccount dashboard-admin -n kubernetes-dashboard
#Binding cluster role If the error message indicates that it already exists, it does not matter, continue to the next step
kubectl create clusterrolebinding dashboard-admin --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:dashboard-admin
#kubectl create clusterrolebinding service binding name--clusterrole=cluster role--serviceaccount=namespace: service account
#Open the browser and pay attention to https
https://master_IP:32000
#log in
Token method:
kubectl get secret -n kubernetes-dashboard | grep dashboard-admin
display:
dashboard-admin-token-8kjlc kubernetes.io/service-account-token 3 4m34s
kubectl describe secret dashboard-admin-token-8kjlc -n kubernetes-dashboard
display:
Name: dashboard-admin-token-8kjlc
Namespace: kubernetes-dashboard
Labels: <none>
Annotations: kubernetes.io/service-account.name: dashboard-admin
kubernetes.io/service-account.uid: 05b26c6b-cb02-4e43-a9ba-38c7553e2c29
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1025 bytes
namespace: 20 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6InR4bWdmaVZ。。。。。。。。。。。。。。。
Copy the token to the browser
File method:
Generate kubeconfig file
# Get token
DASH_TOCKEN=$(kubectl get secret -n kubernetes-dashboard dashboard-admin-token-8kjlc -o jsonpath={.data.token} |base64 -d)
# Set a cluster entry IP in the kubeconfig file to the master host IP
kubectl config set-cluster kubernetes --server=IP:6443 --kubeconfig=/root/dashbord-admin.conf
# Set a user entry in the kubeconfig file
kubectl config set-credentials dashboard-admin --token=$DASH_TOCKEN --kubeconfig=/root/dashbord-admin.conf
# Set a context entry in the kubeconfig file
kubectl config set-context dashboard-admin@kubernetes --cluster=kubernetes --user=dashboard-admin --kubeconfig=/root/dashbord-admin.conf
#Set the current context in the kubeconfig file
kubectl config use-context dashboard-admin@kubernetes --kubeconfig=/root/dashbord-admin.conf
The dashbord-admin.conf generated in the current directory can be used to log in to the dashboard