Table of Contents


Prerequisites

Before you begin, ensure the following tools are installed and configured:

  • Kubernetes cluster (v1.23+) with kubectl access
  • Helm (v3.8+) — Install Helm
  • kubectl configured to point to your target cluster
  • Sufficient cluster resources (recommended: 2 CPU cores, 4 GB RAM minimum)

Verify your tools:

kubectl version --client
helm version
kubectl cluster-info

1. Add the Prometheus Community Helm Repository

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update

Verify the repo was added:

helm search repo prometheus-community

2. Choose Your Chart

The prometheus-community repository provides several charts. The two most common are:

ChartDescription
prometheus-community/prometheusPrometheus only (server, alertmanager, node-exporter)
prometheus-community/kube-prometheus-stackFull stack: Prometheus + Grafana + Alertmanager + exporters

This guide covers the prometheus chart. For the full stack, see the kube-prometheus-stack docs.


3. Create a Namespace

kubectl create namespace monitoring

4. Install Prometheus with Default Values

For a quick installation with defaults:

helm install prometheus prometheus-community/prometheus \
  --namespace monitoring

This deploys:

  • Prometheus server
  • Alertmanager
  • Node Exporter (DaemonSet on all nodes)
  • Kube State Metrics
  • Pushgateway

5. Custom Configuration via values.yaml

It is strongly recommended to use a custom values.yaml file to control your deployment. Pull the default values first:

helm show values prometheus-community/prometheus > values.yaml

Key Configuration Sections

5.1 Prometheus Server

server:
  # Resource limits and requests
  resources:
    limits:
      cpu: 500m
      memory: 512Mi
    requests:
      cpu: 250m
      memory: 256Mi
 
  # Data retention
  retention: "15d"
  retentionSize: "10GB"
 
  # Persistent storage
  persistentVolume:
    enabled: true
    size: 20Gi
    storageClass: "standard"   # Replace with your StorageClass
 
  # Replica count (use 1 unless using HA setup)
  replicaCount: 1
 
  # Global scrape config
  global:
    scrape_interval: 15s
    evaluation_interval: 15s
    scrape_timeout: 10s

5.2 Alertmanager

alertmanager:
  enabled: true
 
  resources:
    limits:
      cpu: 100m
      memory: 128Mi
    requests:
      cpu: 50m
      memory: 64Mi
 
  persistentVolume:
    enabled: true
    size: 2Gi
 
  config:
    global:
      resolve_timeout: 5m
    route:
      group_by: ['alertname', 'namespace']
      group_wait: 30s
      group_interval: 5m
      repeat_interval: 12h
      receiver: 'default'
    receivers:
      - name: 'default'
        slack_configs:
          - api_url: 'https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK'
            channel: '#alerts'
            send_resolved: true

5.3 Node Exporter

nodeExporter:
  enabled: true
 
  resources:
    limits:
      cpu: 200m
      memory: 50Mi
    requests:
      cpu: 100m
      memory: 30Mi
 
  tolerations:
    - key: node-role.kubernetes.io/master
      effect: NoSchedule

5.4 Kube State Metrics

kube-state-metrics:
  enabled: true
 
  resources:
    limits:
      cpu: 100m
      memory: 128Mi
    requests:
      cpu: 10m
      memory: 32Mi

5.5 Pushgateway

pushgateway:
  enabled: true
 
  resources:
    limits:
      cpu: 10m
      memory: 32Mi
    requests:
      cpu: 10m
      memory: 32Mi

5.6 Adding Custom Scrape Configs

Add custom scrape jobs under serverFiles:

serverFiles:
  prometheus.yml:
    scrape_configs:
      # Default Kubernetes scrape jobs are included automatically.
      # Add your custom targets below:
 
      - job_name: 'my-app'
        static_configs:
          - targets: ['my-app-service.default.svc.cluster.local:8080']
        metrics_path: /metrics
        scrape_interval: 30s
 
      - job_name: 'external-service'
        static_configs:
          - targets: ['192.168.1.100:9100']

5.7 Ingress (Optional)

Expose Prometheus via an Ingress controller:

server:
  ingress:
    enabled: true
    ingressClassName: nginx
    annotations:
      nginx.ingress.kubernetes.io/rewrite-target: /
    hosts:
      - prometheus.example.com
    paths:
      - /
    tls:
      - secretName: prometheus-tls
        hosts:
          - prometheus.example.com

6. Install with Custom Values

helm install prometheus prometheus-community/prometheus \
  --namespace monitoring \
  --values values.yaml

Or override individual values inline without a file:

helm install prometheus prometheus-community/prometheus \
  --namespace monitoring \
  --set server.retention=30d \
  --set server.persistentVolume.size=50Gi \
  --set alertmanager.enabled=true

7. Verify the Deployment

Check that all pods are running:

kubectl get pods -n monitoring

Expected output:

NAME                                            READY   STATUS    RESTARTS   AGE
prometheus-alertmanager-xxx                     1/1     Running   0          1m
prometheus-kube-state-metrics-xxx               1/1     Running   0          1m
prometheus-node-exporter-xxx (per node)         1/1     Running   0          1m
prometheus-pushgateway-xxx                      1/1     Running   0          1m
prometheus-server-xxx                           2/2     Running   0          1m

Check services:

kubectl get svc -n monitoring

8. Access the Prometheus UI

If you did not configure an Ingress, use port-forwarding:

kubectl port-forward -n monitoring svc/prometheus-server 9090:80

Then open your browser at: http://localhost:9090

For Alertmanager:

kubectl port-forward -n monitoring svc/prometheus-alertmanager 9093:80

9. Upgrading Prometheus

When you update values.yaml or want a new chart version:

helm upgrade prometheus prometheus-community/prometheus \
  --namespace monitoring \
  --values values.yaml

To upgrade to a specific chart version:

helm upgrade prometheus prometheus-community/prometheus \
  --namespace monitoring \
  --values values.yaml \
  --version 25.21.0

10. Uninstalling Prometheus

helm uninstall prometheus --namespace monitoring

⚠️ Note: This does not delete PersistentVolumeClaims (PVCs). Delete them manually if needed:

kubectl delete pvc -n monitoring -l app=prometheus

11. Common Troubleshooting

Pods not starting

kubectl describe pod <pod-name> -n monitoring
kubectl logs <pod-name> -n monitoring

Prometheus not scraping a target

Open the Prometheus UI → Status → Targets to see which targets are UP or DOWN, and review the error message shown.

Persistent volume not binding

kubectl get pvc -n monitoring
kubectl describe pvc <pvc-name> -n monitoring

Ensure a matching StorageClass exists:

kubectl get storageclass

Check the Helm release status

helm status prometheus -n monitoring
helm get values prometheus -n monitoring

12. Useful References