|NO.Z.00039|——————————|^^ 部署 ^^|——|KuberNetes&二進位制部署.V17|5臺Server|---------------------------------------|kubernetes元件|dashboard|
阿新 • • 發佈:2022-03-29
[CloudNative:KuberNetes&二進位制部署.V17] [Applications.KuberNetes] [|DevOps|k8s|**5節點**|二進位制1.20|kubernetes元件|dashboard|]
一、部署dashboard
### --- Dashboard概述 ~~~ Dashboard用於展示叢集中的各類資源, ~~~ 同時也可以通過Dashboard實時檢視Pod的日誌和在容器中執行一些命令等。
### --- 安裝指定版本dashboard
~~~ # 切換到dashboard部署目錄下
[root@k8s-master01 ~]# cd /root/k8s-ha-install/dashboard/
~~~ # 部署dashboard [root@k8s-master01 dashboard]# kubectl create -f . ~~~ 注:輸出結果: serviceaccount/admin-user created clusterrolebinding.rbac.authorization.k8s.io/admin-user created 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
二、登入dashboard-UI### --- 檢視dashboard.pod狀態 ~~~ # 檢視dashboard部署執行結果 [root@k8s-master01 dashboard]# kubectl get po -n kubernetes-dashboard NAME READY STATUS RESTARTS AGE dashboard-metrics-scraper-7645f69d8c-7dd2b 1/1 Running 0 2m24s kubernetes-dashboard-78cb679857-mqccg 1/1 Running 0 2m25s
### --- Chrome客戶端配置
~~~ 在谷歌瀏覽器(Chrome)啟動檔案中加入啟動引數,用於解決無法訪問Dashboard的問題:
~~~ --test-type --ignore-certificate-errors
### --- 檢視dashboard.service埠號
~~~ # 更改dashboard的svc為NodePort:
~~~ 注:將ClusterIP更改為NodePort(如果已經為NodePort忽略此步驟):
[root@k8s-master01 dashboard]# kubectl edit svc kubernetes-dashboard -n kubernetes-dashboard
type: NodePort
~~~ # 檢視埠號
[root@k8s-master01 dashboard]# kubectl get svc kubernetes-dashboard -n kubernetes-dashboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes-dashboard NodePort 10.104.232.53 <none> 443:30008/TCP 5m26s
### --- 檢視dashboard-token值
~~~ # 檢視token值
[root@k8s-master01 dashboard]# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
Name: admin-user-token-nh8n7
Namespace: kube-system
Labels: <none>
Annotations: kubernetes.io/service-account.name: admin-user
kubernetes.io/service-account.uid: cc002287-5bd5-4e09-9b87-bfe1ea9d6d1f
Type: kubernetes.io/service-account-token
Data
====
namespace: 11 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6InQ2ci1YY3cwaTZjVlQ2bzhaeTJiaGhMNE1fblFzMExrWDhOd25PZmFMXzAifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLW5oOG43Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJjYzAwMjI4Ny01YmQ1LTRlMDktOWI4Ny1iZmUxZWE5ZDZkMWYiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.AkpCaM-gosJ_v_oZJoym3DcgT4qcSlBEsxDZOpqaRLJrF0LTb6ncEFey5MRMXXTEruCnocssuZtb7nuumw2jMgJtEpUsYhhz52ft7aEji8jKRP5-oFBnjX1h1F-vGNupvXq7hZ8CKaK-rGiI40cp8MQAVC8YLpmfGdCSnxDlxiN2DnsqIa6yN5yY0CC3J5dT_4du9oKezujyOi0L0V6f2jCtoWYFfCyTZNspmdSfthVhQQCX3SmlEoh4-mTulem8Ng0TC5Gj-VjVGCbQnZwwKT9dyuu4j0s9rfOjElMTIgBNkwiQ-T6kZB8u2MNroGV5kJjlfB_4l5atDia0YtmD2Q
ca.crt: 1411 bytes
三、登入dashboard:
### --- 登入dashboard:
~~~ # 將token值輸入到令牌後,單擊登入即可訪問Dashboard
~~~ 根據例項埠號,通過任意安裝了kube-proxy的宿主機或者VIP的IP+埠即可訪問到dashboard:
~~~ 訪問Dashboard:https://192.168.1.11:30008(請更改30008為自己的埠),
~~~ http://192.168.1.20:30008/;若是http會報錯,改為https
~~~ Client sent an HTTP request to an HTTPS server.
~~~ 選擇登入方式為令牌:即token方式
四、部署最新版本的dashboar
### --- 部署最新版本的dashboard
~~~ # dashboard官方GitHub地址:https://github.com/kubernetes/dashboard
~~~ 可以在官方dashboard檢視到最新版dashboard
### --- 安裝最新版本dashboard
[root@k8s-master01 ~]# kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.3/aio/deploy/recommended.yaml
### --- 建立dashboard管理員使用者
~~~ # 建立dashboard管理員使用者配置檔案
[root@k8s-master01 ~]# vim admin.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kube-system
~~~ # 建立dashboard管理員使用者
[root@k8s-master01 ~]# kubectl apply -f admin.yaml -n kube-system
===============================END===============================
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart ——W.S.Landor
來自為知筆記(Wiz)