自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Kubernetes Dashboard 2.10 嘗鮮記

運維 系統(tǒng)運維
它允許用戶管理在群集中運行的應用程序并對其進行故障排除,以及管理群集本身。最近推出了 v2.1.0 版本,這里在 Kubernetes 中部署一下,嘗試看看新版本咋樣。

 

簡介

Kubernetes Dashboard 是 Kubernetes 集群的基于 Web 的通用 UI。它允許用戶管理在群集中運行的應用程序并對其進行故障排除,以及管理群集本身。最近推出了 v2.1.0 版本,這里在 Kubernetes 中部署一下,嘗試看看新版本咋樣。

兼容性

Kubernetes版本 1.17 1.18 1.19 1.20  
兼容性 ? ?  
  •  ✕ 不支持的版本范圍。
  •  ✓ 完全支持的版本范圍。
  •  ? 由于Kubernetes API 版本之間的重大更改,某些功能可能無法在儀表板中正常運行。

部署 Kubernetes Dashboard

注意:如果 "kube-system" 命名空間已經(jīng)存在 Kubernetes-Dashboard 相關(guān)資源,請換成別的 Namespace。

系統(tǒng)環(huán)境

  •  Kubernetes 版本:1.20.1
  •  kubernetes-dashboard 版本:v2.1.0

部署文件

完整部署文件 Github 地址:https://github.com/my-dlq/blog-example/tree/master/kubernetes/kubernetes-dashboard2.1.0-deploy

1、Dashboard RBAC

創(chuàng)建 Dashboard RBAC 部署文件

k8s-dashboard-rbac.yaml 

  1. apiVersion: v1  
  2. kind: ServiceAccount  
  3. metadata:  
  4.   labels:  
  5.     k8s-app: kubernetes-dashboard  
  6.   name: kubernetes-dashboard  
  7.   namespace: kube-system  
  8. ---  
  9. apiVersion: rbac.authorization.k8s.io/v1  
  10. kind: Role  
  11. metadata:  
  12.   labels:  
  13.     k8s-app: kubernetes-dashboard  
  14.   name: kubernetes-dashboard  
  15.   namespace: kube-system  
  16. rules:  
  17.   - apiGroups: [""]  
  18.     resources: ["secrets"]  
  19.     resourceNames: ["kubernetes-dashboard-key-holder", "kubernetes-dashboard-certs", "kubernetes-dashboard-csrf"]  
  20.     verbs: ["get", "update", "delete"]  
  21.   - apiGroups: [""]  
  22.     resources: ["configmaps"]  
  23.     resourceNames: ["kubernetes-dashboard-settings"]  
  24.     verbs: ["get", "update"] 
  25.    - apiGroups: [""]  
  26.     resources: ["services"]  
  27.     resourceNames: ["heapster", "dashboard-metrics-scraper"]  
  28.     verbs: ["proxy"]  
  29.   - apiGroups: [""]  
  30.     resources: ["services/proxy"]  
  31.     resourceNames: ["heapster", "http:heapster:", "https:heapster:", "dashboard-metrics-scraper", "http:dashboard-metrics-scraper"]  
  32.     verbs: ["get"]  
  33. ---  
  34. apiVersion: rbac.authorization.k8s.io/v1  
  35. kind: ClusterRole  
  36. metadata:  
  37.   labels:  
  38.     k8s-app: kubernetes-dashboard  
  39.   name: kubernetes-dashboard  
  40. rules:  
  41.   - apiGroups: ["metrics.k8s.io"]  
  42.     resources: ["pods", "nodes"]  
  43.     verbs: ["get", "list", "watch"] 
  44.  ---  
  45. apiVersion: rbac.authorization.k8s.io/v1  
  46. kind: RoleBinding  
  47. metadata:  
  48.   labels:  
  49.     k8s-app: kubernetes-dashboard  
  50.   name: kubernetes-dashboard  
  51.   namespace: kube-system  
  52. roleRef:  
  53.   apiGroup: rbac.authorization.k8s.io  
  54.   kind: Role  
  55.   name: kubernetes-dashboard  
  56. subjects:  
  57.   - kind: ServiceAccount  
  58.     name: kubernetes-dashboard  
  59.     namespace: kube-system  
  60. ---  
  61. apiVersion: rbac.authorization.k8s.io/v1  
  62. kind: ClusterRoleBinding  
  63. metadata:  
  64.   name: kubernetes-dashboard  
  65.   namespace: kube-system  
  66. roleRef:  
  67.   apiGroup: rbac.authorization.k8s.io  
  68.   kind: ClusterRole  
  69.   name: kubernetes-dashboard  
  70. subjects:  
  71.   - kind: ServiceAccount  
  72.     name: kubernetes-dashboard  
  73.     namespace: kube-system 

