環(huán)境說明:
成都創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于做網(wǎng)站、網(wǎng)站建設(shè)、柘城網(wǎng)絡(luò)推廣、微信小程序開發(fā)、柘城網(wǎng)絡(luò)營銷、柘城企業(yè)策劃、柘城品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;成都創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供柘城建站搭建服務(wù),24小時服務(wù)熱線:18982081108,官方網(wǎng)址:sd-ha.com
主機(jī)名 | 操作系統(tǒng)版本 | ip | docker version | kubelet version | 配置 | 備注 |
---|---|---|---|---|---|---|
master | Centos 7.6.1810 | 172.27.9.131 | Docker 18.09.6 | V1.14.2 | 2C2G | master主機(jī) |
node01 | Centos 7.6.1810 | 172.27.9.135 | Docker 18.09.6 | V1.14.2 | 2C2G | node節(jié)點 |
node02 | Centos 7.6.1810 | 172.27.9.136 | Docker 18.09.6 | V1.14.2 | 2C2G | node節(jié)點 |
?
k8s集群部署詳見:Centos7.6部署k8s(v1.14.2)集群
k8s學(xué)習(xí)資料詳見:基本概念、kubectl命令和資料分享
k8s高可用集群部署詳見:Centos7.6部署k8s v1.16.4高可用集群(主備模式)
?
Heapster是Kubernetes原生的集群監(jiān)控方案,Kubelet自身就包含了一個名為cAdvisor的agent,它會收集整個節(jié)點和節(jié)點上運行的所有單獨容器的資源消耗情況。Heapster以pod的方式運行在某個節(jié)點上,它通過普通的KubernetesService暴露服務(wù),使外部可以通過一個穩(wěn)定的IP地址訪問。它從集群中所有的cAdvisor收集數(shù)據(jù),然后通過一個單獨的地址暴露。
Heapster 將數(shù)據(jù)按照 Pod 進(jìn)行分組,將它們存儲到預(yù)先配置的 backend 并進(jìn)行可視化展示。Heapster 當(dāng)前支持的 backend 有 InfluxDB(通過 Grafana 展示),Google Cloud Monitoring 等。
lnfluxDB是一個用于存儲應(yīng)用指標(biāo),以及其他監(jiān)控數(shù)據(jù)的開源的時序數(shù)據(jù)庫。Grafana是一個擁有著華麗的web控制臺的數(shù)據(jù)分析和可視化套件,同樣也是開源的,它允許用戶對InfluxDB中存儲的數(shù)據(jù)進(jìn)行可視化,同時發(fā)現(xiàn)應(yīng)用程序的資源使用行為是如何隨時間變化的。
安裝文件下載:
[root@master ~]# git clone https://github.com/kubernetes-retired/heapster.git
或者
[root@master ~]# wget https://github.com/kubernetes-retired/heapster/archive/master.zip
[root@master ~]# unzip master.zip
兩種方式都可以下載安裝文件,本文采取第二種方式
鏡像下載及打標(biāo)簽
[root@node02 ~]# docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-grafana-amd64:v5.0.4
[root@node02 ~]# docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-influxdb-amd64:v1.5.2
[root@node02 ~]# docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-amd64:v1.5.4
[root@node02 ~]# docker image tag registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-amd64:v1.5.4 k8s.gcr.io/heapster-amd64:v1.5.4
[root@node02 ~]# docker image tag registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-influxdb-amd64:v1.5.2 k8s.gcr.io/heapster-influxdb-amd64:v1.5.2
[root@node02 ~]# docker image tag registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-grafana-amd64:v5.0.4 k8s.gcr.io/heapster-grafana-amd64:v5.0.4
[root@node02 ~]# docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-amd64:v1.5.4 registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-influxdb-amd64:v1.5.2 registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-grafana-amd64:v5.0.4
注意:每個節(jié)點都需執(zhí)行以上命令
[root@master ~]# cd heapster-master/deploy/kube-config/
[root@master kube-config]# pwd
/root/heapster-master/deploy/kube-config
[root@master kube-config]# ll
總用量 0
drwxr-xr-x 2 root root 27 11月 30 2018 google
drwxr-xr-x 2 root root 68 10月 22 15:00 influxdb
drwxr-xr-x 2 root root 32 10月 22 15:02 rbac
drwxr-xr-x 2 root root 38 11月 30 2018 standalone
drwxr-xr-x 2 root root 170 11月 30 2018 standalone-test
drwxr-xr-x 2 root root 145 11月 30 2018 standalone-with-apiserver
[root@master kube-config]# cd influxdb/
[root@master influxdb]# ll
總用量 12
-rw-r--r-- 1 root root 2294 10月 22 14:51 grafana.yaml
-rw-r--r-- 1 root root 1162 10月 22 15:00 heapster.yaml
-rw-r--r-- 1 root root 997 10月 22 14:51 influxdb.yaml
[root@master influxdb]# cd ../rbac/
[root@master rbac]# ll
總用量 4
-rw-r--r-- 1 root root 263 10月 22 15:02 heapster-rbac.yaml
分別修改文件grafana.yaml、influxdb.yaml、heapster.yaml和heapster-rbac.yaml
修改grafana.yaml,port類型為NodePort,nodePort為30011,可通過http://NodeIp:30011方式訪問
修改influxdb.yaml,port類型為NodePort,nodePort為30012,grafana配置數(shù)據(jù)源會用到
修改heapster.yaml中的source和sink參數(shù)
source: 指定數(shù)據(jù)獲取源
source參數(shù) | 說明 |
---|---|
inClusterConfig | 在與heapster的命名空間關(guān)聯(lián)的服務(wù)帳戶中使用kube config(默認(rèn)值:true) |
kubeletPort | 指定kubelet的使用端口,默認(rèn)10255 |
kubeletHttps | 是否使用https去連接kubelets(默認(rèn):false) |
insecure | 是否使用安全證書(默認(rèn):false) |
auth | 安全認(rèn)證 |
useServiceAccount | 是否使用K8S的安全令牌(默認(rèn):false) |
sink: 指定后端數(shù)據(jù)存儲
sink參數(shù) | 說明 |
---|---|
user | InfluxDB用戶,默認(rèn)root |
pw | InfluxDB密碼,默認(rèn)root |
db | 數(shù)據(jù)庫名,默認(rèn)k8s |
retention | 默認(rèn)infloxDB保留策略的持續(xù)時間,默認(rèn)值0,表示無限 |
secure | 安全連接到InfluxDB(默認(rèn):false) |
insecuressl | 忽略SSL證書有效性(默認(rèn)值:false) |
withfields | 使用InfluxDB fields(默認(rèn):false) |
cluster_name | 不同cubernete集群的集群名稱(默認(rèn):default) |
disable_counter_metrics | 禁用接收計數(shù)器度量以流入數(shù)據(jù)庫(默認(rèn):false) |
concurrency | 并發(fā)數(shù)(默認(rèn):1) |
修改heapster-rbac.yaml,將權(quán)限修改為cluster-admi
[root@master kube-config]# pwd
/root/heapster-master/deploy/kube-config
[root@master kube-config]# kubectl apply -f influxdb/
deployment.extensions/monitoring-grafana created
service/monitoring-grafana created
serviceaccount/heapster created
deployment.extensions/heapster created
service/heapster created
deployment.extensions/monitoring-influxdb created
service/monitoring-influxdb created
[root@master kube-config]# kubectl apply -f rbac/heapster-rbac.yaml
clusterrolebinding.rbac.authorization.k8s.io/heapster created
[root@master kube-config]# kubectl get all -n kube-system -o wide |grep -e monitor -e heapster
登陸地址: http://172.27.9.131:30011
url為http://172.27.9.131:30012
模板下載
下載地址:https://grafana.com/api/dashboards/3649/revisions/1/download 、
https://grafana.com/api/dashboards/3646/revisions/1/download
導(dǎo)入
同理導(dǎo)入kubernetes-node-statistics
[root@master ~]# kubectl delete -n kube-system ClusterRoleBinding heapster [root@master ~]# kubectl get all -n kube-system -o wide |grep -e monitor -e heapster |awk '{print $1}'|xargs kubectl delete -n kube-system
[root@master ~]# rm -rf heapster-master master.zip
本文所有配置文件已上傳github:https://github.com/loong576/heapster-influxdb-grafana/archive/master.zip
本文題目:k8s實踐(十一):heapster+influxdb+grafana實現(xiàn)kubernetes集群監(jiān)
本文來源:http://sd-ha.com/article24/ghdhce.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、網(wǎng)站營銷、網(wǎng)站收錄、營銷型網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站、微信小程序
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)