Configure Storage Classes

What is StorageClass?

In Kubernetes, StorageClass is a way to define different storage service levels that the cluster supports. Instead of directly attaching a specific volume type to each PersistentVolumeClaim (PVC), you can use StorageClass to:

  • Specify the type of disk to use (e.g., gp2, gp3, io1… in AWS EBS)

  • Define reclaim policy (keep or delete volume after PVC is deleted)

  • Configure default size, zone (AZ), IOPS, etc.

Integration with Amazon EBS

As you know from the previous section, Kubernetes uses EBS CSI Driver to create and manage EBS volumes. For this to happen automatically, you need to define a StorageClass that uses EBS CSI Driver.

When a Pod creates PVC and specifies StorageClass, the CSI Driver will:

  1. Based on information in StorageClass to call AWS API to create volume.

  2. Attach that volume to the node containing the Pod.

  3. Automatically unmount and delete when no longer needed.

Configure StorageClass for EBS CSI Driver

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ebs-sc
provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumer