Chapter 87: Prometheus and Grafana Monitoring
87.10 Lab — kube-prometheus-stack with Helm
Story. You help a PhonePe-style wallet API lab on kind. Budget notes stay in INR for class. Your job: install kube-prometheus-stack with Helm (skills from chapter 85), scrape a sample app with a ServiceMonitor, open Grafana, and fire a safe test alert into Alertmanager — without putting webhook secrets in Git.
Lab steps
- Confirm
kubectl get nodeson kind or Minikube. - Add the prometheus-community Helm repo using the official chart documentation (Artifact Hub / chart docs — do not invent random URLs).
- Create namespace
monitoringif needed. - Install release
kube-prometheus-stackintomonitoringwith Helm. Keep default admin passwords only for lab; change them. - Wait until Prometheus, Alertmanager and Grafana pods are Ready:
kubectl -n monitoring get pods. - Port-forward Prometheus
9090and open Status → Targets. - Deploy a tiny app with
/metricsand a Service that has a named metrics port. - Apply a ServiceMonitor with labels your Prometheus instance selects.
- Confirm the new target is UP. Query a metric in the Prometheus UI.
- Port-forward Grafana; log in with the Secret password; open Explore and graph that metric.
- Optional: add a PrometheusRule with
for: 1min lab, watch it appear in Alertmanager, then remove it.
What good looks like
- Prometheus Targets page shows kubelet/node exporters UP and your app UP.
- Grafana Explore draws your PromQL line.
- You can explain ServiceMonitor label matching to a friend.
- No Slack webhook or SMTP password appears in any Git commit.
Do the Helm install yourself. Watching a screenshot of Grafana is not the same as fixing an empty Targets list.
Helm install स्वतः करा. Grafana चा screenshot बघणे आणि रिकामी Targets list सोडवणे एक नाही.
Helm install खुद करें. Grafana का screenshot देखना और खाली Targets list ठीक करना एक नहीं है.
Did you understand? Let us try it once more.