Post

Prometheus

Prometheus

Prometheus

Cluster-monitoring Prometheus, deployed to the default namespace of the k3s cluster alongside the rest of the homelab’s apps. It scrapes the Kubernetes API server, kubelet node metrics, cAdvisor container metrics, and any Service/Pod annotated for scraping, then feeds the existing Grafana deployment via file-based provisioning.

Deployment

ItemValue
Namespacedefault
Imageprom/prometheus:latest
Port9090
Ingressprometheus.prod-k3s.iot-proxmox.net (Traefik IngressRoute, TLS)
StoragePVC prometheus-data, 10Gi, local-path
Retention15 days (--storage.tsdb.retention.time=15d)
ServiceAccountprometheus (ClusterRole: read nodes/services/endpoints/pods + /metrics)

reloader.stakater.com/auto: "true" is set on the Deployment, so it restarts automatically when its ConfigMap changes.

Scrape Targets

Configured via a ConfigMap-mounted prometheus.yml:

  • kubernetes-apiservers — the API server itself, via the in-cluster service account token.
  • kubernetes-nodes — kubelet /metrics on every node, proxied through the API server.
  • kubernetes-nodes-cadvisor — per-node container metrics via the kubelet’s cAdvisor proxy; this is what the Grafana dashboard below is built on.
  • kubernetes-service-endpoints / kubernetes-pods — any Service or Pod carrying prometheus.io/scrape: "true" (and optional prometheus.io/path / prometheus.io/port) annotations is picked up automatically.

No kube-state-metrics is deployed — the cAdvisor scrape alone is enough for the dashboard in use.

Grafana Integration

Three ConfigMaps are mounted into the existing Grafana deployment (not a separate Grafana install):

ConfigMapMounted atPurpose
grafana-datasource-prometheus/etc/grafana/provisioning/datasourcesRegisters Prometheus (http://prometheus.default.svc.cluster.local:9090) as the default datasource
grafana-dashboard-provider/etc/grafana/provisioning/dashboardsTells Grafana to load any dashboard JSON dropped into /var/lib/grafana/dashboards into a “Kubernetes” folder
grafana-dashboard-315/var/lib/grafana/dashboardsThe actual dashboard JSON

The dashboard is grafana.com dashboard 315 (“Kubernetes cluster monitoring via Prometheus”), with two local patches:

  • ${DS_PROMETHEUS} replaced with the literal datasource name Prometheus, since file-based provisioning skips the UI import’s __inputs substitution.
  • The filesystem-usage panels’ device filter changed from the dashboard default (^/dev/[sv]da\d+$) to ^/dev/nvme0n1p2$ — the actual root device on all three cluster nodes (cm4-left, cm4-middle, cm4-right).

Notes

  • If a node with a different root device is added to the cluster, the container_fs_* queries in the dashboard JSON need widening (e.g. to ^/dev/(nvme\d+n\d+p\d+|[sv]da\d+)$) and the dashboard ConfigMap re-applied.
  • Retention (15d) and the PVC size (10Gi) should be revisited together if the cluster’s metric cardinality grows.
This post is licensed under CC BY 4.0 by the author.