- Kubernetes 1.13+ (CSI 1.0).
- The aws-ebs-csi-driver installed.
- Created an Amazon EBS volume.
This example shows you how to create and consume a PersistentVolume
from an existing EBS volume with static provisioning.
-
Edit the
PersistentVolume
manifest in pv.yaml to include yourvolumeHandle
EBS volume ID andnodeSelectorTerms
zone value.apiVersion: v1 kind: PersistentVolume metadata: name: test-pv spec: accessModes: - ReadWriteOnce capacity: storage: 5Gi csi: driver: ebs.csi.aws.com fsType: ext4 volumeHandle: {EBS volume ID} nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: topology.ebs.csi.aws.com/zone operator: In values: - {availability zone}
-
Deploy the provided pod on your cluster along with the
PersistentVolume
andPersistentVolumeClaim
:$ kubectl apply -f manifests persistentvolumeclaim/ebs-claim created pod/app created persistentvolume/test-pv created
-
Validate the
PersistentVolumeClaim
is bound to yourPersistentVolume
.$ kubectl get pvc ebs-claim NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE ebs-claim Bound test-pv 5Gi RWO 53s
-
Validate the pod successfully wrote data to the statically provisioned volume:
$ kubectl exec app -- cat /data/out.txt Tue Feb 22 20:51:37 UTC 2022 ...
-
Cleanup resources:
$ kubectl delete -f manifests persistentvolumeclaim "ebs-claim" deleted pod "app" deleted persistentvolume "test-pv" deleted