Amazon EKS — EBS CSI Driver
EBS CSI Driver
Amazon EBS (Elastic Block Store) provides block-level storage volumes for EC2 instances. The EBS CSI driver lets Kubernetes dynamically create and attach EBS volumes to pods.
How EBS Works with EKS
EBS CSI Driver Flow
┌────────────────────────────────────────────────────┐
│ │
│ 1. Pod requests PVC │
│ 2. CSI driver calls AWS API │
│ 3. EBS volume created in same AZ as node │
│ 4. Volume attached to EC2 instance │
│ 5. Volume mounted into pod │
│ │
│ ┌────────┐ ┌──────────┐ ┌─────────────┐ │
│ │ Pod │────│ Node │────│ EBS Volume │ │
│ │ /data │ │ (EC2) │ │ (gp3, 50GB) │ │
│ └────────┘ └──────────┘ └─────────────┘ │
│ │
│ ⚠️ EBS is AZ-specific — volume and node must │
│ be in the same AZ │
└────────────────────────────────────────────────────┘
Install EBS CSI Driver
# Method 1: EKS managed addon (recommended)
$ aws eks create-addon \
--cluster-name demo \
--addon-name aws-ebs-csi-driver \
--service-account-role-arn arn:aws:iam::123456789012:role/AmazonEKS_EBS_CSI_DriverRole
# Method 2: eksctl
$ eksctl create addon --name aws-ebs-csi-driver --cluster demo \
--service-account-role-arn arn:aws:iam::123456789012:role/AmazonEKS_EBS_CSI_DriverRole
Create a StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ebs-gp3
provisioner: ebs.csi.aws.com
parameters:
type: gp3
fsType: ext4
encrypted: "true"
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer # Important!
WaitForFirstConsumerensures the volume is created in the same AZ as the pod. Without this, you get AZ mismatches.
Use EBS in a Pod
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-pvc
spec:
accessModes:
- ReadWriteOnce # EBS is single-node only
storageClassName: ebs-gp3
resources:
requests:
storage: 20Gi
---
apiVersion: v1
kind: Pod
metadata:
name: app
spec:
containers:
- name: app
image: nginx
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: data-pvc
EBS Volume Types
| Type | IOPS | Throughput | Cost | Use Case |
|---|---|---|---|---|
| gp3 | 3,000 baseline (up to 16,000) | 125 MB/s (up to 1,000) | $0.08/GB/mo | Default choice |
| gp2 | 3 per GB (up to 16,000) | 250 MB/s | $0.10/GB/mo | Legacy |
| io2 | Up to 64,000 | Up to 1,000 MB/s | $0.125/GB + $0.065/IOPS | Databases |
| st1 | N/A | Up to 500 MB/s | $0.045/GB/mo | Sequential reads |
Common Mistakes
| Mistake | Impact |
|---|---|
Not using WaitForFirstConsumer |
Volume and pod in different AZs |
| Forgetting IAM role for CSI driver | Can’t create volumes |
ReadWriteMany with EBS |
Not supported — use EFS |
| Not encrypting volumes | Security compliance failure |
What’s Next?
Shared storage: EFS CSI Driver.