国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

Longhorn,企業(yè)級云原生容器分布式存儲之監控

發(fā)布時(shí)間:2021-11-03 13:46 來(lái)源:黑客下午茶 閱讀:0 作者:為少 欄目: 云計算 歡迎投稿:712375056

本文檔提供了一個(gè)監控 Longhorn 的示例設置。監控系統使用 Prometheus 收集數據和警報,使用 Grafana 將收集的數據可視化/儀表板(visualizing/dashboarding)。

目錄

  • 設置 Prometheus 和 Grafana 來(lái)監控 Longhorn
  • 將 Longhorn 指標集成到 Rancher 監控系統中
  • Longhorn 監控指標
  • 支持 Kubelet Volume 指標
  • Longhorn 警報規則示例

設置 Prometheus 和 Grafana 來(lái)監控 Longhorn

概覽

Longhorn 在 REST 端點(diǎn) http://LONGHORN_MANAGER_IP:PORT/metrics 上以 Prometheus 文本格式原生公開(kāi)指標。有關(guān)所有可用指標的說(shuō)明,請參閱 Longhorn's metrics。您可以使用 Prometheus, Graphite, Telegraf 等任何收集工具來(lái)抓取這些指標,然后通過(guò) Grafana 等工具將收集到的數據可視化。

本文檔提供了一個(gè)監控 Longhorn 的示例設置。監控系統使用 Prometheus 收集數據和警報,使用 Grafana 將收集的數據可視化/儀表板(visualizing/dashboarding)。高級概述來(lái)看,監控系統包含:

  • Prometheus 服務(wù)器從 Longhorn 指標端點(diǎn)抓取和存儲時(shí)間序列數據。Prometheus 還負責根據配置的規則和收集的數據生成警報。Prometheus 服務(wù)器然后將警報發(fā)送到 Alertmanager。
  • AlertManager 然后管理這些警報(alerts),包括靜默(silencing)、抑制(inhibition)、聚合(aggregation)和通過(guò)電子郵件、呼叫通知系統和聊天平臺等方法發(fā)送通知。
  • Grafana 向 Prometheus 服務(wù)器查詢(xún)數據并繪制儀表板進(jìn)行可視化。

下圖描述了監控系統的詳細架構。

上圖中有 2 個(gè)未提及的組件:

  • Longhorn 后端服務(wù)是指向 Longhorn manager pods 集的服務(wù)。Longhorn 的指標在端點(diǎn) http://LONGHORN_MANAGER_IP:PORT/metrics 的 Longhorn manager pods 中公開(kāi)。
  • Prometheus operator 使在 Kubernetes 上運行 Prometheus 變得非常容易。operator 監視 3 個(gè)自定義資源:ServiceMonitor、Prometheus 和 AlertManager。當用戶(hù)創(chuàng )建這些自定義資源時(shí),Prometheus Operator 會(huì )使用用戶(hù)指定的配置部署和管理 Prometheus server, AlerManager。

安裝

按照此說(shuō)明將所有組件安裝到 monitoring 命名空間中。要將它們安裝到不同的命名空間中,請更改字段 namespace: OTHER_NAMESPACE

創(chuàng )建 monitoring 命名空間

  1. apiVersion: v1 
  2. kind: Namespace 
  3. metadata: 
  4.   name: monitoring 

安裝 Prometheus Operator

