This is the 8th day of my participation in the August More text Challenge. For details, see: August More Text Challenge

1. Why use visual interfaces

Once node is installed, you need to use Kubectl for execution and operations, but using the command line all the time can be cumbersome for new users. So can you have a visual page where you can just point at the page and do the job of the command?

The Dashboard plugin is officially available as a visualization tool. Highly recommended.

It is recommended that Bashboard be used in conjunction with Kubectl for daily operations.

2. Install

1. Download the file

Select the folder and download recommended. Yaml into the folder.

Wget HTTP: / / https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.3/aio/deploy/recommended.yamlCopy the code

2. Modify the configuration

After the download, modify the configuration.

vi recommended.yaml
Copy the code

We need to change the type to NodePort to specify that it can be accessed from the external network, otherwise other computers will not be able to access it, please pay attention!

3. The installation

Add Dashboard to K8s

kubectl apply -f recommended.yaml
Copy the code

4. Verify

kubectl -n kubernetes-dashboard get all -l k8s-app=kubernetes-dashboard
Copy the code

The following figure shows that the externally mapped port is 32241, which may vary from person to person. Please replace the port by yourself.

You can also see that the started port can be tested for access using the following command.

Kubectl-n kubernetes-dashboard port-forward pod/kubernetes-dashboard-5c785c8bcf-z94nt 32241 // AccessCopy the code

Pod/kubernetes-dashboard-5C785C8bcF-z94nt and port are obtained in the figure above. Please modify the configuration by yourself.

If an installation error occurs, run the following command to view the error information.

sudo kubectl logs kubernetes-dashboard-6dccb458d5-x7xft --namespace=kubernetes-dashboard
Copy the code

5. Create a user

K8s has RBAC permissions, so special users must be used to access it. The token is required for login, so you need to obtain the token of the new user.

Kubectl create serviceAccount dashboard-admin -n kubernetes-dashboard Kubectl create Clusterrolebinding Dashboard-admin-rb Kubectl create clusterrolebinding dashboard-admin-rb kubectl create clusterrolebinding dashboard-admin-rb kubectl create clusterrolebinding dashboard-admin-rb kubectl create clusterrolebinding dashboard-admin-rb --clusterrole=cluster-admin -- serviceAccount =kubernetes-dashboard: dashboark-admin # Get account token kubectl get secrets -n Kubernetes - dashboard | grep dashboard - admin through account access token (dashboard - admin - token - XXXX to get the above) kubectl describe secrets dashboard-admin-token-xxxx -n kubernetes-dashboardCopy the code

If some ids generated during the command execution are different, replace them accordingly.

After creating a User access token after logging in, can’t see the specific information, or an error (statefulsets. Apps is forbidden: User “system: serviceaccount: kubernetes – dashb…) It must be a user problem. Run the preceding command again.

6. Access

Access IP: 32241

You can modify the port number obtained above.

Login, select the token, and the above obtained token copy and input.

3. The unloading

If the dashboard is incorrectly installed, you can uninstall it and reinstall it.

kubectl get secret,sa,role,rolebinding,services,deployments --namespace=kubernetes-dashboard | grep dashboard
 
kubectl delete deployment kubernetes-dashboard --namespace=kubernetes-dashboard  
kubectl delete service kubernetes-dashboard  --namespace=kubernetes-dashboard 
kubectl delete role kubernetes-dashboard-minimal --namespace=kubernetes-dashboard
kubectl delete rolebinding kubernetes-dashboard-minimal --namespace=kubernetes-dashboard
kubectl delete sa kubernetes-dashboard --namespace=kubernetes-dashboard
kubectl delete secret kubernetes-dashboard-certs --namespace=kubernetes-dashboard
kubectl delete secret kubernetes-dashboard-key-holder --namespace=kubernetes-dashboard
Copy the code