部署 Dashboard RBAC 

  1. $ kubectl apply -f k8s-dashboard-rbac.yaml 

2、創(chuàng)建 ConfigMap、Secret

創(chuàng)建 Dashboard Config & Secret 部署文件

k8s-dashboard-configmap-secret.yaml 

  1. apiVersion: v1  
  2. kind: Secret  
  3. metadata:  
  4.   labels:  
  5.     k8s-app: kubernetes-dashboard  
  6.   name: kubernetes-dashboard-certs  
  7.   namespace: kube-system  
  8. type: Opaque  
  9. ---  
  10. apiVersion: v1  
  11. kind: Secret  
  12. metadata: 
  13.    labels:  
  14.     k8s-app: kubernetes-dashboard  
  15.   name: kubernetes-dashboard-csrf  
  16.   namespace: kube-system  
  17. type: Opaque  
  18. data:  
  19.   csrf: ""  
  20. ---  
  21. apiVersion: v1  
  22. kind: Secret  
  23. metadata:  
  24.   labels: 
  25.      k8s-app: kubernetes-dashboard  
  26.   name: kubernetes-dashboard-key-holder  
  27.   namespace: kube-system  
  28. type: Opaque  
  29. ---  
  30. kind: ConfigMap  
  31. apiVersion: v1  
  32. metadata:  
  33.   labels:  
  34.     k8s-app: kubernetes-dashboard  
  35.   name: kubernetes-dashboard-settings  
  36.   namespace: kube-system 

部署 Dashboard Config & Secret 

  1. $ kubectl apply -f k8s-dashboard-configmap-secret.yaml 

3、kubernetes-dashboard

創(chuàng)建 Dashboard Deploy 部署文件

k8s-dashboard-deploy.yaml 

  1. ## Dashboard Service  
  2. kind: Service  
  3. apiVersion: v1  
  4. metadata:  
  5.   labels:  
  6.     k8s-app: kubernetes-dashboard  
  7.   name: kubernetes-dashboard  
  8.   namespace: kube-system  
  9. spec:  
  10.   type: NodePort  
  11.   ports:  
  12.     - port: 443  
  13.       nodePort: 30001  
  14.       targetPort: 8443  
  15.   selector:  
  16.     k8s-app: kubernetes-dashboard  
  17. ---  
  18. ## Dashboard Deployment  
  19. kind: Deployment  
  20. apiVersion: apps/v1  
  21. metadata:  
  22.   labels:  
  23.     k8s-app: kubernetes-dashboard  
  24.   name: kubernetes-dashboard  
  25.   namespace: kube-system  
  26. spec:  
  27.   replicas: 1  
  28.   revisionHistoryLimit: 10  
  29.   selector:  
  30.     matchLabels:  
  31.       k8s-app: kubernetes-dashboard  
  32.   template:  
  33.     metadata:  
  34.       labels:  
  35.         k8s-app: kubernetes-dashboard  
  36.     spec:  
  37.       serviceAccountName: kubernetes-dashboard  
  38.       containers:  
  39.         - name: kubernetes-dashboard  
  40.           image: kubernetesui/dashboard:v2.1.0  
  41.           securityContext:  
  42.             allowPrivilegeEscalation: false  
  43.             readOnlyRootFilesystem: true  
  44.             runAsUser: 1001  
  45.             runAsGroup: 2001  
  46.           ports:  
  47.             - containerPort: 8443  
  48.               protocol: TCP  
  49.           args:  
  50.             - --auto-generate-certificates  
  51.             - --namespace=kube-system          #設置為當前部署的Namespace  
  52.           resources:  
  53.             limits:  
  54.               cpu: 1000m  
  55.               memory: 512Mi  
  56.             requests:  
  57.               cpu: 1000m  
  58.               memory: 512Mi  
  59.           livenessProbe:  
  60.             httpGet:  
  61.               scheme: HTTPS  
  62.               path: /  
  63.               port: 8443  
  64.             initialDelaySeconds: 30  
  65.             timeoutSeconds: 30  
  66.           volumeMounts:  
  67.             - name: kubernetes-dashboard-certs  
  68.               mountPath: /certs  
  69.             - name: tmp-volume  
  70.               mountPath: /tmp  
  71.             - name: localtime 
  72.                readOnly: true  
  73.               mountPath: /etc/localtime  
  74.       volumes:  
  75.         - name: kubernetes-dashboard-certs  
  76.           secret:  
  77.             secretName: kubernetes-dashboard-certs  
  78.         - name: tmp-volume  
  79.           emptyDir: {}  
  80.         - name: localtime  
  81.           hostPath:  
  82.             type: File  
  83.             path: /etc/localtime  
  84.       tolerations:  
  85.         - key: node-role.kubernetes.io/master  
  86.           effect: NoSchedule 

