prometheus

title: Prometheus

system-architecture

This document demonstrates how to scrape metrics from edge node through Raven within an OpenYurt cluster, you can refer to the installation tutorial if Raven components are not deployed. Cloud and edge are usually in different network area, so the Raven project is needed to communicate across network area. Prometheus pull metrics of the resources and objects of the edge gateway node through the VPN built by raven agent, and the pull request of collecting non-gateway node metrics is forwarded by gateway node in the network area.

Environment

  • OpenYurt v1.2+

  • Raven v0.3.0+

  • Prometheus

If you don’t have an OpenYurt on hand, you can refer installation tutorial to create one or convert from an exist Kubernetes cluster.

Prometheus config

Prometheus uses IP by default to access the metric addresses of the nodes, and the Raven project has implemented communication across network area, so using Prometheus on the OpenYurt project is consistent with native k8s.

collect kubelet metrics

The function to collect node metrics from kubelet can be added by modifying the configmap of prometheus. For instance, prometheus collects metrics for the node through the read-only port 10255 that kubelet listens on by the relabel configuration:

  1. - job_name: 'kubelet'
  2. kubernetes_sd_configs:
  3. - role: node
  4. scheme: https
  5. tls_config:
  6. ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
  7. insecure_skip_verify: true
  8. authorization:
  9. credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  10. relabel_configs:
  11. - action: labelmap
  12. regex: __meta_kubernetes_node_label_(.+)
  13. - source_labels: [__address__]
  14. action: replace
  15. target_label: __address__
  16. regex: ([^:;]+):(\d+)
  17. replacement: ${1}:10255
  18. - source_labels: [__scheme__]
  19. action: replace
  20. target_label: __scheme__
  21. regex: https
  22. replacement: http

Note: If you also use read-only port 10255, please note that you configure kubelet to enable listening on port 10255, otherwise an error like the one shown in the figure will occur system-architecture