部署 Prometheus Operator 及其所需的 ClusterRole、ClusterRoleBinding 和 Service Account。

  1. apiVersion: rbac.authorization.k8s.io/v1 
  2. kind: ClusterRoleBinding 
  3. metadata: 
  4.   labels: 
  5.     app.kubernetes.io/component: controller 
  6.     app.kubernetes.io/name: prometheus-operator 
  7.     app.kubernetes.io/version: v0.38.3 
  8.   name: prometheus-operator 
  9.   namespace: monitoring 
  10. roleRef: 
  11.   apiGroup: rbac.authorization.k8s.io 
  12.   kind: ClusterRole 
  13.   name: prometheus-operator 
  14. subjects: 
  15. - kind: ServiceAccount 
  16.   name: prometheus-operator 
  17.   namespace: monitoring 
  18. --- 
  19. apiVersion: rbac.authorization.k8s.io/v1 
  20. kind: ClusterRole 
  21. metadata: 
  22.   labels: 
  23.     app.kubernetes.io/component: controller 
  24.     app.kubernetes.io/name: prometheus-operator 
  25.     app.kubernetes.io/version: v0.38.3 
  26.   name: prometheus-operator 
  27.   namespace: monitoring 
  28. rules: 
  29. - apiGroups: 
  30.   - apiextensions.k8s.io 
  31.   resources: 
  32.   - customresourcedefinitions 
  33.   verbs: 
  34.   - create 
  35. - apiGroups: 
  36.   - apiextensions.k8s.io 
  37.   resourceNames: 
  38.   - alertmanagers.monitoring.coreos.com 
  39.   - podmonitors.monitoring.coreos.com 
  40.   - prometheuses.monitoring.coreos.com 
  41.   - prometheusrules.monitoring.coreos.com 
  42.   - servicemonitors.monitoring.coreos.com 
  43.   - thanosrulers.monitoring.coreos.com 
  44.   resources: 
  45.   - customresourcedefinitions 
  46.   verbs: 
  47.   - get 
  48.   - update 
  49. - apiGroups: 
  50.   - monitoring.coreos.com 
  51.   resources: 
  52.   - alertmanagers 
  53.   - alertmanagers/finalizers 
  54.   - prometheuses 
  55.   - prometheuses/finalizers 
  56.   - thanosrulers 
  57.   - thanosrulers/finalizers 
  58.   - servicemonitors 
  59.   - podmonitors 
  60.   - prometheusrules 
  61.   verbs: 
  62.   - '*' 
  63. - apiGroups: 
  64.   - apps 
  65.   resources: 
  66.   - statefulsets 
  67.   verbs: 
  68.   - '*' 
  69. - apiGroups: 
  70.   - "" 
  71.   resources: 
  72.   - configmaps 
  73.   - secrets 
  74.   verbs: 
  75.   - '*' 
  76. - apiGroups: 
  77.   - "" 
  78.   resources: 
  79.   - pods 
  80.   verbs: 
  81.   - list 
  82.   - delete 
  83. - apiGroups: 
  84.   - "" 
  85.   resources: 
  86.   - services 
  87.   - services/finalizers 
  88.   - endpoints 
  89.   verbs: 
  90.   - get 
  91.   - create 
  92.   - update 
  93.   - delete 
  94. - apiGroups: 
  95.   - "" 
  96.   resources: 
  97.   - nodes 
  98.   verbs: 
  99.   - list 
  100.   - watch 
  101. - apiGroups: 
  102.   - "" 
  103.   resources: 
  104.   - namespaces 
  105.   verbs: 
  106.   - get 
  107.   - list 
  108.   - watch 
  109. --- 
  110. apiVersion: apps/v1 
  111. kind: Deployment 
  112. metadata: 
  113.   labels: 
  114.     app.kubernetes.io/component: controller 
  115.     app.kubernetes.io/name: prometheus-operator 
  116.     app.kubernetes.io/version: v0.38.3 
  117.   name: prometheus-operator 
  118.   namespace: monitoring 
  119. spec: 
  120.   replicas: 1 
  121.   selector: 
  122.     matchLabels: 
  123.       app.kubernetes.io/component: controller 
  124.       app.kubernetes.io/name: prometheus-operator 
  125.   template: 
  126.     metadata: 
  127.       labels: 
  128.         app.kubernetes.io/component: controller 
  129.         app.kubernetes.io/name: prometheus-operator 
  130.         app.kubernetes.io/version: v0.38.3 
  131.     spec: 
  132.       containers: 
  133.       - args: 
  134.         - --kubelet-service=kube-system/kubelet 
  135.         - --logtostderr=true 
  136.         - --config-reloader-image=jimmidyson/configmap-reload:v0.3.0 
  137.         - --prometheus-config-reloader=quay.io/prometheus-operator/prometheus-config-reloader:v0.38.3 
  138.         image: quay.io/prometheus-operator/prometheus-operator:v0.38.3 
  139.         name: prometheus-operator 
  140.         ports: 
  141.         - containerPort: 8080 
  142.           name: http 
  143.         resources: 
  144.           limits: 
  145.             cpu: 200m 
  146.             memory: 200Mi 
  147.           requests: 
  148.             cpu: 100m 
  149.             memory: 100Mi 
  150.         securityContext: 
  151.           allowPrivilegeEscalation: false 
  152.       nodeSelector: 
  153.         beta.kubernetes.io/os: linux 
  154.       securityContext: 
  155.         runAsNonRoot: true 
  156.         runAsUser: 65534 
  157.       serviceAccountName: prometheus-operator 
  158. --- 
  159. apiVersion: v1 
  160. kind: ServiceAccount 
  161. metadata: 
  162.   labels: 
  163.     app.kubernetes.io/component: controller 
  164.     app.kubernetes.io/name: prometheus-operator 
  165.     app.kubernetes.io/version: v0.38.3 
  166.   name: prometheus-operator 
  167.   namespace: monitoring 
  168. --- 
  169. apiVersion: v1 
  170. kind: Service 
  171. metadata: 
  172.   labels: 
  173.     app.kubernetes.io/component: controller 
  174.     app.kubernetes.io/name: prometheus-operator 
  175.     app.kubernetes.io/version: v0.38.3 
  176.   name: prometheus-operator 
  177.   namespace: monitoring 
  178. spec: 
  179.   clusterIP: None 
  180.   ports: 
  181.   - name: http 
  182.     port: 8080 
  183.     targetPort: http 
  184.   selector: 
  185.     app.kubernetes.io/component: controller 
  186.     app.kubernetes.io/name: prometheus-operator 