部署 Dashboard Deploy 

  1. $ kubectl apply -f k8s-dashboard-deploy.yaml 

4、創(chuàng)建 kubernetes-metrics-scraper

創(chuàng)建 Dashboard Metrics 部署文件

k8s-dashboard-metrics.yaml 

  1. ## Dashboard Metrics Service  
  2. kind: Service  
  3. apiVersion: v1  
  4. metadata:  
  5.   labels:  
  6.     k8s-app: dashboard-metrics-scraper  
  7.   name: dashboard-metrics-scraper  
  8.   namespace: kube-system  
  9. spec:  
  10.   ports:  
  11.     - port: 8000 
  12.        targetPort: 8000  
  13.   selector:  
  14.     k8s-app: dashboard-metrics-scraper  
  15. ---  
  16. ## Dashboard Metrics Deployment  
  17. kind: Deployment  
  18. apiVersion: apps/v1  
  19. metadata:  
  20.   labels:  
  21.     k8s-app: dashboard-metrics-scraper  
  22.   name: dashboard-metrics-scraper 
  23.    namespace: kube-system  
  24. spec:  
  25.   replicas: 1  
  26.   revisionHistoryLimit: 10  
  27.   selector:  
  28.     matchLabels:  
  29.       k8s-app: dashboard-metrics-scraper  
  30.   template:  
  31.     metadata:  
  32.       labels:  
  33.         k8s-app: dashboard-metrics-scraper  
  34.       annotations:  
  35.         seccomp.security.alpha.kubernetes.io/pod: 'runtime/default'  
  36.     spec:  
  37.       serviceAccountName: kubernetes-dashboard  
  38.       containers:  
  39.         - name: dashboard-metrics-scraper  
  40.           image: kubernetesui/metrics-scraper:v1.0.6  
  41.           securityContext:  
  42.             allowPrivilegeEscalation: false  
  43.             readOnlyRootFilesystem: true  
  44.             runAsUser: 1001  
  45.             runAsGroup: 2001  
  46.           ports:  
  47.             - containerPort: 8000  
  48.               protocol: TCP  
  49.           resources:  
  50.             limits:  
  51.               cpu: 1000m  
  52.               memory: 512Mi  
  53.             requests:  
  54.               cpu: 1000m  
  55.               memory: 512Mi  
  56.           livenessProbe:  
  57.             httpGet:  
  58.               scheme: HTTP  
  59.               path: /  
  60.               port: 8000  
  61.             initialDelaySeconds: 30  
  62.             timeoutSeconds: 30  
  63.           volumeMounts:  
  64.           - mountPath: /tmp  
  65.             name: tmp-volume  
  66.           - name: localtime  
  67.             readOnly: true  
  68.             mountPath: /etc/localtime  
  69.       volumes:  
  70.         - name: tmp-volume  
  71.           emptyDir: {}  
  72.         - name: localtime  
  73.           hostPath:  
  74.             type: File  
  75.             path: /etc/localtime  
  76.       nodeSelector:  
  77.         "beta.kubernetes.io/os": linux  
  78.       tolerations:  
  79.         - key: node-role.kubernetes.io/master  
  80.           effect: NoSchedule 

部署 Dashboard Metrics 

  1. $ kubectl apply -f k8s-dashboard-metrics.yaml 

5、創(chuàng)建訪問的 ServiceAccount

