How to Configure Persistent Volumes with EBS and EFS in AWS EKS

Managing data persistence in Kubernetes can be tricky, especially when your pods need to survive restarts and scaling events. If you’re running containerized applications on AWS EKS and struggling with storage that sticks around, you need to master AWS EKS persistent volumes.

This guide is for DevOps engineers, Kubernetes administrators, and developers who want to set up reliable storage solutions for their EKS clusters. You’ll learn how to work with both EBS and EFS storage options to keep your application data safe and accessible.

We’ll walk through setting up EBS persistent volumes in EKS for high-performance block storage that works perfectly for databases and single-pod applications. You’ll also discover how to implement EFS persistent volumes in EKS when you need shared storage that multiple pods can access simultaneously.

Finally, we’ll cover managing dynamic volume provisioning to automate storage creation and dive into troubleshooting common persistent volume issues that can leave you scratching your head. By the end, you’ll have the confidence to choose and configure the right AWS EKS storage options for any workload.

Understanding AWS Storage Options for Kubernetes Workloads

Key differences between EBS and EFS storage solutions

AWS offers two primary AWS EKS storage options for persistent volumes: Elastic Block Store (EBS) and Elastic File System (EFS). EBS persistent volumes Kubernetes provides block-level storage that attaches to individual EC2 instances, similar to a traditional hard drive. Each EBS volume can only be mounted to one pod at a time within the same availability zone. In contrast, EFS storage EKS delivers network file system capabilities that multiple pods can access simultaneously across different availability zones within the same region.

Feature EBS EFS
Access Mode Single pod attachment Multi-pod concurrent access
Availability Single AZ Multi-AZ within region
Performance Consistent, predictable Variable based on throughput mode
Scaling Manual volume resizing Automatic scaling

When to choose EBS vs EFS for your applications

Choose EBS persistent volumes Kubernetes for database workloads, single-instance applications, and scenarios requiring consistent IOPS performance. EBS works perfectly for MySQL, PostgreSQL, or any application needing dedicated storage with predictable performance characteristics. The block storage nature makes it ideal for file systems that require direct disk access patterns.

Select EFS storage EKS when your applications need shared storage across multiple pods, such as content management systems, media processing pipelines, or distributed applications requiring concurrent file access. EFS shines in scenarios where pods need to share configuration files, logs, or user-generated content across different nodes in your cluster.

Performance and cost implications of each storage type

EBS persistent volumes Kubernetes typically delivers higher throughput and lower latency compared to EFS, especially with gp3 and io2 volume types. EBS costs remain predictable since you pay for provisioned storage capacity regardless of actual usage. Performance scales with volume size and IOPS allocation, making it suitable for performance-critical applications.

EFS storage EKS follows a pay-per-use model where costs fluctuate based on actual storage consumption. While convenient for variable workloads, EFS can become expensive for large datasets. Performance varies between General Purpose and Max I/O modes, with network latency affecting overall throughput. Consider EFS Intelligent Tiering to optimize costs by automatically moving infrequently accessed files to cheaper storage classes.

Setting Up EBS Persistent Volumes in EKS

Installing and configuring the EBS CSI driver

The Amazon EBS Container Storage Interface (CSI) driver enables your EKS cluster to manage EBS volumes dynamically. Start by adding the EBS CSI driver add-on through the AWS console or using eksctl. You’ll need to create an IAM service account with the required policies like AmazonEBSCSIDriverPolicy attached. Once installed, verify the driver pods are running in the kube-system namespace using kubectl get pods -n kube-system | grep ebs-csi. The CSI driver automatically handles volume attachment, mounting, and lifecycle management for your persistent volumes.

Creating StorageClass definitions for EBS volumes

StorageClass objects define the properties of EBS volumes that will be dynamically provisioned. Create a StorageClass specifying the EBS volume type (gp3, io2, sc1), encryption settings, and availability zone constraints. Here’s a basic configuration:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ebs-gp3
provisioner: ebs.csi.aws.com
parameters:
  type: gp3
  fsType: ext4
  encrypted: "true"
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true

The WaitForFirstConsumer binding mode ensures volumes are created in the same availability zone as the pod requesting storage.

Defining PersistentVolumeClaim specifications

PersistentVolumeClaims (PVCs) request storage resources from your StorageClass. Define the access mode (ReadWriteOnce for EBS), storage size, and reference your StorageClass. Here’s an example PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ebs-claim
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ebs-gp3
  resources:
    requests:
      storage: 10Gi

Remember that EBS volumes only support ReadWriteOnce access mode, meaning they can only be mounted by one pod at a time.

Attaching EBS volumes to your pods

Mount your EBS persistent volumes by referencing the PVC in your pod specification. Add a volume definition and volumeMount to your container spec:

apiVersion: v1
kind: Pod
metadata:
  name: app-pod
spec:
  containers:
  - name: app
    image: nginx
    volumeMounts:
    - name: ebs-storage
      mountPath: /data
  volumes:
  - name: ebs-storage
    persistentVolumeClaim:
      claimName: ebs-claim

The EBS CSI driver handles the complex attachment process, ensuring the volume is available before the pod starts and properly detached when the pod terminates.

Implementing EFS Persistent Volumes in EKS

Provisioning an EFS file system in your VPC

