Kubernetes Storage in Production (AWS EKS Focus)
Kubernetes storage is one of the most critical pillars of production-grade container orchestration. Stateless applications are easy to deploy, but real-world systems require persistent data — databases, logs, analytics, ML pipelines, CI/CD artifacts, etc.
Kubernetes abstracts storage complexity through its Container Storage Interface (CSI) and resource objects like Volumes, PersistentVolumes, PersistentVolumeClaims, StorageClasses, and Dynamic Provisioning.
This article provides a deep, sequential understanding of Kubernetes storage from fundamentals to production-ready AWS EKS implementation.
1. Why Storage in Kubernetes?
Containers are ephemeral by nature. When a Pod dies:
Files written inside the container are lost.
Application state disappears.
Databases become unusable.
Therefore Kubernetes introduces Persistent Storage Abstractions to decouple data lifecycle from Pod lifecycle.
Core Goals:
Durability
Scalability
Portability
Performance
Isolation
2. Kubernetes Volume – The Foundation
A Volume is the basic storage unit mounted inside a Pod.
Unlike container filesystem, Volume survives container restarts within the same Pod.
Key Characteristics
Defined in Pod spec
Shared among containers in same Pod
Deleted when Pod is deleted
Example – emptyDir Volume
apiVersion: v1
kind: Pod
metadata:
name: emptydir-demo
spec:
containers:
- name: app
image: nginx
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}
Use Case: Temporary caching, scratch space.
Not Persistent. Not for production DBs.
3. PersistentVolume (PV)
A PersistentVolume is a cluster-level resource representing actual physical storage.
Think of PV as Disk Infrastructure Layer.
Key Concepts
Independent of Pods
Created by Admin or Dynamic Provisioning
Backed by cloud storage (EBS, EFS, NFS)
Example – AWS EBS PV
apiVersion: v1
kind: PersistentVolume
metadata:
name: ebs-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
awsElasticBlockStore:
volumeID: vol-0abcd1234
fsType: ext4
4. PersistentVolumeClaim (PVC)
PVC is a request for storage by a Pod.
It decouples developers from infrastructure complexity.
Analogy:
PV = Disk
PVC = Disk Request Form
Example – PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: app-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
5. Pod Using PVC
apiVersion: v1
kind: Pod
metadata:
name: app-pod
spec:
containers:
- name: app
image: nginx
volumeMounts:
- mountPath: /data
name: storage
volumes:
- name: storage
persistentVolumeClaim:
claimName: app-pvc
6. Access Modes
| Mode | Meaning | Use Case |
| RWO | ReadWriteOnce | Single node DB |
| ROX | ReadOnlyMany | Shared config |
| RWX | ReadWriteMany | Multi-node apps |
AWS EBS: RWO
AWS EFS: RWX
7. StorageClass – Dynamic Provisioning Engine
StorageClass automates PV creation.
Instead of pre-creating disks, Kubernetes dynamically provisions volumes using CSI drivers.
Example – AWS EBS StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ebs-sc
provisioner: ebs.csi.aws.com
parameters:
type: gp3
fsType: ext4
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
8. Dynamic Provisioning Flow
PVC created
StorageClass detected
CSI driver provisions disk
PV auto-created
Bound to PVC
No manual PV required.
9. CSI – Container Storage Interface
CSI is a standardized plugin system allowing Kubernetes to interact with storage vendors.
In AWS EKS:
EBS CSI Driver → Block storage
EFS CSI Driver → Shared file storage
10. Reclaim Policy
| Policy | Behavior |
| Delete | Disk removed after PVC deletion |
| Retain | Manual cleanup needed |
| Recycle | Deprecated |
Production DBs → Retain
11. Volume Binding Modes
| Mode | Meaning |
| Immediate | Disk created instantly |
| WaitForFirstConsumer | Disk created when Pod scheduled |
EKS Best Practice: WaitForFirstConsumer
12. StatefulSets + Storage
For databases, StatefulSets provide:
Stable identity
Stable storage
Ordered deployment
Example Snippet
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: ebs-sc
resources:
requests:
storage: 10Gi
13. AWS EKS Storage Best Practices
Use EBS For:
Databases
Single-node workloads
High IOPS apps
Use EFS For:
Shared content
Multi-replica apps
CMS platforms
Enable:
Encryption at rest
Backup snapshots
IAM roles for service accounts
Monitoring via CloudWatch
14. Security Considerations
Volume encryption
RBAC policies
Pod security context
IAM permissions
Network isolation
15. Backup and Disaster Recovery
Use:
AWS Snapshots
Velero
Cross-region replication
Automated retention policies
16. Monitoring Storage
Metrics to watch:
Disk latency
IOPS
Throughput
PVC usage
Pod disk pressure
Tools:
Prometheus
Grafana
CloudWatch
Conclusion
Kubernetes storage transforms containerized workloads from ephemeral experiments into enterprise-grade distributed systems.
Mastering PV, PVC, StorageClasses, CSI, StatefulSets, and AWS EBS/EFS integration is essential for production DevOps roles, especially on AWS EKS.