Chapter 17 of 24

Persistent Storage on EKS

Make the CSI driver, encryption key, scheduler, snapshot, and restore lifecycle explicit.

01Learning objectives

02Schedule first, provision second

WaitForFirstConsumer delays provisioning until scheduling provides topology. Immediate binding can create a volume in an Availability Zone where the pod cannot run.

Ownership: Terraform/OpenTofu owns the EBS CSI Pod Identity role and EKS managed add-ons. Argo owns the StorageClass and VolumeSnapshotClass. Applications later own PVCs and VolumeSnapshots.

03Storage is durable, not magically available

ConcernCourse choiceWhy it matters
Volume typegp3Capacity and baseline performance are not tied as tightly as gp2; tune IOPS/throughput only from measurements.
Encryptionencrypted: "true" plus workload KMS aliasPrevents accidental use of an account default key outside this workload boundary.
BindingWaitForFirstConsumerScheduler and CSI agree on the Availability Zone.
ReclaimRetainDeleting a PVC does not immediately delete production data; cleanup becomes explicit.
Snapshot deletionRetainDeleting a Kubernetes snapshot object does not silently delete the AWS recovery point.
Snapshots are not HA. A point-in-time copy can support recovery, but it does not keep a service available during a node, zone, application, or operator failure. Crash consistency also differs from application-consistent backup.

04Lab: inspect storage without applying it

# Terraform mocked plan
terraform -chdir=learn-terraform/capstone/infra/modules/eks test \
  -filter=tests/eks.tftest.hcl

# OpenTofu mocked plan
tofu -chdir=learn-terraform/capstone/infra/modules/eks test \
  -filter=tests/eks.tftest.hcl

# Static manifest checks
yamllint learn-terraform/capstone/gitops/platform/storage
rg 'gp3|encrypted|kmsKeyId|WaitForFirstConsumer|Retain' \
  learn-terraform/capstone/gitops/platform/storage

These commands do not create a PVC, EBS volume, or snapshot. A real restore belongs at a separately approved runtime checkpoint.

Clean-target restore sequence

  1. Quiesce writes or use the database's application-aware backup procedure before taking the snapshot.
  2. Create a new VolumeSnapshot reference and wait until readyToUse=true.
  3. Create a new PVC whose dataSource is that snapshot. Never overwrite or mutate the live PVC.
  4. Start a separate restore workload on the clean target and validate data before switching traffic.
  5. Keep the source volume and snapshot until acceptance checks and rollback time have passed.

05Terraform replacement and state review

Before approving an EKS plan, inspect both resource actions and state addresses:

# Pick one CLI and its state
terraform -chdir=learn-terraform/capstone/infra/stacks/eks plan -out=eks.tfplan
terraform -chdir=learn-terraform/capstone/infra/stacks/eks show eks.tfplan
terraform -chdir=learn-terraform/capstone/infra/stacks/eks state list

tofu -chdir=learn-terraform/capstone/infra/stacks/eks plan -out=eks.tfplan
tofu -chdir=learn-terraform/capstone/infra/stacks/eks show eks.tfplan
tofu -chdir=learn-terraform/capstone/infra/stacks/eks state list
Plan signalReview
EBS CSI role replacementExisting controller credentials can stop refreshing. Confirm association ordering and rollback.
Add-on version updateCheck EKS compatibility, CRDs, release notes, and node rollout impact.
KMS ARN changeNew volumes use the new key; existing volumes are not transparently re-encrypted.
StorageClass editNot in Terraform state. Review GitOps diff; many StorageClass fields are immutable after creation.

A Terraform or OpenTofu output can expose the KMS ARN, but marking it sensitive would only redact CLI display. Sensitive values still exist in state; key ARNs are identifiers, not key material.

!Failure drill

A restored PVC stays Pending. Confirm the snapshot is ready, CSI provisioner and snapshot class names match, the KMS role can create grants, and schedulable EC2 capacity exists in a compatible Availability Zone. Do not set nodeName; it bypasses scheduler logic required by WaitForFirstConsumer.

06Verify boundaries

07Cleanup

The chapter's tests leave no AWS resources. In an applied lab, list retained PVs, EBS volumes, and snapshots before deleting the cluster. Retain prevents accidental deletion, so it also requires a deliberate inventory and separately approved cleanup.

08Quick check

Why is an EBS snapshot not a replica?

It is a recovery point, not a serving copy that automatically receives new writes or handles traffic.

Why restore to a new PVC?

It preserves the source and gives validation and rollback a stable boundary before traffic switches.

Can Cassandra use this StorageClass?

Later, yes, on its dedicated EC2 nodes. Cassandra replication and repair provide service-level resilience; EBS snapshots remain one recovery mechanism.

09Recap and next

CSI add-ons and IAM live in Terraform/OpenTofu; topology and storage policy live in Argo. Encrypted volumes, retained snapshots, and a clean-target workflow make recovery reviewable.

Next: expose Envoy Gateway through one controller-owned private NLB without adding a second L7 proxy.

10Source notes