k8s component-UI interface Dashboard construction

1. Introduction to Dashboard

Dashboard is a web-based Kubernetes user interface. You can use the dashboard to deploy containerized applications to Kubernetes clusters, troubleshoot containerized applications, and manage cluster resources. The dashboard can be used to get an overview of the applications running on the cluster, as well as to create or modify individual Kubernetes resources (such as deployments, tasks, daemons, etc.). Deployments can be extended using the deployment wizard, rolling updates initiated, pods restarted or new applications deployed.
The dashboard also provides information about the status of Kubernetes resources in the cluster and any errors that may have occurred.

2. Dashboard deployment

2.1 download yaml

  1 [root@master ~]# mkdir dashboard					#建议将yaml存储到本地
  2 [root@master ~]# cd dashboard/
  3 [root@master dashboard]# wget https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml

2.2 Modify to domestic source

1 [root@master ~]# cd dashboard/
  2 [root@master dashboard]# vim kubernetes-dashboard.yaml
  3 ……
  4 image: ydtong/kubernetes-dashboard-amd64:v1.10.1
  5 ……

提示:将yaml文件中的image字段修改为ydtong/kubernetes-dashboard-amd64:v1.10.1

The service module configuration exposes the external access port of the k8s cluster, and the configuration is as follows:

# ------------------- Dashboard Service ------------------- #
kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  type: NodePort
  ports:
    - port: 443
      targetPort: 8443
      nodePort: 30001
  selector:
    k8s-app: kubernetes-dashboard
  • Tip: Add typea field, and modify it toNodePort

2.3 Start Dashboard

[root@master dashboard]# kubectl apply -f kubernetes-dashboard.yaml 
secret/kubernetes-dashboard-certs created
serviceaccount/kubernetes-dashboard created
role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
deployment.apps/kubernetes-dashboard created
service/kubernetes-dashboard created

Delete configuration file command:

kubectl delete -f kubernetes-dashboard.yaml 

2.4 Access the web interface

Node node address: https://192.168.10.134:30001
insert image description here

  • Tip: You can also log in to the master node, and you must use https to log in

2.5. Log in with a token (you need to create a user who can access the Dashboard)

Create an account.yaml file and configure it as follows:

# Create Service Account
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
---
# Create ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kube-system

Create user command:

[root@master yaml]# kubectl create -f account.yaml

Get tokens:

[root@master dashboard]# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
Name:         admin-user-token-vck2j
Namespace:    kube-system
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: admin-user
              kubernetes.io/service-account.uid: b8ec1ba2-1b36-11ea-85a5-080027f16b5b

Type:  kubernetes.io/service-account-token

Data
====
ca.crt:     1025 bytes
namespace:  11 bytes
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXZjazJqIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJiOGVjMWJhMi0xYjM2LTExZWEtODVhNS0wODAwMjdmMTZiNWIiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.BHKsuojE4dazrj831eLdTGLMrMtYX7__398cOv43r0AMyBQZZVj8dgYLo-_NjZZ77BCNt4KnaUDg0kirW-wv8iHL7bIroZ3H-YUrJlNcNqocQ_PYEcmY6MSCtTXjwRCTe-j5SQ49CYhZg8MIf2T_SFSVwYxsiP9eCr0yQ411drXjFwLduFkBvHw7AyQ6cBz55S8pTSOuNr-0yENAWCYrhjtNrZjjvijtlJvGug6uUYGj-lRBfYxkD9nlqG8xn8C8_tHuQCTBGaPuZJNa9bgvWNJE0L4qzax8t-fjzmP5m1311aOHL5NlvgFFp3qFvN3kKcWu6PGa55Ecz9f4fcQfZA

3. The final interface is as follows:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_44006354/article/details/103480942