helm uninstall prometheus -n monitoring || true
kubectl delete ns monitoring --grace-period=0 --force || truekubectl get pvc -A | grep prometheus | awk '{print $2, $1}' | while read pvc ns; do
kubectl delete pvc "$pvc" -n "$ns" --grace-period=0 --force || true
donekubectl delete storageclass gp3 --ignore-not-foundkubectl patch storageclass gp2 -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'kubectl get sc
kubectl get ns | grep monitoring
kubectl get pvc -AExpected:
- Only
gp2 (default)in storage class. - No monitoring namespace or PVCs related to Prometheus.
kubectl create ns monitoringcat <<EOF > values.yaml
server:
persistentVolume:
enabled: true
size: 8Gi
alertmanager:
enabled: true
persistentVolume:
enabled: true
size: 2Gi
mountPath: /data
EOFhelm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm search repo prometheus-community # --> to list the all charts
helm template prometheus-community/prometheus #--> It will what k8s objects will deploy through charthelm upgrade --install prometheus prometheus-community/prometheus \
-n monitoring \
-f values.yamlkubectl get all -n monitoring
kubectl get pvc -n monitoring
kubectl get scExpected Output:
- All Prometheus and Alertmanager pods should be
Running - PVCs for both
prometheus-serverandalertmanagershould beBound - Storage class in use should be
gp2
# change ClusterIp to LoadBalancer
kubectl edit svc <svcName> -n <ns># change ClusterIp to LoadBalancer
kubectl edit svc <svcName> -n <ns>| Resource | Status |
|---|---|
| StorageClass | gp2 (default) |
| Prometheus PVC | Bound |
| Alertmanager PVC | Bound |
| Prometheus Pod | Running |
| Alertmanager Pod | Running |