Creating an Amazon EFS file system starts with navigating to the EFS console and selecting “Create file system.” Choose your VPC and configure mount targets in each availability zone where your EKS nodes run. Set up security groups to allow NFS traffic (port 2049) between your EKS worker nodes and the EFS mount targets. Enable encryption at rest and in transit for production workloads to meet security compliance requirements.

Installing the EFS CSI driver in your cluster

Deploy the Amazon EFS CSI driver using either Helm charts or kubectl manifests. The driver requires specific IAM permissions to create and manage EFS access points automatically. Create a service account with the necessary IAM role that includes elasticfilesystem:CreateAccessPoint and elasticfilesystem:DescribeAccessPoints permissions. Apply the CSI driver deployment with proper resource limits and node selectors for optimal performance across your EKS cluster.

Configuring access points for enhanced security

EFS access points provide application-specific entry points with enforced user identity and path restrictions. Create access points through the AWS console or CLI, specifying POSIX user credentials, group ownership, and root directory paths. Configure creation permissions to automatically set proper file ownership when pods write data. Map these access points in your storage classes and persistent volume claims to ensure workloads can only access designated directories with appropriate permissions, following the principle of least privilege.

Managing Dynamic Volume Provisioning

Automating volume creation with dynamic provisioning

Dynamic volume provisioning in AWS EKS eliminates manual storage management by automatically creating EBS volumes when PersistentVolumeClaims are submitted. The EBS CSI driver handles this process seamlessly, provisioning volumes based on StorageClass specifications. You can define default storage classes with specific volume types, IOPS settings, and availability zone constraints. This automation reduces operational overhead while ensuring consistent storage provisioning across your Kubernetes clusters, making it essential for scalable AWS EKS storage options.

Setting up volume expansion capabilities

Enable volume expansion by setting allowVolumeExpansion: true in your StorageClass definition for both EBS persistent volumes Kubernetes configurations. The EBS CSI driver supports online volume expansion without pod restarts for most volume types. Create expansion policies that automatically trigger when storage usage exceeds defined thresholds. Monitor volume utilization through CloudWatch metrics and configure alerts for proactive scaling. This capability prevents storage-related downtime and maintains application performance as data requirements grow in your EKS environment.

Configuring backup and snapshot policies

Implement automated backup strategies using EBS snapshots through the EBS CSI driver’s snapshot functionality. Create VolumeSnapshotClass resources that define retention policies, encryption settings, and scheduling parameters. Use tools like Velero or AWS Backup to orchestrate comprehensive backup workflows across your persistent volumes. Configure cross-region snapshot replication for disaster recovery scenarios. Establish backup verification procedures to ensure data integrity and recovery capabilities, providing robust data protection for your AWS EKS volume management infrastructure.

Implementing volume encryption for data protection

Configure encryption at rest by setting encrypted: "true" in your StorageClass parameters, leveraging AWS KMS keys for enhanced security. The EBS CSI driver automatically encrypts volumes using either default AWS managed keys or customer-managed keys for granular access control. Implement encryption in transit by enabling TLS communication between pods and storage endpoints. Create separate StorageClasses for different security requirements, allowing workload-specific encryption policies. This multi-layered approach ensures comprehensive data protection while maintaining performance in your configure persistent volumes EKS setup.

Troubleshooting Common Persistent Volume Issues

Resolving Volume Mount Failures and Permission Errors

Pod failures in AWS EKS persistent volumes often stem from incorrect StorageClass configurations or file system permissions. Check if your EBS volumes use the correct fsType parameter and verify that pod security contexts match volume ownership. For EFS persistent volumes, ensure your VPC security groups allow NFS traffic on port 2049 and that the CSI driver has proper IAM permissions.

Fixing Storage Capacity and Performance Bottlenecks

EBS volume performance directly correlates with provisioned IOPS and storage type selection. Monitor CloudWatch metrics for VolumeQueueLength and VolumeThroughputPercentage to identify bottlenecks. For EFS storage EKS deployments, switch to Provisioned Throughput mode when General Purpose performance becomes insufficient. Consider using gp3 volumes for better cost-performance ratios compared to gp2 in dynamic volume provisioning EKS scenarios.

Debugging CSI Driver Connectivity Problems

CSI driver issues typically manifest as “FailedMount” events in pod descriptions. Verify that the EBS CSI driver and EFS CSI driver pods are running correctly in the kube-system namespace. Check node instance roles include required AWS policies like AmazonEBSCSIDriverPolicy. Network connectivity problems between worker nodes and AWS APIs often cause persistent volumes troubleshooting EKS challenges – validate VPC endpoints and internet gateway configurations.

Setting up persistent storage in AWS EKS doesn’t have to be complicated once you understand the basics. EBS volumes work great for single-pod applications that need reliable, fast storage, while EFS shines when you need to share data across multiple pods or availability zones. Dynamic provisioning makes everything easier by automatically creating volumes when your applications need them, saving you from manual setup tasks.

The key to success is choosing the right storage type for your workload and keeping an eye on common issues like mount failures or permission problems. Start with the AWS EBS CSI driver for most applications, then add EFS when you need shared storage. Test your setup in a development environment first, and always monitor your storage performance and costs. With these tools and best practices, you’ll have a solid foundation for running stateful applications in your EKS clusters.