Amazon EKS — Storage Classes

less than 1 minute read

Storage Classes

StorageClasses define how persistent volumes are provisioned. They specify the volume type, encryption, IOPS, and reclaim policy.


Default Storage Classes

$ kubectl get storageclass
NAME              PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE
gp2 (default)    kubernetes.io/aws-ebs   Delete          WaitForFirstConsumer

Create Custom Storage Classes

High-Performance (gp3 with custom IOPS)

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: fast-storage
provisioner: ebs.csi.aws.com
parameters:
  type: gp3
  iops: "10000"
  throughput: "500"
  encrypted: "true"
  fsType: ext4
reclaimPolicy: Retain    # Keep volume after PVC deletion
volumeBindingMode: WaitForFirstConsumer

Database (io2 for highest IOPS)

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: database-storage
provisioner: ebs.csi.aws.com
parameters:
  type: io2
  iops: "50000"
  encrypted: "true"
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer

Reclaim Policies

Policy Behavior
Delete (default) Volume deleted when PVC is deleted
Retain Volume kept (manual cleanup required)

Best practice: Use Retain for databases and important data.


Volume Binding Modes

Mode Behavior
Immediate Volume created as soon as PVC is created
WaitForFirstConsumer Volume created when pod is scheduled

Always use WaitForFirstConsumer for EBS to ensure AZ alignment.


Common Mistakes

Mistake Impact
Using Immediate binding with EBS AZ mismatch, pod can’t start
Delete reclaim on production data Data lost when PVC deleted
Not setting encrypted: "true" Compliance violation

What’s Next?

Stateful applications: StatefulSets & PVCs.