Kubernetes可视WEBUI Dashboard搭建

快速查找登录密码token:

kubectl get secret  -n kube-system

kubectl get secret  -n kube-system | grep dashboard-token

kubectl -n kube-system describe secret dashboard-token-cg57k


支持浏览器:火狐

一.Dashboard下载地址

git clone https://github.com/kubernetes/kubernetes/

二.部署Dashboard需要文件

[root@k8s_master ui]# ll

总用量 28

-rwxr-xr-x 1 root root  833 3月  20 19:13 dashboard-cert.sh

-rwxr-xr-x 1 root root  264 3月  20 19:13 dashboard-configmap.yaml

-rwxr-xr-x 1 root root 1819 3月  20 19:13 dashboard-controller.yaml

-rwxr-xr-x 1 root root 1353 3月  20 19:13 dashboard-rbac.yaml

-rwxr-xr-x 1 root root  551 3月  20 19:13 dashboard-secret.yaml

-rwxr-xr-x 1 root root  359 3月  20 19:13 dashboard-service.yaml

三.部署Dashboard

1. rbac部署(授权k8s可以访问apiserver)

kubectl apply -f dashboard-rbac.yaml

2. secret部署

kubectl apply -f dashboard-secret.yaml

3. configmap部署

kubectl apply -f dashboard-configmap.yaml

4. controller部署

node节点上下载镜像并打标签:

docker pull mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.8.3

docker tag mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.8.3  gcr.io/google_containers/kubernetes-dashboard-amd64:v1.8.3

需要修改镜像地址:image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.8.3

kubectl apply -f dashboard-controller.yaml
kubectl get pods -n kube-system

      NAME                                    READY   STATUS    RESTARTS   AGE

      kubernetes-dashboard-785f8ff65c-r52pz       1/1     Running    0          2m31s

 

5. service部署(暴露端口30001)

 kubectl apply -f dashboard-service.yaml
kubectl get svc,pods -n kube-system

NAME                           TYPE       CLUSTER-IP   EXTERNAL-IP   PORT(S)         AGE

service/kubernetes-dashboard   NodePort   10.0.0.254   <none>        443:30001/TCP   2m3s

 

NAME                                        READY   STATUS    RESTARTS   AGE

pod/kubernetes-dashboard-785f8ff65c-r52pz   1/1     Running   0          3m56s

6. 创建账号(k8s-admin)

kubectl apply -f k8s-admin.yaml
kubectl get secret -n kube-system

      NAME                               TYPE                                  DATA   AGE

      dashboard-admin-token-xs5xf        kubernetes.io/service-account-token   3      43s

kubectl describe secret dashboard-admin-token-xs5xf -n kube-system

token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4teHM1eGYiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiZDQzNzQxNTEtNGIwNC0xMWU5LWEwMGMtMDgwMDI3M2VhZDE5Iiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.AL7VyiDHtUoseE6juK_m4OmUeUCGm8xZ497Ab0LY5QGEWa_PTGS044r81h_XKbvpKHgjdMTgPyh4jhBlBSf_LwQvrjhT537F4OjZTfbp1CRxRd9Np4RFOPkgDy7KeWpaYhGfickpwaOLl8PpSKxuHZEkeIVBiRElx-0G-xB4KV8fm34UUXOhx4SxcAIaVliiSSJemg-v2VDqnRNdnlSlyO9kJxV-MpExnIcu4WZsCJ-dHhlkUSukMC3_yV6Etz1RURUTtGiFvqnxF5rTJAT--e8UrxXSFZLrKYCBTxaH4QcwlqhlsMbmNa5PdEMhU3JdhjmDcnfoaYPzJ2T223Xatg   

     

7. 登录dashboard

[root@k8s_master Dashboard]#  kubectl get svc,pods -n kube-system
NAME                           TYPE       CLUSTER-IP   EXTERNAL-IP   PORT(S)         AGE
service/kubernetes-dashboard   NodePort   10.0.0.26    <none>        443:30001/TCP   6s



[root@k8s_master Dashboard]# kubectl get pod -o wide -n kube-system
NAME                                    READY   STATUS    RESTARTS   AGE   IP            NODE             NOMINATED NODE   READINESS GATES
kubernetes-dashboard-6c9b7b8f6c-bdjnz   1/1     Running   0          98s   172.17.37.2   192.168.22.142   <none>           <none>
[root@k8s_master Dashboard]# 

https://192.168.22.142:30001/#!/login

 

令牌:上面生成的token

 

Logo

开源、云原生的融合云平台

更多推荐