Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

K8s practice (11): heapster+influxdb+grafana implements kubernetes cluster monitoring

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Environment description:

Hostname operating system version ipdocker versionkubelet version configuration remarks masterCentos 7.6.1810172.27.9.131Docker 18.09.6V1.14.22C2Gmaster host node01Centos 7.6.1810172.27.9.135Docker 18.09.6V1.14.22C2Gnode node node02Centos 7.6.1810172.27.9.136Docker 18.09.6V1.14.22C2Gnode node

For more information on k8s cluster deployment, please see Centos7.6 deployment k8s (v1.14.2) cluster.

For more information on K8s learning materials, see: basic concepts, kubectl commands and data sharing.

For more information on k8s high availability cluster deployment, please see Centos7.6 deployment k8s v1.16.4 high availability cluster (active / standby mode)

A brief introduction to 1.heapster

Heapster is a native cluster monitoring scheme for Kubernetes, and Kubelet itself includes an agent called cAdvisor, which collects resource consumption for the entire node and all individual containers running on the node. Heapster runs on a node as pod, exposing the service through a normal KubernetesService so that the outside can be accessed through a stable IP address. It collects data from all the cAdvisor in the cluster and exposes it through a separate address.

Heapster groups data by Pod, stores them in a pre-configured backend, and displays them visually. The backend supported by Heapster currently includes InfluxDB (displayed through Grafana), Google Cloud Monitoring and so on.

Introduction to 2.lnfluxDB and Grafana

LnfluxDB is an open source time series database for storing application metrics and other monitoring data. Grafana is a data analysis and visualization suite with a gorgeous web console, which is also open source, allowing users to visualize the data stored in InfluxDB while discovering how the application's resource usage behavior changes over time.

Second, heapster installation 1. Installation files and image downloads

Download the installation file:

[root@master ~] # git clone https://github.com/kubernetes-retired/heapster.git

Or

[root@master ~] # wget https://github.com/kubernetes-retired/heapster/archive/master.zip[root@master ~] # unzip master.zip

You can download the installation file in both ways, but the second way is adopted in this article.

Image download and tagging

[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

Note: each node needs to execute the above command

two。 Installation file modification [root@master ~] # cd heapster-master/deploy/kube-config/ [root@master kube-config] # pwd/root/heapster-master/deploy/kube-config [root@master kube-config] # ll Total usage 0drwxr-xr-x 2 root root 27 November 30 2018 googledrwxr-xr-x 2 root root 68 October 22 15:00 influxdbdrwxr-xr-x 2 root root 32 October 22 15:02 rbacdrwxr-xr-x 2 root root 38 November 30 2018 standalonedrwxr-xr-x 2 root root 170Nov 30 2018 standalone-testdrwxr-xr-x 2 root root 145Nov 30 2018 standalone-with-apiserver [root@master kube-config] # cd influxdb/ [root@master influxdb] # ll Total usage 12 root 22 14:51 grafana.yaml-rw-r--r-- 1 root root 1162 October 22 15:00 heapster.yaml-rw-r--r-- 1 root root 997 October 22 14:51 influxdb.yaml [root @ master influxdb] # cd.. / rbac/ [root@master rbac] # ll Total usage 4murrwMurr Muhami-1 root root 263 October 22 15:02 heapster-rbac.yaml

Modify the files grafana.yaml, influxdb.yaml, heapster.yaml and heapster-rbac.yaml respectively

Modify the grafana.yaml,port type to NodePort,nodePort to 30011, which can be accessed through http://NodeIp:30011

Change the influxdb.yaml,port type to NodePort,nodePort to 30012 grafana configuration data source will be used

Modify source and sink parameters in heapster.yaml

Source: specify the data acquisition source

The source parameter indicates that inClusterConfig uses kube config (default: true) kubeletPort in the service account associated with heapster's namespace to specify the port to be used by kubelet, and whether the default 10255kubeletHttps uses https to connect to kubelets (default: false) insecure uses security certificate (default: false) auth security authentication useServiceAccount uses K8S security token (default: false)

Sink: specify the backend data store

The sink parameter describes the userInfluxDB user, default rootpwInfluxDB password, default rootdb database name, default k8sretention default infloxDB retention policy duration, default 0 Indicates that unlimited secure securely connects to InfluxDB (default: false) insecuressl ignores SSL certificate validity (default: false) withfields uses InfluxDB fields (default: false) cluster name of different cubernete clusters (default: default) disable_counter_metrics disables receiving counter metrics to flow into database (default: false) number of concurrency concurrency (default: 1)

Modify heapster-rbac.yaml to change permissions to cluster-admi

3. Perform the installation of [root@master kube-config] # pwd/root/heapster-master/deploy/kube-config [root@master kube-config] # kubectl apply-f influxdb/deployment.extensions/monitoring-grafana createdservice/monitoring-grafana createdserviceaccount/heapster createddeployment.extensions/heapster createdservice/heapster createddeployment.extensions/monitoring-influxdb createdservice/monitoring-influxdb created [root@master kube-config] # kubectl apply-f rbac/heapster-rbac.yaml clusterrolebinding.rbac.authorization.k8s.io/heapster created4. For resources, see [root@master kube-config] # kubectl get all-n kube-system-o wide | grep-e monitor-e heapster

Third, Grafana configuration 1. Log in to grafana

Login address: http://172.27.9.131:30011

two。 Configure DataSource

Url is http://172.27.9.131:30012

3. Import template

Template download

Download address: https://grafana.com/api/dashboards/3649/revisions/1/download,

Https://grafana.com/api/dashboards/3646/revisions/1/download

Import

Similarly, import kubernetes-node-statistics

4. Check Grafana

5. Delete resources [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

All configuration files in this article have been uploaded to github: https://github.com/loong576/heapster-influxdb-grafana/archive/master.zip

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report