Monitoring Setup
Prometheus and Grafana monitoring stack for the Kubernetes cluster.
Prerequisites
- Kubernetes cluster with Traefik Gateway API configured
- cert-manager with Let’s Encrypt ClusterIssuer
- Helm installed
Installation
# 1. Add Prometheus community Helm repo
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
# 2. Install kube-prometheus-stack
# Replace <your-password> with a secure password
helm install monitoring prometheus-community/kube-prometheus-stack \
-n monitoring --create-namespace \
--set grafana.adminPassword='<your-password>'
# 3. Create HTTPRoute for Grafana (uses wildcard cert, no per-app certificate needed)
kubectl apply -f - <<'EOF'
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: grafana
namespace: monitoring
spec:
parentRefs:
- name: traefik-gateway
namespace: traefik
sectionName: https # Uses wildcard listener
hostnames:
- grafana.app.domain.no
rules:
- backendRefs:
- name: monitoring-grafana
port: 80
EOFAccess
- Grafana: https://grafana.app.domain.no
- Username:
admin - Password: (set during installation)
- Username:
Included Components
The kube-prometheus-stack includes:
- Prometheus: Metrics collection and storage
- Grafana: Visualization and dashboards
- Alertmanager: Alert routing and notifications
- Node Exporter: Host-level metrics
- kube-state-metrics: Kubernetes object metrics
Pre-configured Dashboards
Grafana comes with dashboards for:
- Kubernetes cluster overview
- Node resources (CPU, memory, disk, network)
- Pod resources
- Namespace resources
- Persistent volumes
- API server metrics
Adding Custom Dashboards
Import dashboards from Grafana.com :
- Go to Grafana → Dashboards → Import
- Enter dashboard ID (e.g.,
15757for Kubernetes views) - Select Prometheus data source
- Click Import
Alerting (Optional)
Configure Alertmanager for notifications:
kubectl edit secret alertmanager-monitoring-kube-prometheus-alertmanager -n monitoringAdd Slack, email, or other notification channels in the alertmanager.yaml config.