Kubernetes-dashboard+Heapster+InfluxDB+Grafana的示例分析

這篇文章將為大家詳細(xì)講解有關(guān)Kubernetes-dashboard+Heapster+InfluxDB+Grafana的示例分析,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

目前成都創(chuàng)新互聯(lián)公司已為上1000+的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)絡(luò)空間、綿陽(yáng)服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計(jì)、銅川網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

一:前言

1.kubernetes-dashboard 官方提供的用戶管理Kubernets集群可視化工具

2.cAdvisor是用于監(jiān)控容器運(yùn)行狀態(tài)的利器之一。在kubernetes系統(tǒng)中,cAdvisor已經(jīng)被默認(rèn)集成到了kubelet組件內(nèi),當(dāng)kubelet服務(wù)啟動(dòng)時(shí),它會(huì)自動(dòng)啟動(dòng)cAdvisor服務(wù),然后cAdvisor會(huì)實(shí)時(shí)采集所在節(jié)點(diǎn)的性能指標(biāo)及節(jié)點(diǎn)上運(yùn)行的容器的性能指標(biāo)。cAdvisor主頁(yè)顯示了主機(jī)的實(shí)時(shí)運(yùn)行狀態(tài),包括CPU使用情況、內(nèi)存使用情況、網(wǎng)絡(luò)吞吐量及文件系統(tǒng)使用情況等信息。但是cAdvisor只提供了單機(jī)的容器資源占用情況,而在大規(guī)模容器集群中,需要對(duì)所有的Node和全部容器進(jìn)行性能監(jiān)控。這就需要一套工具來(lái)實(shí)現(xiàn)集群性能數(shù)據(jù)的采集、存儲(chǔ)和展示。

3.Heapster 提供整個(gè)集群的資源監(jiān)控,并支持持久化數(shù)據(jù)存儲(chǔ)到InfluxDB或者其他的存儲(chǔ)后端。Heapster從kubelet提供的API采集節(jié)點(diǎn)和容器的資源占用。另外,Heapster的 /metrics API提供了Prometheus格式的數(shù)據(jù)。

4.InfluxDB是一個(gè)開(kāi)源分布式時(shí)序、事件和指標(biāo)數(shù)據(jù)庫(kù)。

5.Grafana是一個(gè)開(kāi)源儀表盤(pán)工具,它可用于Graphite、InfluxDB與 OpenTSDB 一起使用。最新的版本還可以用于其他的數(shù)據(jù)源,比如Elasticsearch。(與heapster與Prometheus均可集成)

6.Zabbix是一個(gè)基于WEB界面的提供分布式系統(tǒng)監(jiān)視以及網(wǎng)絡(luò)監(jiān)視功能的企業(yè)級(jí)的開(kāi)源解決方案.多用于傳統(tǒng)(非微服務(wù))分布式系統(tǒng)的監(jiān)控。

7.Prometheus 容器時(shí)代的產(chǎn)物。集成采集、存儲(chǔ)(支持多種時(shí)序數(shù)據(jù)庫(kù))、頁(yè)面展示與一體的監(jiān)控工具。

監(jiān)控方案:
a.Heapster+InfluxDB+Grafana
b.Prometheus

二:安裝
1.鏡像
k8s.gcr.io/kubernetes-dashboard-amd64:v1.8.2
gcr.io/google_containers/heapster-amd64:v1.4.2
gcr.io/google_containers/heapster-influxdb-amd64:v1.3.3 
gcr.io/google_containers/heapster-grafana-amd64:v4.4.3

2.yaml文件
Kubernetes-dashboard+Heapster+InfluxDB+Grafana的示例分析

admin-user.yaml(不需修改)

點(diǎn)擊(此處)折疊或打開(kāi)

  1. apiVersion: v1

  2. kind: ServiceAccount

  3. metadata:

  4.   name: admin-user

  5.   namespace: kube-system

  6. ---

  7. apiVersion: rbac.authorization.k8s.io/v1

  8. kind: ClusterRoleBinding

  9. metadata:

  10.   name: admin-user

  11. roleRef:

  12.   apiGroup: rbac.authorization.k8s.io

  13.   kind: ClusterRole

  14.   name: cluster-admin

  15. subjects:

  16. - kind: ServiceAccount

  17.   name: admin-user

  18.   namespace: kube-system

