Skip to content

Latest commit

 

History

History

static-provisioning

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Static Provisioning

Prerequisites

  1. Kubernetes 1.13+ (CSI 1.0).
  2. The aws-ebs-csi-driver installed.
  3. Created an Amazon EBS volume.

Usage

This example shows you how to create and consume a PersistentVolume from an existing EBS volume with static provisioning.

  1. Edit the PersistentVolume manifest in pv.yaml to include your volumeHandle EBS volume ID and nodeSelectorTerms zone value.

    The StorageClass on the PersistentVolumeClaim and PersistentVolume must match. If you have a default storage class, this means you must explicitly set spec.storageClassName to "" in the PVC manifest if the PV doesn't have a StorageClass.

    The spec.volumeName field of the PVC must match the name of the PV for it to be selected.

    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}
  2. Deploy the provided pod on your cluster along with the PersistentVolume and PersistentVolumeClaim:

    $ kubectl apply -f manifests
    
    persistentvolumeclaim/ebs-claim created
    pod/app created
    persistentvolume/test-pv created
  3. Validate the PersistentVolumeClaim is bound to your PersistentVolume.

    $ kubectl get pvc ebs-claim
    
    NAME        STATUS   VOLUME    CAPACITY   ACCESS MODES   STORAGECLASS   AGE
    ebs-claim   Bound    test-pv   5Gi        RWO                           53s
  4. 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
    ...
  5. Cleanup resources:

    $ kubectl delete -f manifests
    
    persistentvolumeclaim "ebs-claim" deleted
    pod "app" deleted
    persistentvolume "test-pv" deleted