Why Your Unused PersistentVolumes Are Probably Orphaned in 1.37 (And How to Audit Them)
Why Your Unused PersistentVolumes Are Probably Orphaned in 1.37 (And How to Audit Them): hands-on walkthrough with commands, expected outputs and a checklist.
Aicademy’s FinOps dashboard triggered a critical alert on Tuesday morning: cloud storage costs spiked 40% week-over-week despite active ingress traffic staying completely flat. The infrastructure team had scaled down several stateful staging pipelines, but the underlying AWS EBS blocks never vanished. They remained bound in the cluster storage layer, silently burning cloud credits while mounted to nothing.
TL;DR: Orphaned storage volumes accumulate rapidly when StatefulSets scale down or delete without custom reclamation logic. Kubernetes 1.37.1 standardizes controller metrics for tracking unmounted volumes, exposing unattached disks directly through the API. This audit gives you the exact commands to catch zombie storage, snapshot it, and reclaim provider capacity today.
What you’ll walk away with:
- A repeatable 5-minute shell audit to isolate detached storage volumes.
- Direct methods to query Kubernetes 1.37.1 storage controller metrics.
- A baseline safety checklist for snapshotting and purging unattached resources.
- A scoring rubric to grade your cluster storage hygiene.
Why Do Kubernetes PersistentVolumes Become Orphaned?
PersistentVolumes become orphaned when their associated workloads scale to zero or delete while the persistentVolumeReclaimPolicy remains configured as Retain. Under this configuration, the Kubernetes control plane releases the pod mount point but keeps the cloud storage disk allocated to prevent accidental data loss.
An orphaned PersistentVolume is a provisioned cloud storage block that remains bound to an unreferenced claim or detached node path while continuing to accrue provider infrastructure charges. If you previously reviewed 5 Kubernetes 1.37 PersistentVolume Claim Myths Costing You Storage IOPS, you know that default storage classes rarely automate volume garbage collection across dynamic staging namespaces.
flowchart LR
A["StatefulSet Deletion"] --> B["Pod Terminates"]
B --> C["PVC Retained in Namespace"]
C --> D["PV Status: Released or Bound"]
D --> E["AWS EBS Volume Left In-Use/Available"]
E --> F["Monthly Cloud Invoice Accumulates"]
When a StatefulSet replica scales down, the underlying claim stays behind by design. The aws-ebs-csi-driver unpublishes the volume from the node, but AWS keeps billing for the provisioned GiB and IOPS indefinitely.
Set
reclaimPolicy: Deleteon dynamic storage classes used strictly for ephemeral and staging environments.
How Do You Audit Orphaned Volumes in Kubernetes 1.37?
Run this audit in 5 minutes. Kubernetes 1.37.1 provides native controller metrics and attachment status endpoints that let you isolate released, failed, and unmounted persistent storage without third-party agents.
Step 1: Export all released and unmounted PersistentVolumes
Run this command to find all volumes stuck in a non-bound state or detached status:
1
kubectl get pv -o jsonpath='{range .items[?(@.status.phase!="Bound")]}{.metadata.name}{"\t"}{.status.phase}{"\t"}{.spec.claimRef.namespace}{"/"}{.spec.claimRef.name}{"\n"}{end}'
1
2
pvc-a0b1c2d3-137a-4b92-91ef-001 Released staging-aicademy/data-redis-shard-0
pvc-f4e5d6c7-137b-4c93-92fe-002 Failed analytics/clickhouse-buffer-0
Step 2: Identify Bound PVCs with zero active consumers
Extract claims where no running pod references the claim UID:
1
2
3
4
5
6
kubectl get pvc --all-namespaces -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{.spec.volumeName}{"\n"}{end}' | while read -r ns claim pv; do
pods=$(kubectl get pods -n "$ns" -o json | jq -r --arg claim "$claim" '.items[] | select(.spec.volumes[]?.persistentVolumeClaim.claimName == $claim) | .metadata.name')
if [ -z "$pods" ]; then
echo "Dangling: Namespace=${ns} Claim=${claim} PV=${pv}"
fi
done
1
2
Dangling: Namespace=staging-aicademy Claim=data-backend-cache-0 PV=pvc-87612345-137c-4d94-93ff-003
Dangling: Namespace=ci-runners Claim=workspace-job-9842 PV=pvc-11223344-137d-4e95-94aa-004
Step 3: Query the CSI VolumeAttachment API
Confirm whether the storage driver still keeps the raw block attached to an instance:
1
kubectl get volumeattachments -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.nodeName}{"\t"}{.spec.source.persistentVolumeName}{"\t"}{.status.attached}{"\n"}{end}'
1
2
csi-ebs-attach-01 ip-10-0-12-42.ec2.internal pvc-87612345-137c-4d94-93ff-003 false
csi-ebs-attach-02 ip-10-0-12-88.ec2.internal pvc-55667788-137e-4f96-95bb-005 true
Step 4: Check cluster-wide controller metrics
Examine the volume_manager_total_volumes metric on your nodes to detect unmounted storage loops:
1
kubectl get --raw /metrics | grep "volume_manager_total_volumes" | head -n 4
1
2
3
4
# HELP volume_manager_total_volumes [ALPHA] Number of volumes in Volume Manager
# TYPE volume_manager_total_volumes gauge
volume_manager_total_volumes{plugin_name="kubernetes.io/csi/ebs.csi.aws.com",state="desired_state_of_world"} 12
volume_manager_total_volumes{plugin_name="kubernetes.io/csi/ebs.csi.aws.com",state="actual_state_of_world"} 8
Step 5: Tally the wasted allocation
Sum the total gigabytes wasted across dangling claims:
1
kubectl get pv -o json | jq '[.items[] | select(.status.phase != "Bound" or .spec.claimRef == null) | .spec.capacity.storage | rtrimstr("Gi") | tonumber] | add // 0'
1
1450
Scoring Rubric
- 0 findings (0 GiB unattached): Pristine cluster storage hygiene.
- 1–3 findings (< 250 GiB): Normal lifecycle drift; clean up during standard sprints.
- 4–10 findings (250–1000 GiB): Moderate budget leak; manual reclamation required this week.
- 11+ findings (> 1000 GiB): Critical leakage; dynamic provisioners or workflows lack lifecycle policies.
Audit
VolumeAttachmentsdirectly through the API rather than scraping cloud provider consoles to get real-time state.
What Is the Recommended Cleanup Strategy for Dangling PVCs?
The recommended cleanup strategy requires creating a VolumeSnapshot before deleting the claim, followed by patching the reclaim policy on the PersistentVolume to prevent storage provider locks. This guarantees data recovery while permanently unlinking the billed cloud block from your monthly budget.
Ensure node operations remain stable during volume detachment by verifying node memory states, as detailed in The Kubernetes 1.37 cgroup v2 Re-Architecture That Silently Alters Node Memory Management. Unclean volume unmounts can stall node processes if page caches are under kernel eviction pressure.
| Strategy | Speed | Data Safety | Operational Overhead | Winner |
|---|---|---|---|---|
| Direct PVC Deletion | Instant | Low (Permanent data loss risk) | Low | Testing Clusters Only |
| Snapshot-First Purge | Under 2 minutes | High (Full point-in-time image) | Moderate | Production Workloads |
| Manual Reclaim Patching | Slow | High (Leaves volume untouched) | High | Forensic Analysis |
Execute a snapshot before deletion using a standard manifest:
1
2
3
4
5
6
7
8
9
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: pre-purge-data-backend-cache-0
namespace: staging-aicademy
spec:
volumeSnapshotClassName: csi-aws-vsc
source:
persistentVolumeClaimName: data-backend-cache-0
Review this operational checklist before removing unused storage blocks:
- Confirm no CronJobs or offline StatefulSets reference the target PVC.
-
Verify
VolumeSnapshotstatus displaysreadyToUse: true. -
Patch the target PV reclaim policy to
Deleteif the cloud disk should be removed immediately. - Delete the dangling PVC to signal the CSI driver.
- Verify in the cloud provider console that the volume ID shows terminated or deleted.
Read the official Kubernetes Resource Management Documentation to align your retention rules with cluster quotas.
Always take a VolumeSnapshot before running destructive volume deletions, even on staging volumes.
In the next part of the series, we will examine how CSI VolumeAttributesClasses in Kubernetes 1.37 let you dynamically alter IOPS and throughput without recreation.
Bottom Line
Orphaned storage is entirely avoidable through strict reclaim policies and scheduled detachment checks. Run the 5-step shell audit against your non-production clusters today to eliminate unattached storage costs. Transition all automated staging pipelines to use reclaimPolicy: Delete immediately.
FAQ
Why does a PersistentVolume stay Bound after deleting a deployment?
Deployments do not manage storage directly; they delegate volume binding to PersistentVolumeClaims. Deleting a deployment removes the consumer pods, but the PersistentVolumeClaim remains bound to its PersistentVolume until deleted explicitly.
Does Kubernetes automatically delete EBS volumes when namespaces are destroyed?
Kubernetes deletes dynamic EBS volumes during namespace destruction only if the storage class sets reclaimPolicy: Delete. If the storage class uses reclaimPolicy: Retain, the PersistentVolume changes to Released status and the underlying AWS disk continues to incur charges.
How do you identify which AWS EBS volume corresponds to a Kubernetes PV?
Run kubectl get pv <pv-name> -o jsonpath='{.spec.csi.volumeHandle}' to extract the volume handle. For clusters using the AWS EBS CSI driver, this command prints the AWS EBS volume ID (e.g., vol-0123456789abcdef0).
Can a detached PersistentVolume degrade cluster control plane performance?
Detached volumes do not impact API latency in small numbers, but hundreds of abandoned claims swell etcd database size and increase CSI attachment reconciliation loops. The Kube-Controller-Manager periodically scans all VolumeAttachment objects, adding unneeded CPU cycles when managing excessive dangling resources.
Part of the series: k8s-1-37-series
- 5 Kubernetes 1.37 PersistentVolume Claim Myths Costing You Storage IOPS
- The Kubernetes 1.37 cgroup v2 Re-Architecture That Silently Alters Node Memory Management
- Why Your Unused PersistentVolumes Are Probably Orphaned in 1.37 (And How to Audit Them) (you are here)
- Recover Your Stateful Workloads in 10 Minutes After a Kubernetes 1.37 Bind Mount Failure
Further Reading
- https://kubernetes.io/blog/2026/08/26/kubernetes-v1-37-release/
- https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/
- https://github.com/kubernetes-sigs/aws-ebs-csi-driver
🚀 Ready to get hands-on? Spin up an interactive AI or Kubernetes Sandbox at Aicademy Labs for free.
