Environment Description:

The host name Operating System Version

ip

docker version kubelet version configuration note

master Centos 7.6.1810 172.27.9.131 Docker 18.09.6 V1.14.2

2C2G The master host
node01 Centos 7.6.1810 172.27.9.135 Docker 18.09.6 V1.14.2

2C2G The node node

node02 Centos 7.6.1810 172.27.9.136 Docker 18.09.6 V1.14.2

2C2G The node node

 

For details about k8s cluster deployment, see Centos7.6 deploying a k8s(v1.14.2) cluster

K8s learning materials see: basic concepts, Kubectl commands and data sharing

 

A list,

1. Heapster profile

Heapster is a native cluster monitoring solution of Kubernetes. Kubelet itself contains an agent named cAdvisor, which collects resource consumption of the entire node and all individual containers running on the node. Heapster runs as a POD on a node and exposes the service through the ordinary KubernetesService, making it externally accessible through a stable IP address. It collects data from all the CAdvisors in the cluster and exposes it through a single address.

Heapster groups data by Pod, stores it to preconfigured Backend and visually displays it. Backend supported by Heapster includes InfluxDB (displayed using Grafana) and Google Cloud Monitoring.

2. Introduction of lnfluxDB and Grafana

LnfluxDB is an open source timing database for storing application metrics and other monitoring data. Grafana is a data analysis and visualization suite with a slick Web console, also open source, that allows users to visualize data stored in InfluxDB and discover how an application’s resource usage behavior changes over time.

Two, heapster installation

1. Download the installation file and image

Installation file download:

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

or

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

You can download the installation file either way, but this article takes the second method

Image download and label

/ 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-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.4Copy the code

Note: This command is required for each node

2. Modify the installation file

[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 amount 0 drwxr-xr-x 2 root root 27 11月 30 2018 Google drwxr-xr-x 2 root root 68 October 22 15:00 InfluxDB drwxr-xr-x 2 root root 32 October 22 15:02 rbac drwxr-xr-x 2 root Root 38 November 30 2018 standalone drwxr-xr-x 2 root root 170 November 30 2018 standalone-test drwxr-xr-x 2 root root 145 November 30 2018 standalone-with-apiserver [root@master kube-config]# CD influxDB / [root@master influxDB]# ll total content 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 2294 10月 22 14:51 grafana. yaml-rw-r --r-- 1 root root 997 10月 22 14:51 Influxdb. yaml [root@master influxdb]# CD.. /rbac/ [root@master rbac]# ll total amount 4-rw-r --r-- 1 root root 263 10月 22 15:02 heapster-rbac.yamlCopy the code

Yaml, influxdb.yaml, heapster.yaml and heapster-rbac.yaml are respectively modified

Yaml, the port type is NodePort, and NodePort is 30011. You can access grafana.yaml by using http://NodeIp:30011

Yaml, port type is NodePort, NodePort is 30012, which is used by grafana configuration data source

Modify the source and sink parameters in heapster.yaml

Source: Specifies the data source

The source parameters

instructions

inClusterConfig

Use kube config in service accounts associated with heapster’s namespace (default: true)
kubeletPort

Specifies the port used by kubelet. The default is 10255

kubeletHttps

Whether to use HTTPS to connect to Kubelets (default: false)

insecure

Whether to use a security certificate (default: false)

auth

Safety certification

useServiceAccount Whether to use K8S security tokens (default: false)

Sink: specifies the back-end data store

Sink parameters

instructions

user

InfluxDB user, root by default

pw

Parameter Description Value InfluxDB Specifies the password. The default value is root

db

Database name, default k8S

retention

Default Duration of the infloxDB retention policy. The default value is 0, indicating unlimited
secure

Securely connect to InfluxDB(default: false)

insecuressl

Ignore SSL certificate validity (default: false)

withfields

InfluxDB fields(default: false)

cluster_name

Cluster names for different Cubernete clusters (default: default)

disablecountermetrics Disable receiving counter measures to feed into the database (default: false)

concurrency

Number of concurrent requests (default: 1)

Yaml: change the permission to cluster-admi

3. Perform the installation

[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 createdCopy the code

4. View resources

[root@master kube-config]# kubectl get all -n kube-system -o wide |grep -e monitor -e heapster    Copy the code

Grafana configuration

1. Login grafana

Login address: http://172.27.9.131:30011

2. Configure the DataSource

The url is http://172.27.9.131:30012

3. Import the template

Download the template

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

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

The import

Import kubernetes-node-statistics

Look at Grafana

5. Resource deletion

[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 Copy the code

All configuration files for this article have been uploaded to github: heapster-grafana

Welcome to pay attention to my public number: Linux operation and maintenance practice, pay attention to cloud computing, containers, K8S, big data, etc., you want dry goods are here!

– If you are interested in my thematic content, you can also follow my blog: Loong576’s blog