dashboard.yaml(橙色標(biāo)示是修改的地方。特別說(shuō)明當(dāng)前版本需要添加 - --heapster-host=http://heapster 配置,否則無(wú)法正常獲取metrics )

點(diǎn)擊(此處)折疊或打開(kāi)

  1. # Copyright 2017 The Kubernetes Authors.

  2. #

  3. # Licensed under the Apache License, Version 2.0 (the "License");

  4. # you may not use this file except in compliance with the License.

  5. # You may obtain a copy of the License at

  6. #

  7. #     http://www.apache.org/licenses/LICENSE-2.0

  8. #

  9. # Unless required by applicable law or agreed to in writing, software

  10. # distributed under the License is distributed on an "AS IS" BASIS,

  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  12. # See the License for the specific language governing permissions and

  13. # limitations under the License.

  14. # Configuration to deploy release version of the Dashboard UI compatible with

  15. # Kubernetes 1.8.

  16. #

  17. # Example usage: kubectl create -f

  18. # ------------------- Dashboard Secret ------------------- #

  19. apiVersion: v1

  20. kind: Secret

  21. metadata:

  22.   labels:

  23.     k8s-app: kubernetes-dashboard

  24.   name: kubernetes-dashboard-certs

  25.   namespace: kube-system

  26. type: Opaque

  27. ---

  28. # ------------------- Dashboard Service Account ------------------- #

  29. apiVersion: v1

  30. kind: ServiceAccount

  31. metadata:

  32.   labels:

  33.     k8s-app: kubernetes-dashboard

  34.   name: kubernetes-dashboard

  35.   namespace: kube-system

  36. ---

  37. # ------------------- Dashboard Role & Role Binding ------------------- #

  38. kind: Role

  39. apiVersion: rbac.authorization.k8s.io/v1

  40. metadata:

  41.   name: kubernetes-dashboard-minimal

  42.   namespace: kube-system

  43. rules:

  44.   # Allow Dashboard to create 'kubernetes-dashboard-key-holder' secret.

  45. - apiGroups: [""]

  46.   resources: ["secrets"]

  47.   verbs: ["create"]

  48.   # Allow Dashboard to create 'kubernetes-dashboard-settings' config map.

  49. - apiGroups: [""]

  50.   resources: ["configmaps"]

  51.   verbs: ["create"]

  52.   # Allow Dashboard to get, update and delete Dashboard exclusive secrets.

  53. - apiGroups: [""]

  54.   resources: ["secrets"]

  55.   resourceNames: ["kubernetes-dashboard-key-holder", "kubernetes-dashboard-certs"]

  56.   verbs: ["get", "update", "delete"]

  57.   # Allow Dashboard to get and update 'kubernetes-dashboard-settings' config map.

  58. - apiGroups: [""]

  59.   resources: ["configmaps"]

  60.   resourceNames: ["kubernetes-dashboard-settings"]

  61.   verbs: ["get", "update"]

  62.   # Allow Dashboard to get metrics from heapster.

  63. - apiGroups: [""]

  64.   resources: ["services"]

  65.   resourceNames: ["heapster"]

  66.   verbs: ["proxy"]

  67. - apiGroups: [""]

  68.   resources: ["services/proxy"]

  69.   resourceNames: ["heapster", "http:heapster:", "https:heapster:"]

  70.   verbs: ["get"]

  71. ---

  72. apiVersion: rbac.authorization.k8s.io/v1

  73. kind: RoleBinding

  74. metadata:

  75.   name: kubernetes-dashboard-minimal

  76.   namespace: kube-system

  77. roleRef:

  78.   apiGroup: rbac.authorization.k8s.io

  79.   kind: Role

  80.   name: kubernetes-dashboard-minimal

  81. subjects:

  82. - kind: ServiceAccount

  83.   name: kubernetes-dashboard

  84.   namespace: kube-system

  85. ---

  86. # ------------------- Dashboard Deployment ------------------- #

  87. kind: Deployment

  88. apiVersion: apps/v1beta2

  89. metadata:

  90.   labels:

  91.     k8s-app: kubernetes-dashboard

  92.   name: kubernetes-dashboard

  93.   namespace: kube-system

  94. spec:

  95.   replicas: 1

  96.   revisionHistoryLimit: 10

  97.   selector:

  98.     matchLabels:

  99.       k8s-app: kubernetes-dashboard

  100.   template:

  101.     metadata:

  102.       labels:

  103.         k8s-app: kubernetes-dashboard

  104.     spec:

  105.       containers:

  106.       - name: kubernetes-dashboard

  107.         image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.8.2

  108.         ports:

  109.         - containerPort: 8443

  110.           protocol: TCP

  111.         args:

  112.           - --auto-generate-certificates

  113.           # Uncomment the following line to manually specify Kubernetes API server Host

  114.           # If not specified, Dashboard will attempt to auto discover the API server and connect

  115.           # to it. Uncomment only if the default does not work.

  116.           # - --apiserver-host=http://my-address:port

  117.           - --heapster-host=http://heapster

  118.         volumeMounts:

  119.         - name: kubernetes-dashboard-certs

  120.           mountPath: /certs

  121.           # Create on-disk volume to store exec logs

  122.         - mountPath: /tmp

  123.           name: tmp-volume

  124.         livenessProbe:

  125.           httpGet:

  126.             scheme: HTTPS

  127.             path: /

  128.             port: 8443

  129.           initialDelaySeconds: 30

  130.           timeoutSeconds: 30

  131.       volumes:

  132.       - name: kubernetes-dashboard-certs

  133.         secret:

  134.           secretName: kubernetes-dashboard-certs

  135.       - name: tmp-volume

  136.         emptyDir: {}

  137.       serviceAccountName: kubernetes-dashboard

  138.       # Comment the following tolerations if Dashboard must not be deployed on master

  139.       tolerations:

  140.       - key: node-role.kubernetes.io/master

  141.         effect: NoSchedule

  142. ---

  143. # ------------------- Dashboard Service ------------------- #

  144. kind: Service

  145. apiVersion: v1

  146. metadata:

  147.   labels:

  148.     k8s-app: kubernetes-dashboard

  149.   name: kubernetes-dashboard

  150.   namespace: kube-system

  151. spec:

  152.   type: NodePort

  153.   ports:

  154.     - port: 443

  155.       targetPort: 8443

  156.       nodePort: 32666

  157.   selector:

  158.     k8s-app: kubernetes-dashboard

grafana.yaml(橙色標(biāo)示為需要修改的地方)

點(diǎn)擊(此處)折疊或打開(kāi)

  1. apiVersion: extensions/v1beta1

  2. kind: Deployment

  3. metadata:

  4.   name: monitoring-grafana

  5.   namespace: kube-system

  6. spec:

  7.   replicas: 1

  8.   template:

  9.     metadata:

  10.       labels:

  11.         task: monitoring

  12.         k8s-app: grafana

  13.     spec:

  14.       containers:

  15.       - name: grafana

  16.         image: gcr.io/google_containers/heapster-grafana-amd64:v4.4.3

  17.         ports:

  18.         - containerPort: 3000

  19.           protocol: TCP

  20.         volumeMounts:

  21.         - mountPath: /etc/ssl/certs

  22.           name: ca-certificates

  23.           readOnly: true

  24.         - mountPath: /var

  25.           name: grafana-storage

  26.         env:

  27.         - name: INFLUXDB_HOST

  28.           value: monitoring-influxdb

  29.         - name: GF_SERVER_HTTP_PORT

  30.           value: "3000"

  31.           # The following env variables are required to make Grafana accessible via

  32.           # the kubernetes api-server proxy. On production clusters, we recommend

  33.           # removing these env variables, setup auth for grafana, and expose the grafana

  34.           # service using a LoadBalancer or a public IP.

  35.         - name: GF_AUTH_BASIC_ENABLED

  36.           value: "false"

  37.         - name: GF_AUTH_ANONYMOUS_ENABLED

  38.           value: "true"

  39.         - name: GF_AUTH_ANONYMOUS_ORG_ROLE

  40.           value: Admin

  41.         - name: GF_SERVER_ROOT_URL

  42.           # If you're only using the API Server proxy, set this value instead:

  43.           # value: /api/v1/namespaces/kube-system/services/monitoring-grafana/proxy

  44.           value: /

  45.       volumes:

  46.       - name: ca-certificates

  47.         hostPath:

  48.           path: /etc/ssl/certs

  49.       - name: grafana-storage

  50.         emptyDir: {}

  51. ---

  52. apiVersion: v1

  53. kind: Service

  54. metadata:

  55.   labels:

  56.     # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)

  57.     # If you are NOT using this as an addon, you should comment out this line.

  58.     kubernetes.io/cluster-service: 'true

heapster-rbac.yaml(不需要修改)

點(diǎn)擊(此處)折疊或打開(kāi)

  1. kind: ClusterRoleBinding

  2. apiVersion: rbac.authorization.k8s.io/v1beta1

  3. metadata:

  4.   name: heapster

  5. roleRef:

  6.   apiGroup: rbac.authorization.k8s.io

  7.   kind: ClusterRole

  8.   name: system:heapster

  9. subjects:

  10. - kind: ServiceAccount

  11.   name: heapster

  12.   namespace: kube-system

heapster.yaml(橙色標(biāo)示為需要修改的地方)

點(diǎn)擊(此處)折疊或打開(kāi)

  1. apiVersion: v1

  2. kind: ServiceAccount

  3. metadata:

  4.   name: heapster

  5.   namespace: kube-system

  6. ---

  7. apiVersion: extensions/v1beta1

  8. kind: Deployment

  9. metadata:

  10.   name: heapster

  11.   namespace: kube-system

  12. spec:

  13.   replicas: 1

  14.   template:

  15.     metadata:

  16.       labels:

  17.         task: monitoring

  18.         k8s-app: heapster

  19.     spec:

  20.       serviceAccountName: heapster

  21.       containers:

  22.       - name: heapster

  23.         image: gcr.io/google_containers/heapster-amd64:v1.4.2

  24.         imagePullPolicy: IfNotPresent

  25.         command:

  26.         - /heapster

  27.         - --source=kubernetes:https://10.116.137.196:6443

  28.         - --sink=influxdb:http://monitoring-influxdb.kube-system.svc:8086

  29. ---

  30. apiVersion: v1

  31. kind: Service

  32. metadata:

  33.   labels:

  34.     task: monitoring

  35.     # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)

  36.     # If you are NOT using this as an addon, you should comment out this line.

  37.     kubernetes.io/cluster-service: 'true'

  38.     kubernetes.io/name: Heapster

  39.   name: heapster

  40.   namespace: kube-system

  41. spec:

  42.   ports:

  43.   - port: 80

  44.     targetPort: 8082

  45.   selector:

  46.     k8s-app: heapster

influxdb.yaml(橙色標(biāo)示為需要修改的地方)

點(diǎn)擊(此處)折疊或打開(kāi)

  1. apiVersion: extensions/v1beta1

  2. kind: Deployment

  3. metadata:

  4.   name: monitoring-influxdb

  5.   namespace: kube-system

  6. spec:

  7.   replicas: 1

  8.   template:

  9.     metadata:

  10.       labels:

  11.         task: monitoring

  12.         k8s-app: influxdb

  13.     spec:

  14.       containers:

  15.       - name: influxdb

  16.         image: gcr.io/google_containers/heapster-influxdb-amd64:v1.3.3

  17.         volumeMounts:

  18.         - mountPath: /data

  19.           name: influxdb-storage

  20.       volumes:

  21.       - name: influxdb-storage

  22.         emptyDir: {}

  23. ---

  24. apiVersion: v1

  25. kind: Service

  26. metadata:

  27.   labels:

  28.     task: monitoring

  29.     # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)

  30.     # If you are NOT using this as an addon, you should comment out this line.

  31.     kubernetes.io/cluster-service: 'true'

  32.     kubernetes.io/name: monitoring-influxdb

  33.   name: monitoring-influxdb

  34.   namespace: kube-system

  35. spec:

  36.   ports:

  37.   - port: 8086

  38.     targetPort: 8086

  39.   selector:

  40.     k8s-app: influxdb

dashboard.yaml 文件源于https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

其他yaml.文件源于
https://codeload.github.com/kubernetes/heapster/zip/v1.4.2  下載后解壓縮  位于目錄\deploy\kube-config\influxdb

3.創(chuàng)建相關(guān)資源
執(zhí)行命令:
kubectl create -f admin-user.yaml -f dashboard.yaml -f grafana.yaml -f heapster-rbac.yaml -f heapster.yaml -f influxdb.yaml
查看創(chuàng)建狀態(tài):
kubectl get pods --all-namespaces
Kubernetes-dashboard+Heapster+InfluxDB+Grafana的示例分析
三:訪問(wèn)
建議使用Firefox瀏覽器訪問(wèn)https://nodeIp:32666

Kubernetes-dashboard+Heapster+InfluxDB+Grafana的示例分析

選擇使用令牌登錄的方式,  生成令牌的命令如下(請(qǐng)保存好生成的Token):

點(diǎn)擊(此處)折疊或打開(kāi)

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

成功登錄后的頁(yè)面:
Kubernetes-dashboard+Heapster+InfluxDB+Grafana的示例分析

關(guān)于“Kubernetes-dashboard+Heapster+InfluxDB+Grafana的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

當(dāng)前文章:Kubernetes-dashboard+Heapster+InfluxDB+Grafana的示例分析
標(biāo)題網(wǎng)址:http://bm7419.com/article14/gegpde.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、云服務(wù)器、服務(wù)器托管、外貿(mào)網(wǎng)站建設(shè)、商城網(wǎng)站用戶體驗(yàn)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

營(yíng)銷型網(wǎng)站建設(shè)