What You'll Build
In this lab you will deploy the complete kube-prometheus-stack on EKS using Helm, instrument the india-squad FastAPI application to expose Prometheus metrics, create a ServiceMonitor CRD for automatic scraping, and deploy a Grafana dashboard showing the four golden signals. You will verify the complete observability pipeline: application emits metrics, Prometheus scrapes them, and Grafana visualises them in a live dashboard.
By the end, any push to the GitOps repository that changes the application will be visible in Grafana within 30 seconds: request rate changes, latency distribution shifts, and error rate spikes all appear on the live dashboard without any manual configuration updates. The complete observability pipeline—application instrumentation, Prometheus scraping, and Grafana visualisation—will be managed as code in the GitOps repository.
Prerequisites
- EKS cluster with at least 3 t3.large nodes (kube-prometheus-stack requires approximately 4 GB of memory total across all components).
- gp3 StorageClass available in the cluster for Prometheus and Grafana persistent volumes—verify with kubectl get storageclass.
- The india-squad FastAPI application from Module 2 Exercise 13 deployed in the squad-prod namespace and accessible via a Kubernetes Service.
- Helm 3.x installed locally and the prometheus-community Helm repository accessible.
- The PrometheusRule from Exercise 34 ready to apply after Prometheus Operator is installed in the cluster.
Setup — Install kube-prometheus-stack
Install the kube-prometheus-stack Helm chart, which deploys Prometheus Operator, Prometheus with 15-day retention on gp3 EBS, Grafana with persistent storage, and Alertmanager with Slack notification routing. The `serviceMonitorSelector: {}` and `ruleSelector: {}` configurations with empty selectors instruct Prometheus to pick up ServiceMonitors and PrometheusRules from all namespaces, enabling application teams to define their own monitors without modifying the central Prometheus configuration.
# Install kube-prometheus-stack (Prometheus Operator + Grafana + Alertmanager)
# using Helm. This is the production-standard observability stack for EKS.
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
# Install with custom values for EKS
cat > kube-prometheus-values.yaml << 'EOF'
# ── Prometheus configuration ──────────────────────────────────────────────
prometheus:
prometheusSpec:
retention: 15d
retentionSize: 50GiB
storageSpec:
volumeClaimTemplate:
spec:
storageClassName: gp3
accessModes: [ReadWriteOnce]
resources:
requests:
storage: 50Gi
# Scrape all PrometheusRules in all namespaces
ruleSelector: {}
ruleNamespaceSelector: {}
# Scrape all ServiceMonitors in all namespaces
serviceMonitorSelector: {}
serviceMonitorNamespaceSelector: {}
# ── Grafana configuration ─────────────────────────────────────────────────
grafana:
persistence:
enabled: true
storageClassName: gp3
size: 10Gi
sidecar:
dashboards:
enabled: true
searchNamespace: ALL # load dashboards from ConfigMaps in all namespaces
adminPassword: 'india-squad-grafana-admin' # change in production!
# ── Alertmanager configuration ────────────────────────────────────────────
alertmanager:
config:
route:
group_by: [alertname, service]
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
receiver: default
receivers:
- name: default
slack_configs:
- api_url: '${SLACK_WEBHOOK_URL}'
channel: '#india-squad-alerts'
title: '{{ .CommonLabels.alertname }}'
text: '{{ range .Alerts }}{{ .Annotations.description }}{{ end }}'
EOF
helm upgrade --install kube-prometheus-stack prometheus-community/kube-prometheus-stack \
--namespace monitoring --create-namespace \
--values kube-prometheus-values.yaml \
--wait --timeout 10m
# Verify all components are running
kubectl get pods -n monitoring