安裝 Longhorn ServiceMonitor

Longhorn ServiceMonitor 有一個(gè)標簽選擇器 app: longhorn-manager 來(lái)選擇 Longhorn 后端服務(wù)。稍后,Prometheus CRD 可以包含 Longhorn ServiceMonitor,以便 Prometheus server 可以發(fā)現所有 Longhorn manager pods 及其端點(diǎn)。

  1. apiVersion: monitoring.coreos.com/v1 
  2. kind: ServiceMonitor 
  3. metadata: 
  4.   name: longhorn-prometheus-servicemonitor 
  5.   namespace: monitoring 
  6.   labels: 
  7.     name: longhorn-prometheus-servicemonitor 
  8. spec: 
  9.   selector: 
  10.     matchLabels: 
  11.       app: longhorn-manager 
  12.   namespaceSelector: 
  13.     matchNames: 
  14.     - longhorn-system 
  15.   endpoints: 
  16.   - port: manager 

安裝和配置 Prometheus AlertManager

使用 3 個(gè)實(shí)例創(chuàng )建一個(gè)高可用的 Alertmanager 部署:

  1. apiVersion: monitoring.coreos.com/v1 
  2. kind: Alertmanager 
  3. metadata: 
  4.   name: longhorn 
  5.   namespace: monitoring 
  6. spec: 
  7.   replicas: 3 

