Bootstrap

Kubernetes可视化界面

DashBoard

  • Kubernetes Dashboard 是 Kubernetes 集群的一个开箱即用的 Web UI,提供了一种图形化的方式来管理和监视 Kubernetes 集群中的资源。它允许用户直接在浏览器中执行许多常见的 Kubernetes 管理任务,如部署应用、监控应用状态、执行故障排查以及管理 Kubernetes 中的各种资源。

部署DashBoard

[root@k8s-master ~]# wget -c https://gitee.com/kong-xiangyuxcz/svn/releases/download/Dashboard/recommended.yaml
--2025-01-25 04:00:24--  https://gitee.com/kong-xiangyuxcz/svn/releases/download/Dashboard/recommended.yaml
Resolving gitee.com (gitee.com)... 180.76.199.13
Connecting to gitee.com (gitee.com)|180.76.199.13|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://gitee.com/kong-xiangyuxcz/svn/attach_files/1778112/download/recommended.yaml [following]
--2025-01-25 04:00:25--  https://gitee.com/kong-xiangyuxcz/svn/attach_files/1778112/download/recommended.yaml
Reusing existing connection to gitee.com:443.
HTTP request sent, awaiting response... 302 Found
Location: https://foruda.gitee.com/attach_file/1716450459731550796/recommended.yaml?token=bbeb599ae978ce6b8d57f091196fba4c&ts=1737795625&attname=recommended.yaml [following]
--2025-01-25 04:00:25--  https://foruda.gitee.com/attach_file/1716450459731550796/recommended.yaml?token=bbeb599ae978ce6b8d57f091196fba4c&ts=1737795625&attname=recommended.yaml
Resolving foruda.gitee.com (foruda.gitee.com)... 180.76.199.13
Connecting to foruda.gitee.com (foruda.gitee.com)|180.76.199.13|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7621 (7.4K) [text/plain]
Saving to: ‘recommended.yaml’

100%[==================================================================================================================================================>] 7,621       --.-K/s   in 0s      

2025-01-25 04:00:25 (684 MB/s) - ‘recommended.yaml’ saved [7621/7621]

[root@k8s-master ~]# docker pull kubernetesui/dashboard:v2.7.0

v2.7.0: Pulling from kubernetesui/dashboard
ee3247c7e545: Pull complete 
8e052fd7e2d0: Pull complete 
Digest: sha256:2e500d29e9d5f4a086b908eb8dfe7ecac57d2ab09d65b24f588b1d449841ef93
Status: Downloaded newer image for kubernetesui/dashboard:v2.7.0
docker.io/kubernetesui/dashboard:v2.7.0
[root@k8s-master ~]# 
[root@k8s-master ~]# kubectl apply -f recommended.yaml 
namespace/kubernetes-dashboard created
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/dashboard-metrics-scraper created
[root@k8s-master ~]#  kubectl get pod -n kubernetes-dashboard 
NAME                                         READY   STATUS              RESTARTS   AGE
dashboard-metrics-scraper-7c857855d9-7wrjb   0/1     ContainerCreating   0          6s
kubernetes-dashboard-658b66597c-cpnkx        0/1     ContainerCreating   0          6s
[root@k8s-master ~]#  kubectl get pod -n kubernetes-dashboard  -w
NAME                                         READY   STATUS              RESTARTS   AGE
dashboard-metrics-scraper-7c857855d9-7wrjb   0/1     ContainerCreating   0          8s
kubernetes-dashboard-658b66597c-cpnkx        0/1     ContainerCreating   0          8s
dashboard-metrics-scraper-7c857855d9-7wrjb   1/1     Running             0          22s
^C[root@k8s-master ~]#  kubectl get pod -n kubernetes-dashboard 
NAME                                         READY   STATUS              RESTARTS   AGE
dashboard-metrics-scraper-7c857855d9-7wrjb   1/1     Running             0          67s
kubernetes-dashboard-658b66597c-cpnkx        0/1     ContainerCreating   0          67s
[root@k8s-master ~]#  kubectl get pod -n kubernetes-dashboard  -w
NAME                                         READY   STATUS              RESTARTS   AGE
dashboard-metrics-scraper-7c857855d9-7wrjb   1/1     Running             0          72s
kubernetes-dashboard-658b66597c-cpnkx        0/1     ContainerCreating   0          72s
kubernetes-dashboard-658b66597c-cpnkx        0/1     ErrImagePull        0          102s
kubernetes-dashboard-658b66597c-cpnkx        0/1     ImagePullBackOff    0          115s
kubernetes-dashboard-658b66597c-cpnkx        1/1     Running             0          2m35s
^C[root@k8s-master ~]#  kubectl get pod,svc -n kubernetes-dashboard -o wide
NAME                                             READY   STATUS    RESTARTS   AGE     IP             NODE        NOMINATED NODE   READINESS GATES
pod/dashboard-metrics-scraper-7c857855d9-7wrjb   1/1     Running   0          4m15s   10.244.36.79   k8s-node1   <none>           <none>
pod/kubernetes-dashboard-658b66597c-cpnkx        1/1     Running   0          4m15s   10.244.36.80   k8s-node1   <none>           <none>

