The connection between node-exporter, prometheus, and grafana

1. node-exporter and node machine

It is used to collect the data information of the node machine, so where is the connection between node-exporter and the node machine?
node-exporter.yaml

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-exporter
  namespace: kube-system
  labels:
    k8s-app: node-exporter
spec:
  selector:
    matchLabels:
      k8s-app: node-exporter
  template:
    metadata:
      labels:
        k8s-app: node-exporter
    spec:
      containers:
      - image: prom/node-exporter
        name: node-exporter
        ports:
        - containerPort: 9100
          protocol: TCP
          name: http
      tolerations:
      - key: "node-role.kubernetes.io/master"
        operator: "Exists"
        effect: "NoSchedule"
---
apiVersion: v1
kind: Service
metadata:
  labels:
    k8s-app: node-exporter
  name: node-exporter
  namespace: kube-system
spec:
  ports:
  - name: http
    port: 9100
    nodePort: 31672
    protocol: TC
  type: NodePort
  selector:
    k8s-app: node-exporter

We can see the kind of node-exporter: DaemonSet
DaemonSet ensures that all (or some) Nodes run a copy of Pod. When a Node joins the cluster, a Pod is also added for them. These Pods are also recycled when a Node is removed from the cluster. that is, as long as

kubectl create -f node-exporter.yaml

node-exporter will automatically join each Node under k8s management. Automatic association eliminates the need for manual association.

Two, node-exporter and prometheus

Prometheus is used to store the data collected by node-exporte. Where is the connection between them?
First of all, we can see that node-exporter has opened port 31672
insert image description here
, so prometheus also listens to port 31672 when listening to node-exporter.
Then we configure the IP of node-exporter in the configmap.yaml file of prometheus.
insert image description here
Both the public network IP and the internal network IP can be used to access the communication here. The difference is not yet known.
Notice:
If you modify the configmap.yaml file, you need to do the following steps instead of just apply configmap.yaml

kubectl delete -f prometheus.svc.yml
kubectl delete -f prometheus.deploy.yml
kubectl delete -f configmap.yaml

Verify that the prometheus service no longer exists

kubectl get po -A

Recreate the prometheus service

kubectl create -f configmap.yaml
kubectl create -f prometheus.deploy.yml
kubectl create -f prometheus.svc.yml
kubectl get po -n kube-system

3. Prometheus and Grafana

Grafana is used to display the data stored by prometheus. The connection between them is simple and straightforward.
Configure the IP (master public network ip) + port of prometheus on the Data Source page of Grafana. You can read the data stored by prometheus and display the data in the form of a graph.
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/simpleness_/article/details/130988505