Prometheus PVC pending after launching multi‑GPU training pods
Problem
When a distributed multi‑GPU training job is started, the Prometheus instance that runs in the same namespace fails to start because its PersistentVolumeClaim (PVC) stays in the Pending phase. The training pods launch successfully, but Prometheus reports:
kubectl get pvc -n ml-monitoring
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
prometheus-data Pending - 100Gi RWO fast-ssd 2m
Consequences include missing metrics for GPU utilization, loss of alerting, and the training job’s ServiceMonitor never becomes ready.
Root Cause
The cluster uses a StorageClass that provisions gp2 volumes on an AWS EBS backend. The multi‑GPU training job requests nodeSelector and affinity rules that force the pod onto a specific set of GPU‑enabled nodes. Those nodes are labeled cloud.google.com/gke-accelerator=nvidia-tesla-v100 and are deliberately tainted with gpu=true:NoSchedule.
Prometheus is deployed with the default nodeSelector (no GPU selector) and no tolerations. The PVC is bound by the volumeBindingMode: WaitForFirstConsumer policy, which delays volume provisioning until a pod that uses the PVC is scheduled. Because the only pods that can consume the PVC are the Prometheus server pods, the scheduler tries to place them on a node that satisfies both the PVC’s storage class and the pod’s node constraints. Since Prometheus lacks the GPU toleration, the scheduler cannot find a node that satisfies both, and the PVC remains pending indefinitely.
In short: the PVC is waiting for a pod that can be scheduled, but the pod cannot be scheduled because it lacks the required GPU tolerations.
Debug
Step‑by‑step investigation that reproduced the failure:
-
Inspect PVC status and events:
kubectl describe pvc prometheus-data -n ml-monitoringRelevant excerpt:
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Provisioning 2m pvc-controller External provisioner is provisioning volume for claim "prometheus-data" Warning ProvisioningFailed 1m pvc-controller failed to provision volume with StorageClass "fast-ssd": timed out waiting for volume binding -
Check the Prometheus pod spec:
kubectl get pod -l app=prometheus -n ml-monitoring -o yamlKey sections:
spec: nodeSelector: {} tolerations: [] volumes: - name: storage persistentVolumeClaim: claimName: prometheus-data -
Verify node taints:
kubectl get nodes -l cloud.google.com/gke-accelerator=nvidia-tesla-v100 -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.taints}{"\n"}{end}'Output:
gpu-node-1 [{"key":"gpu","value":"true","effect":"NoSchedule"}] gpu-node-2 [{"key":"gpu","value":"true","effect":"NoSchedule"}] -
Confirm the StorageClass binding mode:
kubectl get sc fast-ssd -o yamlSnippet:
provisioner: ebs.csi.aws.com volumeBindingMode: WaitForFirstConsumer
Solution
Two complementary changes resolve the deadlock:
1. Add GPU tolerations to the Prometheus server pod
Update the Prometheus StatefulSet (or Deployment) to tolerate the gpu=true:NoSchedule taint. This allows the scheduler to place Prometheus on a GPU node, satisfying the PVC binding.
Before:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: prometheus
namespace: ml-monitoring
spec:
serviceName: prometheus
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
spec:
containers:
- name: prometheus
image: prom/prometheus:v2.45.0
volumeMounts:
- name: storage
mountPath: /prometheus
volumes:
- name: storage
persistentVolumeClaim:
claimName: prometheus-data
After (add tolerations):
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: prometheus
namespace: ml-monitoring
spec:
serviceName: prometheus
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
spec:
tolerations:
- key: "gpu"
operator: "Equal"
value: "true"
effect: "NoSchedule"
containers:
- name: prometheus
image: prom/prometheus:v2.45.0
volumeMounts:
- name: storage
mountPath: /prometheus
volumes:
- name: storage
persistentVolumeClaim:
claimName: prometheus-data
2. Change the StorageClass binding mode to Immediate
If running Prometheus on a GPU node is undesirable, switch the PVC to use a StorageClass with volumeBindingMode: Immediate. This provisions the volume before the pod is scheduled, removing the dependency on the pod’s node placement.
Before (original SC):
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast-ssd
provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumer
parameters:
type: gp2
fsType: ext4
After (new SC):
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast-ssd-immediate
provisioner: ebs.csi.aws.com
volumeBindingMode: Immediate
parameters:
type: gp2
fsSize: "100Gi"
fsType: ext4
Then recreate the PVC to bind to the new class:
kubectl delete pvc prometheus-data -n ml-monitoring
cat > pvc.yaml <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: prometheus-data
namespace: ml-monitoring
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Gi
storageClassName: fast-ssd-immediate
EOF
kubectl apply -f pvc.yaml
Verify
Confirm that the PVC transitions to Bound and that Prometheus starts:
kubectl get pvc prometheus-data -n ml-monitoring
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
prometheus-data Bound pvc-3f2b7c9e-8d4a-4a6e-b9c1-1f2e5d6a7b8c 100Gi RWO fast-ssd-immediate 1m
Check the pod status:
kubectl get pod -l app=prometheus -n ml-monitoring
NAME READY STATUS RESTARTS AGE
prometheus-0 2/2 Running 0 2m
Validate metrics collection by querying the Prometheus API:
curl -s http://prometheus.ml-monitoring.svc.cluster.local:9090/api/v1/query?query=up | jq .
Expected JSON snippet:
{
"status":"success",
"data":{
"resultType":"vector",
"result":[
{"metric":{"__name__":"up","job":"prometheus"},"value":[1698056400,"1"]}
]
}
}
Prevent
- Explicitly document node constraints for monitoring components. If a StorageClass uses
WaitForFirstConsumer, ensure all consumers have compatiblenodeSelectorandtolerations. - Prefer
Immediatebinding for infrastructure services. Metrics stores, logging agents, and databases rarely need to co‑locate with workload‑specific taints. - Automate PVC health checks. Add a
PrometheusRulethat alerts when any PVC staysPendingfor more than 2 minutes. - Use separate StorageClasses for workloads with special scheduling requirements. Keep a “fast‑ssd‑gpu” class for GPU‑tainted nodes and a generic “fast‑ssd‑standard” for other services.
- Version‑lock the CSI driver. Some older driver versions had a bug where
WaitForFirstConsumerignored tolerations; keep the driver up‑to‑date.
FAQ
- Why does the PVC stay pending only after I start a multi‑GPU job? The training job adds a
gpu=true:NoScheduletaint to the nodes it uses. Prometheus, lacking a matching toleration, cannot be scheduled on those nodes, so the PVC bound withWaitForFirstConsumernever finds a suitable consumer. - Can I keep Prometheus on non‑GPU nodes and still use the same PVC? Yes, by switching the StorageClass to
Immediateor by creating a separate PVC that uses a StorageClass withoutWaitForFirstConsumer. The volume will be provisioned regardless of pod placement. - Is adding a GPU toleration to Prometheus safe? Functionally it is safe; Prometheus does not use GPUs. The only impact is that the pod may be scheduled on a GPU node, which could increase node resource fragmentation. Evaluate node capacity before applying globally.
- How do I detect similar binding deadlocks in the future? Monitor the
kube_persistentvolumeclaim_status_phasemetric for a high count ofPendingPVCs and correlate withkube_pod_status_phasefor pods stuck inPending. Alert on a ratio threshold (e.g., >5 pending PVCs with no matching running pods). - What if I cannot modify the StorageClass because it is shared? Create a new StorageClass that copies the parameters of the original but sets
volumeBindingMode: Immediate, then point the Prometheus PVC to the new class.
Related Topic Hub: Observability Troubleshooting Hub