NAME                                TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE     SELECTOR
service/dashboard-metrics-scraper   ClusterIP   10.96.4.236    <none>        8000/TCP   4m15s   k8s-app=dashboard-metrics-scraper
service/kubernetes-dashboard        ClusterIP   10.96.230.94   <none>        443/TCP    4m16s   k8s-app=kubernetes-dashboard

 

创建访问账户

[root@k8s-master ~]# vim dashuser.yaml
[root@k8s-master ~]#  kubectl apply -f dashuser.yaml 
serviceaccount/admin-user created
clusterrolebinding.rbac.authorization.k8s.io/admin-user created
[root@k8s-master ~]# kubectl -n kubernetes-dashboard get serviceaccount admin-user -o jsonpath='{.secrets[0].name}'
admin-user-token-9v62h[root@k8s-master ~]# 

[root@k8s-master ~]# kubectl -n kubernetes-dashboard get secret  admin-user-token-9v62h -o jsonpath='{.data.token}' | base64 --decode
eyJhbGciOiJSUzI1NiIsImtpZCI6ImZPazA4TUd5LU1YSnd2c1Y3aHB1d2p4OXVVdFpJT3puVVk2aWJnZk5WancifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLTl2NjJoIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJmY2VmMmFiZi1kNzBmLTRmYjMtOTMwMS0zNGQ0OTRlNmYwYzQiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.AiCClchb1PzyVjM83vvo9bj2Gf7lL-4a5aSLn7agrgH4grVXv7bytP3dsYk8FMOOYJwboildjbNYCpoo8nMQEzV9a2BXIrf01m5W0HP5sonf9WavSfz7U1XEVMsISRJtEwy9lg5zegg9NsLJOrv8w9sOKpzNUmsawvBpfBzUPvCBjeGCB-xzIV09jIn3vr640s_JCFmjLupfF9Xf34bVghMGMkaXt_5yasglLV_LLGflgCY4eUTA-UC45X1uKc1Gp8O4LUzLBoNDrsn_D2AoapX02Juyy8iLcQxbu00jSxBQCZhwaKYSLO2F1oFQCorkbjv534KRZyP01cBqclGzvA[root@k8s-master ~]#  kubectl get svc -n kubernetes-dashboard -o wide
NAME                        TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)         AGE     SELECTOR
dashboard-metrics-scraper   ClusterIP   10.96.4.236    <none>        8000/TCP        8m54s   k8s-app=dashboard-metrics-scraper
kubernetes-dashboard        NodePort    10.96.230.94   <none>        443:30511/TCP   8m55s   k8s-app=kubernetes-dashboard

 

访问

Kubernetes Dashboard 

 

;