- Kubernetes 1.23+
- The aws-ebs-csi-driver installed.
This example shows you how to use EBS-backed generic ephemeral volumes in your cluster to have Kubernetes ensure volumes are created and deleted alongside their Pods. See Kubernetes documentation on generic ephemeral volume lifecycle and PersistentVolumeClaim for more information.
-
Deploy the provided pod on your cluster along with the
StorageClass
. Note that we do not create aPersistentVolumeClaim
:$ kubectl apply -f manifests pod/app created storageclass.storage.k8s.io/ebs-ephemeral-demo created
-
Validate the
PersistentVolumeClaim
Kubernetes created on your behalf is bound to aPersistentVolume
.$ kubectl get pvc app-persistent-storage NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS ebs-claim Bound pvc-9124c6d0-382a-49c5-9494-bcb60f6c0c9c 1Gi RWO ebs-ephemeral-demo
-
Validate the pod successfully wrote data to the volume:
$ kubectl exec app -- cat /data/out.txt Fri Jan 24 17:15:42 UTC 2025 ...
-
Cleanup resources:
$ kubectl delete -f manifests pod "app" deleted storageclass.storage.k8s.io "ebs-ephemeral-demo" deleted
-
Validate that Kubernetes deleted the
PersistentVolumeClaim
and released thePersistentVolume
on your behalf:$ kubectl get pvc app-persistent-storage Error from server (NotFound): persistentvolumeclaims "app-persistent-storage" not found $ kubectl get pv <PV_NAME> Error from server (NotFound): persistentvolumes "pvc-9124c6d0-382a-49c5-9494-bcb60f6c0c9c" not found