# Kubernetes Dashboard

# 安装

# 下载官方部署配置文件

wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
1

# 修改属性

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  type: NodePort   #新增
  ports:
    - port: 443
      targetPort: 8443
  selector:
    k8s-app: kubernetes-dashboard
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# 创建资源

kubectl apply -f recommend.yaml
1

# 查看资源是否已经就绪

kubectl get all -n kubernetes-dashboard -o wide
1

# 访问测试

https://节点ip:端口

# 配置所有权限账号

# 创建账号配置文件

vim dashboard-admin.yaml
1

# 配置文件

apiVersion: v1 
kind: ServiceAccount 
metadata: 
  labels: 
    k8s-app: kubernetes-dashboard 
  name: dashboard-admin 
  namespace: kubernetes-dashboard 
--- 
apiVersion: rbac.authorization.k8s.io/v1 
kind: ClusterRoleBinding 
metadata: 
  name: dashboard-admin-cluster-role 
roleRef: 
  apiGroup: rbac.authorization.k8s.io 
  kind: ClusterRole 
  name: cluster-admin 
subjects: 
  - kind: ServiceAccount
    name: dashboard-admin
    namespace: kubernetes-dashboard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

# 创建资源

kubectl  apply -f dashboard-admin.yaml
1

# 查看账号信息

kubectl describe serviceaccount dashboard-admin -n kubernetes-dashboard
1
[root@k8s-master Dashboard]# kubectl describe serviceaccount dashboard-admin -n kubernetes-dashboard
Name:                dashboard-admin
Namespace:           kubernetes-dashboard
Labels:              k8s-app=kubernetes-dashboard
Annotations:         <none>
Image pull secrets:  <none>
Mountable secrets:   dashboard-admin-token-sn8x4
Tokens:              dashboard-admin-token-sn8x4
Events:              <none>
1
2
3
4
5
6
7
8
9

# 获取账号的 token 登录 dashboard

kubectl describe secrets  dashboard-admin-token-sn8x4  -n kubernetes-dashboard
1
[root@k8s-master Dashboard]# kubectl describe secrets  dashboard-admin-token-sn8x4  -n kubernetes-dashboard
Name:         dashboard-admin-token-sn8x4
Namespace:    kubernetes-dashboard
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: dashboard-admin
              kubernetes.io/service-account.uid: 3f9342b6-ac04-4753-a84f-edbbb8e08dd6

Type:  kubernetes.io/service-account-token

Data
====
ca.crt:     1099 bytes
namespace:  20 bytes
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IkhTNktIRXk2N09XdVk5NHA5el9zVEpJV0pHdlQ5WTBFVzdrbVFab2k4OVUifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tc244eDQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiM2Y5MzQyYjYtYWMwNC00NzUzLWE4NGYtZWRiYmI4ZTA4ZGQ2Iiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmVybmV0ZXMtZGFzaGJvYXJkOmRhc2hib2FyZC1hZG1pbiJ9.LW5xJYnKAwlMIXQYaEbIo6aXbiXY-_VaxiTji59lbJI2phw7iLmzyRo46v7cEZZ12aFEy2u_hKAnsvAMJZi3sPm9mF7WZVv0aOPIsGbM55XO8v81w7RbzOa3hA40GMnPXym-aAcrkdO4_xyY5ehDdrdl1pmhm_1oSTCA5oc2yajpqGv-4R0Jp_pcGRXcmt7xvgGdNI9SOXUQ7IUizUpKLaqSzY1TVnPTssZkpUtLoqY8tACERRRV8QKmFtOGMas9ra_HQzjI_7VnYHEVh_raftOOcmDj19U6G4YtceOE_08tLhARARHI2E2D74kueZbCAVhn49rIkOAiMleV21HD7g
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# 登录

# 设置语言为中文

# 使用

上次更新: 2023/12/27