The multi-attach capability allows you to attach a single EBS volume to multiple EC2 instances located within the same Availability Zone (AZ). This shared volume can be utilized by several pods running on distinct nodes.
- EBS Multi-Attach does not support standard file systems. Standard file systems such as
XFS
,EXT3
,EXT4
, andNTFS
aren't designed to be simultaneously accessed by multiple servers or EC2 instances. - Simultaneous access to a standard file system can result in data corruption or data loss.
- You should use a clustered file system to ensure data resiliency and reliability for your production workloads.
- Multi-Attach is only enabled for
IO2
block devices.
Refer to the official AWS documentation on Multi-Attach for more information, best practices, and limitations of this capability.
- Create a
StorageClass
referencing anIO2
volume type:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ebs-sc
provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumer
parameters:
type: io2
iops: "1000"
- Create a
PersistentVolumeClaim
referencing theReadWriteMany
access andBlock
device modes:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: block-claim
spec:
accessModes:
- ReadWriteMany
volumeMode: Block
storageClassName: ebs-sc
resources:
requests:
storage: 4Gi
- Create a
DaemonSet
to deploy the driver on all nodes:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: app-daemon
spec:
selector:
matchLabels:
name: app
template:
metadata:
labels:
name: app
spec:
containers:
- name: app
image: busybox
command: ["/bin/sh", "-c"]
args: ["tail -f /dev/null"]
volumeDevices:
- name: data
devicePath: /dev/xvda
volumes:
- name: data
persistentVolumeClaim:
claimName: block-claim
- Verify the
DaemonSet
is running:
$ kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
default app-daemon-9hdgw 1/1 Running 0 18s
default app-daemon-xm8zr 1/1 Running 0 18s