除非提供有效配置,否則 Alertmanager 實(shí)例將無(wú)法啟動(dòng)。有關(guān) Alertmanager 配置的更多說(shuō)明,請參見(jiàn)此處。下面的代碼給出了一個(gè)示例配置:

  1. global
  2.   resolve_timeout: 5m 
  3. route: 
  4.   group_by: [alertname] 
  5.   receiver: email_and_slack 
  6. receivers: 
  7. name: email_and_slack 
  8.   email_configs: 
  9.   - to: <the email address to send notifications to
  10.     from: <the sender address> 
  11.     smarthost: <the SMTP host through which emails are sent> 
  12.     # SMTP authentication information. 
  13.     auth_username: <the username> 
  14.     auth_identity: <the identity> 
  15.     auth_password: <the password
  16.     headers: 
  17.       subject: 'Longhorn-Alert' 
  18.     text: |- 
  19.       {{ range .Alerts }} 
  20.         *Alert:* {{ .Annotations.summary }} - `{{ .Labels.severity }}` 
  21.         *Description:* {{ .Annotations.description }} 
  22.         *Details:* 
  23.         {{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}` 
  24.         {{ end }} 
  25.       {{ end }} 
  26.   slack_configs: 
  27.   - api_url: <the Slack webhook URL> 
  28.     channel: <the channel or user to send notifications to
  29.     text: |- 
  30.       {{ range .Alerts }} 
  31.         *Alert:* {{ .Annotations.summary }} - `{{ .Labels.severity }}` 
  32.         *Description:* {{ .Annotations.description }} 
  33.         *Details:* 
  34.         {{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}` 
  35.         {{ end }} 
  36.       {{ end }} 

將上述 Alertmanager 配置保存在名為 alertmanager.yaml 的文件中,并使用 kubectl 從中創(chuàng )建一個(gè) secret。

Alertmanager 實(shí)例要求 secret 資源命名遵循 alertmanager-{ALERTMANAGER_NAME} 格式。在上一步中,Alertmanager 的名稱(chēng)是 longhorn,所以 secret 名稱(chēng)必須是 alertmanager-longhorn

  1. $ kubectl create secret generic alertmanager-longhorn --from-file=alertmanager.yaml -n monitoring 

為了能夠查看 Alertmanager 的 Web UI,請通過(guò) Service 公開(kāi)它。一個(gè)簡(jiǎn)單的方法是使用 NodePort 類(lèi)型的 Service :

  1. apiVersion: v1 
  2. kind: Service 
  3. metadata: 
  4.   name: alertmanager-longhorn 
  5.   namespace: monitoring 
  6. spec: 
  7.   type: NodePort 
  8.   ports: 
  9.   - name: web 
  10.     nodePort: 30903 
  11.     port: 9093 
  12.     protocol: TCP 
  13.     targetPort: web 
  14.   selector: 
  15.     alertmanager: longhorn 

創(chuàng )建上述服務(wù)后,您可以通過(guò)節點(diǎn)的 IP 和端口 30903 訪(fǎng)問(wèn) Alertmanager 的 web UI。

使用上面的 NodePort 服務(wù)進(jìn)行快速驗證,因為它不通過(guò) TLS 連接進(jìn)行通信。您可能希望將服務(wù)類(lèi)型更改為 ClusterIP,并設置一個(gè) Ingress-controller 以通過(guò) TLS 連接公開(kāi) Alertmanager 的 web UI。

安裝和配置 Prometheus server

創(chuàng )建定義警報條件的 PrometheusRule 自定義資源。

  1. apiVersion: monitoring.coreos.com/v1 
  2. kind: PrometheusRule 
  3. metadata: 
  4.   labels: 
  5.     prometheus: longhorn 
  6.     role: alert-rules 
  7.   name: prometheus-longhorn-rules 
  8.   namespace: monitoring 
  9. spec: 
  10.   groups: 
  11.   - name: longhorn.rules 
  12.     rules: 
  13.     - alert: LonghornVolumeUsageCritical 
  14.       annotations: 
  15.         description: Longhorn volume {{$labels.volume}} on {{$labels.node}} is at {{$value}}% used for 
  16.           more than 5 minutes. 
  17.         summary: Longhorn volume capacity is over 90% used. 
  18.       expr: 100 * (longhorn_volume_usage_bytes / longhorn_volume_capacity_bytes) > 90 
  19.       for: 5m 
  20.       labels: 
  21.         issue: Longhorn volume {{$labels.volume}} usage on {{$labels.node}} is critical. 
  22.         severity: critical 

有關(guān)如何定義警報規則的更多信息,請參見(jiàn)https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/#alerting-rules

如果激活了 RBAC 授權,則為 Prometheus Pod 創(chuàng )建 ClusterRole 和 ClusterRoleBinding:

  1. apiVersion: v1 
  2. kind: ServiceAccount 
  3. metadata: 
  4.   name: prometheus 
  5.   namespace: monitoring 
  6. apiVersion: rbac.authorization.k8s.io/v1beta1 
  7. kind: ClusterRole 
  8. metadata: 
  9.   name: prometheus 
  10.   namespace: monitoring 
  11. rules: 
  12. - apiGroups: [""
  13.   resources: 
  14.   - nodes 
  15.   - services 
  16.   - endpoints 
  17.   - pods 
  18.   verbs: ["get""list""watch"
  19. - apiGroups: [""
  20.   resources: 
  21.   - configmaps 
  22.   verbs: ["get"
  23. - nonResourceURLs: ["/metrics"
  24.   verbs: ["get"
  25. apiVersion: rbac.authorization.k8s.io/v1beta1 
  26. kind: ClusterRoleBinding 
  27. metadata: 
  28.   name: prometheus 
  29. roleRef: 
  30.   apiGroup: rbac.authorization.k8s.io 
  31.   kind: ClusterRole 
  32.   name: prometheus 
  33. subjects: 
  34. - kind: ServiceAccount 
  35.   name: prometheus 
  36.   namespace: monitoring 

創(chuàng )建 Prometheus 自定義資源。請注意,我們在 spec 中選擇了 Longhorn 服務(wù)監視器(service monitor)和 Longhorn 規則。

  1. apiVersion: monitoring.coreos.com/v1 
  2. kind: Prometheus 
  3. metadata: 
  4.   name: prometheus 
  5.   namespace: monitoring 
  6. spec: 
  7.   replicas: 2 
  8.   serviceAccountName: prometheus 
  9.   alerting: 
  10.     alertmanagers: 
  11.       - namespace: monitoring 
  12.         name: alertmanager-longhorn 
  13.         port: web 
  14.   serviceMonitorSelector: 
  15.     matchLabels: 
  16.       name: longhorn-prometheus-servicemonitor 
  17.   ruleSelector: 
  18.     matchLabels: 
  19.       prometheus: longhorn 
  20.       role: alert-rules 

為了能夠查看 Prometheus 服務(wù)器的 web UI,請通過(guò) Service 公開(kāi)它。一個(gè)簡(jiǎn)單的方法是使用 NodePort 類(lèi)型的 Service:

  1. apiVersion: v1 
  2. kind: Service 
  3. metadata: 
  4.   name: prometheus 
  5.   namespace: monitoring 
  6. spec: 
  7.   type: NodePort 
  8.   ports: 
  9.   - name: web 
  10.     nodePort: 30904 
  11.     port: 9090 
  12.     protocol: TCP 
  13.     targetPort: web 
  14.   selector: 
  15.     prometheus: prometheus 

創(chuàng )建上述服務(wù)后,您可以通過(guò)節點(diǎn)的 IP 和端口 30904 訪(fǎng)問(wèn) Prometheus server 的 web UI。

此時(shí),您應該能夠在 Prometheus server UI 的目標和規則部分看到所有 Longhorn manager targets 以及 Longhorn rules。

使用上述 NodePort service 進(jìn)行快速驗證,因為它不通過(guò) TLS 連接進(jìn)行通信。您可能希望將服務(wù)類(lèi)型更改為 ClusterIP,并設置一個(gè) Ingress-controller 以通過(guò) TLS 連接公開(kāi) Prometheus server 的 web UI。

安裝 Grafana

創(chuàng )建 Grafana 數據源配置:

  1. apiVersion: v1 
  2. kind: ConfigMap 
  3. metadata: 
  4.   name: grafana-datasources 
  5.   namespace: monitoring 
  6. data: 
  7.   prometheus.yaml: |- 
  8.     { 
  9.         "apiVersion": 1, 
  10.         "datasources": [ 
  11.             { 
  12.                "access":"proxy"
  13.                 "editable"true
  14.                 "name""prometheus"
  15.                 "orgId": 1, 
  16.                 "type""prometheus"
  17.                 "url""http://prometheus:9090"
  18.                 "version": 1 
  19.             } 
  20.         ] 
  21.     } 

創(chuàng )建 Grafana 部署:

  1. apiVersion: apps/v1 
  2. kind: Deployment 
  3. metadata: 
  4.   name: grafana 
  5.   namespace: monitoring 
  6.   labels: 
  7.     app: grafana 
  8. spec: 
  9.   replicas: 1 
  10.   selector: 
  11.     matchLabels: 
  12.       app: grafana 
  13.   template: 
  14.     metadata: 
  15.       name: grafana 
  16.       labels: 
  17.         app: grafana 
  18.     spec: 
  19.       containers: 
  20.       - name: grafana 
  21.         image: grafana/grafana:7.1.5 
  22.         ports: 
  23.         - name: grafana 
  24.           containerPort: 3000 
  25.         resources: 
  26.           limits: 
  27.             memory: "500Mi" 
  28.             cpu: "300m" 
  29.           requests: 
  30.             memory: "500Mi" 
  31.             cpu: "200m" 
  32.         volumeMounts: 
  33.           - mountPath: /var/lib/grafana 
  34.             name: grafana-storage 
  35.           - mountPath: /etc/grafana/provisioning/datasources 
  36.             name: grafana-datasources 
  37.             readOnly: false 
  38.       volumes: 
  39.         - name: grafana-storage 
  40.           emptyDir: {} 
  41.         - name: grafana-datasources 
  42.           configMap: 
  43.               defaultMode: 420 
  44.               name: grafana-datasources 

在 NodePort 32000 上暴露 Grafana:

  1. apiVersion: v1 
  2. kind: Service 
  3. metadata: 
  4.   name: grafana 
  5.   namespace: monitoring 
  6. spec: 
  7.   selector: 
  8.     app: grafana 
  9.   type: NodePort 
  10.   ports: 
  11.     - port: 3000 
  12.       targetPort: 3000 
  13.       nodePort: 32000 

使用上述 NodePort 服務(wù)進(jìn)行快速驗證,因為它不通過(guò) TLS 連接進(jìn)行通信。您可能希望將服務(wù)類(lèi)型更改為 ClusterIP,并設置一個(gè) Ingress-controller 以通過(guò) TLS 連接公開(kāi) Grafana。

使用端口 32000 上的任何節點(diǎn) IP 訪(fǎng)問(wèn) Grafana 儀表板。默認憑據為:

  1. User: admin 
  2. Pass: admin 

安裝 Longhorn dashboard

進(jìn)入 Grafana 后,導入預置的面板:https://grafana.com/grafana/dashboards/13032

有關(guān)如何導入 Grafana dashboard 的說(shuō)明,請參閱 https://grafana.com/docs/grafana/latest/reference/export_import/

成功后,您應該會(huì )看到以下 dashboard:

將 Longhorn 指標集成到 Rancher 監控系統中

關(guān)于 Rancher 監控系統

使用 Rancher,您可以通過(guò)與領(lǐng)先的開(kāi)源監控解決方案 Prometheus 的集成來(lái)監控集群節點(diǎn)、Kubernetes 組件和軟件部署的狀態(tài)和進(jìn)程。

有關(guān)如何部署/啟用 Rancher 監控系統的說(shuō)明,請參見(jiàn)https://rancher.com/docs/rancher/v2.x/en/monitoring-alerting/

將 Longhorn 指標添加到 Rancher 監控系統

如果您使用 Rancher 來(lái)管理您的 Kubernetes 并且已經(jīng)啟用 Rancher 監控,您可以通過(guò)簡(jiǎn)單地部署以下 ServiceMonitor 將 Longhorn 指標添加到 Rancher 監控中:

  1. apiVersion: monitoring.coreos.com/v1 
  2. kind: ServiceMonitor 
  3. metadata: 
  4.   name: longhorn-prometheus-servicemonitor 
  5.   namespace: longhorn-system 
  6.   labels: 
  7.     name: longhorn-prometheus-servicemonitor 
  8. spec: 
  9.   selector: 
  10.     matchLabels: 
  11.       app: longhorn-manager 
  12.   namespaceSelector: 
  13.     matchNames: 
  14.     - longhorn-system 
  15.   endpoints: 
  16.   - port: manager 

創(chuàng )建 ServiceMonitor 后,Rancher 將自動(dòng)發(fā)現所有 Longhorn 指標。

然后,您可以設置 Grafana 儀表板以進(jìn)行可視化。

Longhorn 監控指標

Volume(卷)

Node(節點(diǎn))

Disk(磁盤(pán))

Instance Manager(實(shí)例管理器)

Manager(管理器)

支持 Kubelet Volume 指標

關(guān)于 Kubelet Volume 指標

Kubelet 公開(kāi)了以下指標:

  1. kubelet_volume_stats_capacity_bytes
  2. kubelet_volume_stats_available_bytes
  3. kubelet_volume_stats_used_bytes
  4. kubelet_volume_stats_inodes
  5. kubelet_volume_stats_inodes_free
  6. kubelet_volume_stats_inodes_used

這些指標衡量與 Longhorn 塊設備內的 PVC 文件系統相關(guān)的信息。

它們與 longhorn_volume_* 指標不同,后者測量特定于 Longhorn 塊設備(block device)的信息。

您可以設置一個(gè)監控系統來(lái)抓取 Kubelet 指標端點(diǎn)以獲取 PVC 的狀態(tài)并設置異常事件的警報,例如 PVC 即將耗盡存儲空間。

一個(gè)流行的監控設置是 prometheus-operator/kube-prometheus-stack,,它抓取 kubelet_volume_stats_* 指標并為它們提供儀表板和警報規則。

Longhorn CSI 插件支持

在 v1.1.0 中,Longhorn CSI 插件根據 CSI spec 支持 NodeGetVolumeStats RPC。

這允許 kubelet 查詢(xún) Longhorn CSI 插件以獲取 PVC 的狀態(tài)。

然后 kubelet 在 kubelet_volume_stats_* 指標中公開(kāi)該信息。

Longhorn 警報規則示例

我們在下面提供了幾個(gè)示例 Longhorn 警報規則供您參考。請參閱此處獲取所有可用 Longhorn 指標的列表并構建您自己的警報規則。

  1. apiVersion: monitoring.coreos.com/v1 
  2. kind: PrometheusRule 
  3. metadata: 
  4.   labels: 
  5.     prometheus: longhorn 
  6.     role: alert-rules 
  7.   name: prometheus-longhorn-rules 
  8.   namespace: monitoring 
  9. spec: 
  10.   groups: 
  11.   - name: longhorn.rules 
  12.     rules: 
  13.     - alert: LonghornVolumeActualSpaceUsedWarning 
  14.       annotations: 
  15.         description: The actual space used by Longhorn volume {{$labels.volume}} on {{$labels.node}} is at {{$value}}% capacity for 
  16.           more than 5 minutes. 
  17.         summary: The actual used space of Longhorn volume is over 90% of the capacity. 
  18.       expr: (longhorn_volume_actual_size_bytes / longhorn_volume_capacity_bytes) * 100 > 90 
  19.       for: 5m 
  20.       labels: 
  21.         issue: The actual used space of Longhorn volume {{$labels.volume}} on {{$labels.node}} is high. 
  22.         severity: warning 
  23.     - alert: LonghornVolumeStatusCritical 
  24.       annotations: 
  25.         description: Longhorn volume {{$labels.volume}} on {{$labels.node}} is Fault for 
  26.           more than 2 minutes. 
  27.         summary: Longhorn volume {{$labels.volume}} is Fault 
  28.       expr: longhorn_volume_robustness == 3 
  29.       for: 5m 
  30.       labels: 
  31.         issue: Longhorn volume {{$labels.volume}} is Fault. 
  32.         severity: critical 
  33.     - alert: LonghornVolumeStatusWarning 
  34.       annotations: 
  35.         description: Longhorn volume {{$labels.volume}} on {{$labels.node}} is Degraded for 
  36.           more than 5 minutes. 
  37.         summary: Longhorn volume {{$labels.volume}} is Degraded 
  38.       expr: longhorn_volume_robustness == 2 
  39.       for: 5m 
  40.       labels: 
  41.         issue: Longhorn volume {{$labels.volume}} is Degraded. 
  42.         severity: warning 
  43.     - alert: LonghornNodeStorageWarning 
  44.       annotations: 
  45.         description: The used storage of node {{$labels.node}} is at {{$value}}% capacity for 
  46.           more than 5 minutes. 
  47.         summary:  The used storage of node is over 70% of the capacity. 
  48.       expr: (longhorn_node_storage_usage_bytes / longhorn_node_storage_capacity_bytes) * 100 > 70 
  49.       for: 5m 
  50.       labels: 
  51.         issue: The used storage of node {{$labels.node}} is high. 
  52.         severity: warning 
  53.     - alert: LonghornDiskStorageWarning 
  54.       annotations: 
  55.         description: The used storage of disk {{$labels.disk}} on node {{$labels.node}} is at {{$value}}% capacity for 
  56.           more than 5 minutes. 
  57.         summary:  The used storage of disk is over 70% of the capacity. 
  58.       expr: (longhorn_disk_usage_bytes / longhorn_disk_capacity_bytes) * 100 > 70 
  59.       for: 5m 
  60.       labels: 
  61.         issue: The used storage of disk {{$labels.disk}} on node {{$labels.node}} is high. 
  62.         severity: warning 
  63.     - alert: LonghornNodeDown 
  64.       annotations: 
  65.         description: There are {{$value}} Longhorn nodes which have been offline for more than 5 minutes. 
  66.         summary: Longhorn nodes is offline 
  67.       expr: longhorn_node_total - (count(longhorn_node_status{condition="ready"}==1) OR on() vector(0)) 
  68.       for: 5m 
  69.       labels: 
  70.         issue: There are {{$value}} Longhorn nodes are offline 
  71.         severity: critical 
  72.     - alert: LonghornIntanceManagerCPUUsageWarning 
  73.       annotations: 
  74.         description: Longhorn instance manager {{$labels.instance_manager}} on {{$labels.node}} has CPU Usage / CPU request is {{$value}}% for 
  75.           more than 5 minutes. 
  76.         summary: Longhorn instance manager {{$labels.instance_manager}} on {{$labels.node}} has CPU Usage / CPU request is over 300%. 
  77.       expr: (longhorn_instance_manager_cpu_usage_millicpu/longhorn_instance_manager_cpu_requests_millicpu) * 100 > 300 
  78.       for: 5m 
  79.       labels: 
  80.         issue: Longhorn instance manager {{$labels.instance_manager}} on {{$labels.node}} consumes 3 times the CPU request. 
  81.         severity: warning 
  82.     - alert: LonghornNodeCPUUsageWarning 
  83.       annotations: 
  84.         description: Longhorn node {{$labels.node}} has CPU Usage / CPU capacity is {{$value}}% for 
  85.           more than 5 minutes. 
  86.         summary: Longhorn node {{$labels.node}} experiences high CPU pressure for more than 5m. 
  87.       expr: (longhorn_node_cpu_usage_millicpu / longhorn_node_cpu_capacity_millicpu) * 100 > 90 
  88.       for: 5m 
  89.       labels: 
  90.         issue: Longhorn node {{$labels.node}} experiences high CPU pressure. 
  91.         severity: warning 

在https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/#alerting-rules 查看有關(guān)如何定義警報規則的更多信息。

原文鏈接:https://mp.weixin.qq.com/s/znaf4v3OBdGrLp0j23BcaQ

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

成人欧美日韩一区二区三区| 美女被男人桶到爽免费网站| 最近中文字幕完整版免费高清| 亚洲成AV人片一区二区三区| 亚洲国产精品一区二区美利坚| 亚洲一区AV无码少妇电影☆|