Skip to content

Prometheus Helm deployment

Prometheus is a widely used open-source monitoring and alerting toolkit, often deployed on Kubernetes to track cluster health and application performance.^[400-devops-03-containerization-prometheus.md]

Deployment via Helm

Deploying Prometheus is streamlined using the official community Helm chart.^[400-devops-03-containerization-prometheus.md] The process involves adding the repository, updating the local index, and installing the chart.

Prerequisites and Commands

The following commands are used to install the prometheus-community chart and deploy the release named prometheus to the default namespace^[400-devops-03-containerization-prometheus.md]:

[Helm](<./helm.md>) repo add prometheus-community https://prometheus-community.github.io/helm-charts
[Helm](<./helm.md>) repo update
[Helm](<./helm.md>) install [Prometheus](<./prometheus.md>) prometheus-community/[Prometheus](<./prometheus.md>)

Upon successful deployment, Helm outputs installation notes providing internal DNS names and instructions for accessing the various components^[400-devops-03-containerization-prometheus.md].

Deployed Components

The default Helm chart deployment creates several distinct resources within the Kubernetes cluster^[400-devops-03-containerization-prometheus.md]:

  • Prometheus Server: The core monitoring service.
    • Internal Access: prometheus-server.default.svc.cluster.local^[400-devops-03-containerization-prometheus.md]
    • Port Forwarding Command:
      export POD_NAME=$([kubectl get pods](<./kubectl-get-pods.md>) --namespace default -l "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")
      [kubectl](<./kubectl.md>) --namespace default port-forward $POD_NAME 9090
      
  • Alertmanager: Handles alerts sent by the Prometheus server.
    • Internal Access: prometheus-alertmanager.default.svc.cluster.local^[400-devops-03-containerization-prometheus.md]
    • Port Forwarding Command:
      export POD_NAME=$([kubectl get pods](<./kubectl-get-pods.md>) --namespace default -l "app=prometheus,component=alertmanager" -o jsonpath="{.items[0].metadata.name}")
      [kubectl](<./kubectl.md>) --namespace default port-forward $POD_NAME 9093
      
  • Pushgateway: A middleware for accepting pushed Metrics.
    • Internal Access: prometheus-pushgateway.default.svc.cluster.local^[400-devops-03-containerization-prometheus.md]
  • Node Exporter: Deploys as a DaemonSet to collect hardware Metrics from nodes^[400-devops-03-containerization-prometheus.md].
  • Kube-State-Metrics: Generates Metrics about Kubernetes objects^[400-devops-03-containerization-prometheus.md].

Integration with Grafana

To visualize the Metrics collected by Prometheus, it is common to deploy Grafana via its corresponding Helm chart^[400-devops-03-containerization-prometheus.md].

Configuration

Grafana requires the Prometheus server URL to function as a data source. Using the cluster IP or the internal DNS name resolves the connection^[400-devops-03-containerization-prometheus.md]:

  • Cluster IP: http://10.111.94.209:80 (example IP)
  • Internal DNS: http://prometheus-server:80

Dashboard Importation

Users can enhance monitoring by importing pre-built dashboards. A commonly referenced dashboard ID for Kubernetes monitoring is 6417^[400-devops-03-containerization-prometheus.md]. Dashboards can be browsed and selected from the official Grafana Labs dashboard repository^[400-devops-03-containerization-prometheus.md].

Sources

  • 400-devops-03-containerization-prometheus.md