創(chuàng)建一個綁定 admin 權(quán)限的 ServiceAccount,獲取其 Token 用于訪問看板。

創(chuàng)建 Dashboard ServiceAccount 部署文件

k8s-dashboard-token.yaml 

  1. kind: ClusterRoleBinding  
  2. apiVersion: rbac.authorization.k8s.io/v1  
  3. metadata:  
  4.   name: admin  
  5.   annotations:  
  6.     rbac.authorization.kubernetes.io/autoupdate: "true"  
  7. roleRef:  
  8.   kind: ClusterRole  
  9.   name: cluster-admin  
  10.   apiGroup: rbac.authorization.k8s.io  
  11. subjects:  
  12. - kind: ServiceAccount  
  13.   name: admin  
  14.   namespace: kube-system  
  15. ---  
  16. apiVersion: v1  
  17. kind: ServiceAccount  
  18. metadata:  
  19.   name: admin  
  20.   namespace: kube-system  
  21.   labels:  
  22.     kubernetes.io/cluster-service: "true"  
  23.     addonmanager.kubernetes.io/mode: Reconcile 

部署訪問的 ServiceAccount 

  1. $ kubectl apply -f k8s-dashboard-token.yaml 

獲取 Token 

  1. $ kubectl describe secret/$(kubectl get secret -n kube-system |grep admin|awk '{print $1}') -n kube-system 

token:

登錄新版本 Dashboard 查看

本人的 Kubernetes 集群地址為”192.168.2.11”并且在 Service 中設置了 NodePort 端口為 30001 和類型為 NodePort 方式訪問 Dashboard ,所以訪問地址:https://192.168.2.11:30001 進入 Kubernetes Dashboard 頁面,然后輸入上一步中創(chuàng)建的 ServiceAccount 的 Token 進入 Dashboard,可以看到新的 Dashboard。

跟上一個版本比較,整體資源的顯示位置,增加對 1.20 版本的支持等:

部署 Metrics Server 為 Dashboard 提供指標數(shù)據(jù)

Dashboard 已經(jīng)部署完成,不過登錄 Dashboard 后可以看到:

這些欄數(shù)據(jù)顯示都是空,這是由于 Dashboard 的指標部署需要從 Metrics Server 中獲取,Dashboard 該版本另一個組件 kubernetes-metrics-scraper 就是用于從 Metrics Server 獲取指標的適配器。之前我們已經(jīng)部署 kubernetes-metrics-scraper 組件,接下來只要再部署 Metrics Server 組件就能獲取系統(tǒng)指標數(shù)據(jù),供 Dashboard 繪制圖形,部署 Metrics Server 可以參考:

  •  Kubernetes 部署 Metrics Server 獲取集群指標數(shù)據(jù)

當按照上面部署完成后,等一段時間,再刷新 Dashboard 界面,可以觀察到如下界面:

 

 

責任編輯:龐桂玉 來源: 奇妙的Linux世界
相關(guān)推薦

2020-09-15 08:46:26

Kubernetes探針服務端

2021-11-11 16:14:04

Kubernetes

2021-03-29 12:35:04

Kubernetes環(huán)境TCP

2013-10-28 16:00:48

二十八畝地輕應用App Builder

2021-05-20 12:01:59

Kubernetes 密碼認證Linux

2021-06-22 06:24:57

Linkerd Ingress 流量網(wǎng)絡技術(shù)

2021-05-26 11:06:06

Kubernetes網(wǎng)絡故障集群節(jié)點

2021-06-29 13:09:07

服務配置文件

2022-01-18 09:35:36

GNOME編輯器Linux

2012-12-03 10:26:51

Scala

2011-03-23 11:19:37

2014-07-23 09:55:39

NginxLibreSSL

2021-06-16 17:42:48

Linkerd 配置CPU

2021-06-22 06:41:38

Linkerd 安裝多集群組件網(wǎng)絡技術(shù)

2021-06-28 11:00:48

QEMUWindows 11Windows

2021-06-22 06:16:24

Linkerd books webapp

2022-02-17 11:19:33

Kubernetes服務器運維

2023-03-16 08:01:43

CephWeb

2021-06-17 06:13:29

Linkerd Prometheus 網(wǎng)絡技術(shù)

2018-03-26 20:49:08

圖像分類
點贊
收藏

51CTO技術(shù)棧公眾號