Amazon EKS의 Stateful 파드는 EBS Multi-AZ 볼륨과 EBS CSI 드라이버 v1.69.0을 함께 사용하면 볼륨 때문에 한 가용 영역(AZ)에 묶이지 않습니다. 파드가 대기 AZ의 노드에 배정되면 드라이버가 볼륨을 페일오버한 뒤 연결하므로 운영자가 페일오버 API를 호출하지 않아도 됩니다. 하지만 노드가 응답하지 않을 때 그 노드를 포기하는 결정은 자동으로 내려지지 않았고 그 결정 전에는 파드가 옮겨 가지 않았습니다. 서울 리전의 EKS 클러스터에서 PostgreSQL StatefulSet으로 직접 테스트해 보았습니다. 계획한 이동에서 쓰기는 12초에서 23초 동안 멈췄고 확인받은 쓰기는 한 건도 유실되지 않았습니다. 실제 AZ 장애는 재현하지 못했으므로 장애가 난 AZ의 인스턴스에서 볼륨이 분리되는 시간은 이 결과에 없습니다.A stateful pod on Amazon EKS is no longer tied to one Availability Zone (AZ) by its volume when EBS Multi-AZ volumes are used with the EBS CSI driver v1.69.0. When the pod is scheduled to a node in the standby AZ, the driver fails the volume over and then attaches it, so the operator does not call the failover API. However, when a node stopped responding, nothing decided to give that node up, and the pod did not move before that decision was made. I tested this with a PostgreSQL StatefulSet on an EKS cluster in the Seoul Region. In planned moves writes stopped for 12 to 23 seconds, and not one acknowledged write was lost. I could not reproduce a real AZ failure, so the time to detach the volume from an instance in a failed AZ is not in these results.
configurationType: multi-az-1을 넣으면 됩니다. 대기 AZ는 드라이버가 지연이 가장 낮은 AZ로 고르고 PV는 두 AZ의 노드만 허용합니다.Setup: add configurationType: multi-az-1 to the StorageClass. The driver picks the standby AZ with the lowest latency, and the PV allows nodes of those two AZs only.ec2:GetAwsNetworkPerformanceData와 ec2:FailoverVolumes를 드라이버 역할에 넣어야 합니다. 페일오버 권한이 빠지면 원인이 파드 이벤트에 나오지 않습니다.Permissions: the driver role needs ec2:GetAwsNetworkPerformanceData and ec2:FailoverVolumes, which the managed policy does not have. Without the failover permission the cause does not show up in the pod events.out-of-service taint를 넣은 뒤 26초에서 32초 만에 쓰기가 재개됐습니다.Node not responding: the pod stays in Terminating and the StatefulSet creates no new pod. Writes resumed 26 to 32 seconds after the out-of-service taint.EBS 볼륨은 한 가용 영역(AZ)에만 있어서 EBS를 쓰는 Stateful 파드는 그 AZ의 노드에서만 다시 뜰 수 있었습니다. AWS는 2026년 11월 30일에 두 AZ에 동기 복제되는 EBS Multi-AZ 볼륨을 발표했고 12월 1일에 나온 EBS CSI 드라이버 v1.69.0이 이 볼륨을 지원합니다.
이 조합에서는 PersistentVolume(PV)이 두 AZ의 노드를 허용합니다. 파드가 대기 AZ의 노드에 배정되면 드라이버가 볼륨의 활성 AZ를 그 AZ로 바꾸는 페일오버를 호출한 뒤 볼륨을 연결합니다. 운영자가 페일오버 API를 직접 호출하지 않아도 되고 복제본을 여러 개 두기 어려운 단일 인스턴스 데이터베이스도 AZ를 옮겨 다시 뜰 수 있습니다.

하지만 자동으로 처리되는 범위는 볼륨까지입니다. 노드가 응답하지 않을 때 그 노드를 포기하는 결정은 Kubernetes도 드라이버도 내려 주지 않았고 그 결정이 내려지기 전에는 파드가 옮겨 가지 않았습니다.
Multi-AZ 볼륨 자체의 지연 시간과 페일오버는 앞선 글에서 다뤘습니다. 이 글에서는 Amazon EKS 클러스터에 PostgreSQL StatefulSet을 올리고 파드가 있는 노드를 세 가지 방식으로 없애 보았습니다. 확인하려는 것은 파드가 다른 AZ에서 다시 쓰기를 받기까지 걸리는 시간과 그 과정에서 사람이 해야 하는 일입니다.
01
| 항목 | 구성 |
|---|---|
| 클러스터 | Amazon EKS 1.37(서울 리전), Karpenter 1.15.2 |
| 노드 | c7g.large 5대. 데이터 노드는 AZ마다 1대(2a, 2b, 2c, 2d), 드라이버 컨트롤러와 클라이언트를 두는 infra 노드 1대 |
| 드라이버 | EKS 애드온 aws-ebs-csi-driver v1.69.0-eksbuild.1, 컨트롤러 1개, EKS Pod Identity |
| 워크로드 | PostgreSQL 17.12 StatefulSet(복제본 1), PVC 20GiB, gp3 Multi-AZ 볼륨 |
| 클라이언트 | 약 0.1초마다 새 연결로 INSERT 한 건을 커밋. 정상일 때 초당 약 7건 |
| 쓰기 중단 | 클라이언트가 마지막으로 확인받은 INSERT부터 다음에 확인받은 INSERT까지의 시간 |
| 단계 시각 | 파드, VolumeAttachment, 노드의 watch 이벤트 수신 시각(ms), 드라이버 컨트롤러 로그, 0.25초 간격의 DescribeVolumes |
표 1. 테스트 구성과 측정 방법
다른 워크로드가 떠 있는 클러스터여서 테스트용 NodePool 두 개와 전용 네임스페이스로 분리했고 드라이버의 노드 플러그인은 데이터 노드에만 배치했습니다. 데이터 노드를 AZ마다 한 대씩 미리 둔 것은 새 노드가 뜨는 시간을 빼고 재기 위해서입니다. 드라이버 컨트롤러와 클라이언트는 테스트로 없어지는 노드와 겹치지 않도록 infra 노드에 따로 두었습니다.
02
애드온이 권장하는 관리형 정책 AmazonEBSCSIDriverPolicyV2에는 Multi-AZ 볼륨에 필요한 권한 두 가지가 없었습니다. 드라이버의 설치 문서는 관리형 정책에 추가되기 전까지 두 권한을 별도 정책으로 넣으라고 안내합니다. ec2:GetAwsNetworkPerformanceData는 대기 AZ를 고를 때, ec2:FailoverVolumes는 볼륨을 페일오버할 때 사용합니다.
# 드라이버용 역할 (EKS Pod Identity)
aws iam create-role --role-name ebs-csi-multi-az \
--assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"pods.eks.amazonaws.com"},"Action":["sts:AssumeRole","sts:TagSession"]}]}'
aws iam attach-role-policy --role-name ebs-csi-multi-az \
--policy-arn arn:aws:iam::aws:policy/AmazonEBSCSIDriverPolicyV2
# Multi-AZ 볼륨용 추가 권한 (multi-az.json)
{
"Version": "2012-10-17",
"Statement": [
{"Effect": "Allow", "Action": "ec2:GetAwsNetworkPerformanceData", "Resource": "*"},
{"Effect": "Allow", "Action": "ec2:FailoverVolumes",
"Resource": "arn:aws:ec2:*:*:volume/*",
"Condition": {"StringEquals": {"ec2:ResourceTag/ebs.csi.aws.com/cluster": "true"}}}
]
}
aws iam put-role-policy --role-name ebs-csi-multi-az --policy-name multi-az \
--policy-document file://multi-az.json
aws eks create-addon --cluster-name my-cluster --addon-name aws-ebs-csi-driver \
--addon-version v1.69.0-eksbuild.1 \
--pod-identity-associations serviceAccount=ebs-csi-controller-sa,roleArn=arn:aws:iam::111122223333:role/ebs-csi-multi-az추가 정책 없이 먼저 배포해 보았습니다. PVC는 Pending에 머물렀고 이벤트에 원인이 나왔습니다. 정책을 넣자 프로비저너가 다음 재시도에서 볼륨을 만들었습니다.
$ kubectl -n ebs-maz describe pvc data-pg-0
Warning ProvisioningFailed ebs.csi.aws.com_ebs-csi-controller-...
rpc error: code = Internal desc = Could not create volume "pvc-...":
could not select standby availability zones: could not get network performance data:
operation error EC2: GetAwsNetworkPerformanceData, https response error StatusCode: 403,
api error UnauthorizedOperation: You are not authorized to perform this operation.03
StorageClass에 configurationType: multi-az-1을 넣으면 드라이버가 Multi-AZ 볼륨을 만듭니다. 나머지는 기존 EBS StorageClass와 같습니다.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ebs-maz-gp3
provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete
parameters:
type: gp3
configurationType: multi-az-1파드가 2a 노드에 배정되자 드라이버는 활성 AZ가 2a이고 대기 AZ가 2d인 볼륨을 만들었습니다. PV의 노드 어피니티에는 두 AZ가 함께 기록됐습니다.
$ kubectl get pv pvc-11111111-2222-3333-4444-555555555555 \
-o jsonpath='{.spec.nodeAffinity.required.nodeSelectorTerms[*].matchExpressions[*].values}'
["ap-northeast-2a"] ["ap-northeast-2d"]
$ aws ec2 describe-volumes --volume-ids vol-0aaaaaaaaaaaaaaaa \
--query 'Volumes[0].{Az:AvailabilityZone,Type:VolumeType,Size:Size,MultiAz:MultiAvailabilityZoneConfiguration}'
{
"Az": "ap-northeast-2a",
"Type": "gp3",
"Size": 20,
"MultiAz": {
"ConfigurationType": "multi-az-1",
"StandbyAvailabilityZones": [
{"AvailabilityZone": "ap-northeast-2d", "AvailabilityZoneId": "apne2-az4"}
]
}
}드라이버의 파라미터 문서에 따르면 대기 AZ는 볼륨을 만들 수 있는 AZ 가운데 활성 AZ에서 네트워크 지연이 가장 낮은 곳입니다. 이 테스트에서는 드라이버의 노드 플러그인이 있는 네 AZ가 후보였습니다. 드라이버가 사용하는 GetAwsNetworkPerformanceData를 같은 조건으로 호출해 보았습니다. 2a에서 본 지연은 2b 0.62ms, 2c 0.92ms, 2d 0.52ms였고 드라이버가 고른 2d가 가장 낮았습니다.
AZ 쌍을 직접 정하려면 StorageClass의 allowedTopologies에 두 AZ만 적습니다. 2b와 2c만 허용한 StorageClass에서는 드라이버가 활성 2b, 대기 2c인 볼륨을 만들었습니다. 볼륨의 두 AZ 밖으로는 파드가 가지 못합니다. 2a와 2d 노드를 모두 막고 파드를 지우자 2b와 2c 노드가 남아 있는데도 파드는 Pending에 머물렀습니다. 스케줄러가 남긴 이벤트는 2 node(s) didn't match PersistentVolume's node affinity였습니다.
04
노드 교체처럼 미리 계획한 이동을 먼저 확인했습니다. 파드가 있는 노드에 새 파드가 배정되지 않게 막고(cordon) 파드를 지웠습니다. 새 파드는 대기 AZ의 노드에 배정됐고 드라이버 컨트롤러의 로그에는 연결하기 전에 페일오버를 호출한 기록이 남았습니다.
$ kubectl cordon ip-10-200-70-10.ap-northeast-2.compute.internal
$ kubectl -n ebs-maz delete pod pg-0 --wait=false
$ kubectl -n kube-system logs deploy/ebs-csi-controller -c ebs-plugin \
| grep -E 'ControllerUnpublishVolume: det|ControllerPublishVolume: att|MAZ volume'
I1203 05:58:04.798047 controller.go:640] "ControllerUnpublishVolume: detaching" volumeID="vol-0aaaaaaaaaaaaaaaa" nodeID="i-0dddddddddddddddd"
I1203 05:58:07.974143 controller.go:648] "ControllerUnpublishVolume: detached" volumeID="vol-0aaaaaaaaaaaaaaaa" nodeID="i-0dddddddddddddddd"
I1203 05:58:08.425088 controller.go:539] "ControllerPublishVolume: attaching" volumeID="vol-0aaaaaaaaaaaaaaaa" nodeID="i-0aaaaaaaaaaaaaaaa"
I1203 05:58:09.607308 cloud.go:3370] "AttachDisk: MAZ volume failover required" volumeID="vol-0aaaaaaaaaaaaaaaa" currentPrimaryAZ="ap-northeast-2d" targetAZ="ap-northeast-2a"
I1203 05:58:10.429970 cloud.go:3374] "AttachDisk: MAZ volume failover completed" volumeID="vol-0aaaaaaaaaaaaaaaa" newPrimaryAZ="ap-northeast-2a"
I1203 05:58:13.228495 controller.go:554] "ControllerPublishVolume: attached" volumeID="vol-0aaaaaaaaaaaaaaaa" nodeID="i-0aaaaaaaaaaaaaaaa" devicePath="/dev/xvdaa"
2a와 2d 사이를 일곱 번 오갔고 쓰기 중단은 11.8초에서 22.7초, 중앙값은 15.5초였습니다. 단계별 시각을 기록한 여섯 번을 구간으로 나누면 페일오버는 매번 0.8초대였고 시간은 이전 노드에서 볼륨을 분리하는 데 가장 많이 들었습니다.
| 구간 | 담당 | 걸린 시간 (6회) |
|---|---|---|
| 이전 파드 종료와 삭제 | kubelet, PostgreSQL | 0.7~1.4초 |
| 이전 노드에서 볼륨 분리 | attach-detach 컨트롤러, 드라이버 | 4.0~11.9초 |
| 페일오버와 새 노드 연결 | 드라이버 컨트롤러 | 3.5~5.2초 |
| 그중 페일오버 호출부터 완료까지 | 드라이버 컨트롤러 | 0.82~0.87초 |
| 컨테이너 시작과 Ready | kubelet, PostgreSQL | 1.7~2.4초 |
| Service를 거친 첫 INSERT | kube-proxy, 클라이언트 | 0.4~1.5초 |
표 2. 계획한 이동의 구간별 시간. 단계 시각을 기록한 6회의 범위이고 첫 번째 이동은 쓰기 중단만 측정했습니다
볼륨 분리와 연결, 파드 시작은 단일 AZ 볼륨을 쓰는 파드가 같은 AZ의 다른 노드로 옮겨 갈 때도 거치는 단계입니다. AZ를 넘는 이동에 더해진 것은 1초가 안 되는 페일오버였습니다.
05
파드가 있는 노드의 인스턴스를 예고 없이 종료했습니다. Karpenter가 종료 이벤트를 받아 노드를 비웠고 새 파드는 약 2초 뒤에 대기 AZ의 노드에 배정됐습니다. 하지만 종료 중인 인스턴스에서 볼륨이 분리될 때까지 약 55초를 기다렸고 쓰기 중단은 두 번 모두 1분을 조금 넘었습니다.
AZ 장애에서는 종료 이벤트가 오지 않고 노드가 응답만 하지 않습니다. 이 상황은 노드의 kubelet을 멈춰서 만들었고 인스턴스와 PostgreSQL 컨테이너는 계속 실행됩니다. 48초쯤 뒤에 노드가 NotReady가 되면서 쓰기가 실패하기 시작했고 5분 48초 뒤에 파드에 삭제 표시가 생겼습니다. 그 뒤로는 진행되지 않았습니다. 8분 17초가 지날 때까지 파드는 Terminating에 머물렀고 StatefulSet은 새 파드를 만들지 않았습니다. Kubernetes 문서의 비정상 노드 종료 처리가 설명하는 동작과 같습니다.
문서는 노드에 out-of-service taint를 넣어 그 노드를 포기한다고 알리라고 안내합니다. taint를 넣자 이전 파드가 강제로 삭제되고 볼륨이 분리된 뒤 새 파드가 대기 AZ에서 떴습니다.
$ kubectl taint nodes ip-10-200-20-10.ap-northeast-2.compute.internal \
node.kubernetes.io/out-of-service=nodeshutdown:NoExecute
# 측정 기록을 taint를 넣은 시각 기준으로 정리
+9.9s old pod: object deleted
+10.0s new pod: scheduled to ip-10-200-70-10
+15.4s VolumeAttachment for ip-10-200-20-10 deleted (detached)
+17.0s CSI controller: failover required (ap-northeast-2a -> ap-northeast-2d)
+17.9s CSI controller: failover completed
+20.6s CSI controller: attached
+31.5s new pod: Ready=True
+32.1s client: first INSERT after the outage acknowledged| 경우 | 횟수 | 쓰기 중단 | 사람이 한 일 | 가장 오래 걸린 구간 |
|---|---|---|---|---|
| 계획한 이동 | 7 | 12초에서 23초 (04 챕터) | cordon과 파드 삭제 | 이전 노드에서 볼륨 분리 |
| 인스턴스 종료 | 2 | 64.2초, 65.5초 | 없음 | 종료 중인 인스턴스에서 볼륨 분리, 약 55초 |
| 노드 무응답 | 3 | taint 뒤 25.7초, 31.5초, 32.1초 | out-of-service taint | taint를 넣기 전까지의 시간. 넣지 않으면 복구되지 않음 |
표 3. 세 경우의 쓰기 중단. 노드 무응답의 값은 taint를 넣은 시각부터 잰 것이고 노드가 NotReady로 바뀔 때까지 걸린 48초 안팎과 사람이 판단한 시간은 들어 있지 않습니다
노드 무응답의 첫 실행에서는 새 파드가 같은 AZ로 갔습니다. 응답하지 않는 노드에 있던 다른 파드가 축출되자 Karpenter가 같은 AZ에 새 노드를 띄웠기 때문입니다. AZ 장애에서는 그 AZ에 새 노드가 뜨지 않으므로 나머지 두 실행에서는 NodePool에서 해당 AZ를 임시로 제외했고 파드는 대기 AZ로 갔습니다.
Kubernetes 문서는 이 taint를 넣기 전에 노드가 꺼져 있는지 확인하라고 안내합니다. 이 테스트의 노드는 켜져 있었고 PostgreSQL도 실행 중이었습니다. taint 뒤에 이전 노드를 보니 볼륨 장치가 사라져 있었고 파일시스템은 중단돼 있었습니다. 이전 파드가 같은 볼륨에 계속 쓰는 일은 없었습니다.
# 이전 노드, taint를 넣고 43초 뒤
$ lsblk -dn -o NAME,SIZE
nvme0n1 20G
$ dmesg | tail -4
[ 453.399276] EXT4-fs (nvme1n1): shut down requested (2)
[ 453.399898] Aborting journal on device nvme1n1-8.
[ 453.400536] Buffer I/O error on dev nvme1n1, logical block 2655236, lost sync page write
[ 453.401693] JBD2: I/O error when updating journal superblock for nvme1n1-8.테스트 전체에서 클라이언트가 확인받은 INSERT는 11,327건이었고 마지막에 테이블과 대조했을 때 빠진 행은 없었습니다.
06
ec2:FailoverVolumes 권한을 뺀 상태에서 계획한 이동을 실행했습니다. 연결은 실패했고 파드는 ContainerCreating에 머물렀습니다. 원인은 드라이버 컨트롤러의 로그에만 있었습니다. 오류 메시지가 VolumeAttachment에 기록할 수 있는 1,024바이트를 넘어 저장되지 못했고 파드 이벤트에는 시간 초과만 나왔습니다.
# kubectl -n kube-system logs deploy/ebs-csi-controller -c ebs-plugin
"GRPC error" err="rpc error: code = Internal desc = Could not attach volume \"vol-0aaaaaaaaaaaaaaaa\"
to node \"i-0aaaaaaaaaaaaaaaa\": could not failover volume \"vol-0aaaaaaaaaaaaaaaa\" to AZ \"ap-northeast-2a\"
before attach: ... operation error EC2: FailoverVolumes, https response error StatusCode: 403,
api error UnauthorizedOperation ... because no identity-based policy allows the ec2:FailoverVolumes action."
# kubectl -n kube-system logs deploy/ebs-csi-controller -c csi-attacher
"Failed to save attach error to VolumeAttachment" err="... status.attachError.message: Too long:
may not be more than 1024 bytes"
# kubectl -n ebs-maz describe pod pg-0
Warning FailedAttachVolume AttachVolume.Attach failed for volume "pvc-..." : timed out waiting for
external-attacher of ebs.csi.aws.com CSI driver to attach volume vol-0aaaaaaaaaaaaaaaa연결 재시도의 간격은 2초에서 시작해 130초까지 벌어졌습니다. 그래서 87초 만에 권한을 되돌렸는데도 다음에 성공한 시도는 271초에 시작됐고 쓰기 중단은 286초였습니다.
이 권한 누락은 볼륨을 만들 때 드러나지 않을 수 있습니다. 대기 AZ 후보가 하나뿐이면 드라이버가 지연을 조회하지 않기 때문입니다. allowedTopologies에 두 AZ만 적은 StorageClass는 GetAwsNetworkPerformanceData 권한이 없어도 볼륨을 만들었습니다. 이런 구성에서는 권한 문제를 첫 AZ 이동 때 처음 만나게 됩니다.
07
DetachVolume이 끝나는지는 확인하지 못했습니다. Kubernetes는 이전 노드의 분리가 끝나야 새 노드에 연결하므로 이 부분이 복구 시간을 좌우합니다.08
PVC를 지우면 드라이버가 볼륨을 삭제하므로 드라이버보다 PVC를 먼저 지웁니다.
kubectl -n ebs-maz delete statefulset pg
kubectl -n ebs-maz delete pvc --all # 볼륨 삭제까지 기다립니다
kubectl delete storageclass ebs-maz-gp3
aws eks delete-addon --cluster-name my-cluster --addon-name aws-ebs-csi-driver
aws iam delete-role-policy --role-name ebs-csi-multi-az --policy-name multi-az
aws iam detach-role-policy --role-name ebs-csi-multi-az \
--policy-arn arn:aws:iam::aws:policy/AmazonEBSCSIDriverPolicyV2
aws iam delete-role --role-name ebs-csi-multi-az비용은 볼륨에서 늘어납니다. Multi-AZ 볼륨의 요금은 단일 AZ 볼륨의 두 배이고 서울 리전의 gp3 20GiB는 월 1.82달러에서 3.65달러가 됩니다. 쓰기 지연도 대기 AZ까지 다녀오는 만큼 늘어납니다. 그 값은 앞선 글에 있습니다. 파드가 넘어갈 AZ에는 노드 용량이 있어야 합니다.
이 구성은 복제본을 여러 개 두기 어려운 Stateful 워크로드에서 AZ를 옮길 때 수십 초에서 1분 안팎의 중단을 받아들일 수 있으면 맞습니다. 노드 교체나 AZ를 비우는 작업처럼 계획한 이동은 이 테스트에서 23초 안에 끝났습니다. 몇 초 안에 넘어가야 하는 서비스는 애플리케이션 수준의 복제를 그대로 두는 편이 맞습니다. 이 테스트의 가장 짧은 중단도 10초를 넘었기 때문입니다.
적용하기 전에 정해 둘 항목입니다.
out-of-service taint를 누가 어떤 조건에서 넣는지 정합니다. 이 결정이 없으면 파드는 옮겨 가지 않습니다.allowedTopologies를 사용합니다.An EBS volume lives in one Availability Zone (AZ), so a stateful pod on EBS could only come back on a node in that AZ. On November 30, 2026 AWS announced EBS Multi-AZ volumes, which are replicated synchronously to two AZs, and the EBS CSI driver v1.69.0, released on December 1, supports them.
With the two together, the PersistentVolume (PV) allows nodes of two AZs. When the pod is scheduled to a node in the standby AZ, the driver calls a failover, which makes that AZ the active AZ of the volume, and then attaches the volume. The operator does not call the failover API, and a single-instance database that is hard to run with several replicas can also change AZ and start again.

However, what is handled automatically ends at the volume. When a node stopped responding, neither Kubernetes nor the driver decided to give that node up, and the pod did not move before that decision was made.
The latency and the failover of a Multi-AZ volume itself are in an earlier post. For this post I ran a PostgreSQL StatefulSet on an Amazon EKS cluster and took the pod's node away in three ways. What I wanted to find out is how long it takes until the pod accepts writes again in the other AZ, and what a person has to do along the way.
01
| Item | Setup |
|---|---|
| Cluster | Amazon EKS 1.37 (Seoul Region), Karpenter 1.15.2 |
| Nodes | Five c7g.large. One data node per AZ (2a, 2b, 2c, 2d) and one infra node for the driver controller and the client |
| Driver | EKS add-on aws-ebs-csi-driver v1.69.0-eksbuild.1, one controller, EKS Pod Identity |
| Workload | PostgreSQL 17.12 StatefulSet (one replica), 20 GiB PVC, gp3 Multi-AZ volume |
| Client | Commits one INSERT over a new connection about every 0.1 seconds. About 7 per second in normal operation |
| Write interruption | The time from the last INSERT the client had acknowledged to the next acknowledged INSERT |
| Step times | Receive time (ms) of the watch events of the pod, the VolumeAttachment and the nodes, the log of the driver controller, and DescribeVolumes every 0.25 seconds |
Table 1. Test setup and how it was measured
The cluster runs other workloads, so the test used two NodePools and a namespace of its own, and the node plugin of the driver ran on the data nodes only. One data node per AZ was there in advance so that the time to launch a new node is not in the measurement. The driver controller and the client ran on the infra node so that they are never on a node that a test takes away.
02
The managed policy that the add-on recommends, AmazonEBSCSIDriverPolicyV2, did not have the two permissions that Multi-AZ volumes need. The installation docs of the driver say to add them as a separate policy until the managed policies include them. ec2:GetAwsNetworkPerformanceData is used to pick the standby AZ, and ec2:FailoverVolumes to fail the volume over.
# Role for the driver (EKS Pod Identity)
aws iam create-role --role-name ebs-csi-multi-az \
--assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"pods.eks.amazonaws.com"},"Action":["sts:AssumeRole","sts:TagSession"]}]}'
aws iam attach-role-policy --role-name ebs-csi-multi-az \
--policy-arn arn:aws:iam::aws:policy/AmazonEBSCSIDriverPolicyV2
# Extra permissions for Multi-AZ volumes (multi-az.json)
{
"Version": "2012-10-17",
"Statement": [
{"Effect": "Allow", "Action": "ec2:GetAwsNetworkPerformanceData", "Resource": "*"},
{"Effect": "Allow", "Action": "ec2:FailoverVolumes",
"Resource": "arn:aws:ec2:*:*:volume/*",
"Condition": {"StringEquals": {"ec2:ResourceTag/ebs.csi.aws.com/cluster": "true"}}}
]
}
aws iam put-role-policy --role-name ebs-csi-multi-az --policy-name multi-az \
--policy-document file://multi-az.json
aws eks create-addon --cluster-name my-cluster --addon-name aws-ebs-csi-driver \
--addon-version v1.69.0-eksbuild.1 \
--pod-identity-associations serviceAccount=ebs-csi-controller-sa,roleArn=arn:aws:iam::111122223333:role/ebs-csi-multi-azI deployed without the extra policy first. The PVC stayed Pending and the cause was in its events. Once the policy was there, the provisioner created the volume on its next retry.
$ kubectl -n ebs-maz describe pvc data-pg-0
Warning ProvisioningFailed ebs.csi.aws.com_ebs-csi-controller-...
rpc error: code = Internal desc = Could not create volume "pvc-...":
could not select standby availability zones: could not get network performance data:
operation error EC2: GetAwsNetworkPerformanceData, https response error StatusCode: 403,
api error UnauthorizedOperation: You are not authorized to perform this operation.03
With configurationType: multi-az-1 in the StorageClass, the driver creates a Multi-AZ volume. The rest is the same as any EBS StorageClass.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ebs-maz-gp3
provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete
parameters:
type: gp3
configurationType: multi-az-1When the pod was scheduled to the 2a node, the driver created a volume with 2a as the active AZ and 2d as the standby AZ. Both AZs were written to the node affinity of the PV.
$ kubectl get pv pvc-11111111-2222-3333-4444-555555555555 \
-o jsonpath='{.spec.nodeAffinity.required.nodeSelectorTerms[*].matchExpressions[*].values}'
["ap-northeast-2a"] ["ap-northeast-2d"]
$ aws ec2 describe-volumes --volume-ids vol-0aaaaaaaaaaaaaaaa \
--query 'Volumes[0].{Az:AvailabilityZone,Type:VolumeType,Size:Size,MultiAz:MultiAvailabilityZoneConfiguration}'
{
"Az": "ap-northeast-2a",
"Type": "gp3",
"Size": 20,
"MultiAz": {
"ConfigurationType": "multi-az-1",
"StandbyAvailabilityZones": [
{"AvailabilityZone": "ap-northeast-2d", "AvailabilityZoneId": "apne2-az4"}
]
}
}According to the parameter docs of the driver, the standby AZ is the one with the lowest network latency from the active AZ among the AZs where the volume can be created. In this test the four AZs with a node plugin of the driver were the candidates. I called GetAwsNetworkPerformanceData, which the driver uses, with the same conditions. The latency seen from 2a was 0.62 ms to 2b, 0.92 ms to 2c and 0.52 ms to 2d, and 2d, which the driver picked, was the lowest.
To fix the pair of AZs yourself, list only two AZs in allowedTopologies of the StorageClass. With a StorageClass that allowed only 2b and 2c, the driver created a volume with 2b active and 2c standby. A pod cannot go outside the two AZs of its volume. When I cordoned both the 2a and the 2d node and deleted the pod, it stayed Pending although the 2b and 2c nodes were available. The event of the scheduler was 2 node(s) didn't match PersistentVolume's node affinity.
04
I started with a move that is planned in advance, such as a node replacement. I cordoned the pod's node, so that no new pod is scheduled to it, and deleted the pod. The new pod was scheduled to the node in the standby AZ, and the log of the driver controller shows the failover call before the attach.
$ kubectl cordon ip-10-200-70-10.ap-northeast-2.compute.internal
$ kubectl -n ebs-maz delete pod pg-0 --wait=false
$ kubectl -n kube-system logs deploy/ebs-csi-controller -c ebs-plugin \
| grep -E 'ControllerUnpublishVolume: det|ControllerPublishVolume: att|MAZ volume'
I1203 05:58:04.798047 controller.go:640] "ControllerUnpublishVolume: detaching" volumeID="vol-0aaaaaaaaaaaaaaaa" nodeID="i-0dddddddddddddddd"
I1203 05:58:07.974143 controller.go:648] "ControllerUnpublishVolume: detached" volumeID="vol-0aaaaaaaaaaaaaaaa" nodeID="i-0dddddddddddddddd"
I1203 05:58:08.425088 controller.go:539] "ControllerPublishVolume: attaching" volumeID="vol-0aaaaaaaaaaaaaaaa" nodeID="i-0aaaaaaaaaaaaaaaa"
I1203 05:58:09.607308 cloud.go:3370] "AttachDisk: MAZ volume failover required" volumeID="vol-0aaaaaaaaaaaaaaaa" currentPrimaryAZ="ap-northeast-2d" targetAZ="ap-northeast-2a"
I1203 05:58:10.429970 cloud.go:3374] "AttachDisk: MAZ volume failover completed" volumeID="vol-0aaaaaaaaaaaaaaaa" newPrimaryAZ="ap-northeast-2a"
I1203 05:58:13.228495 controller.go:554] "ControllerPublishVolume: attached" volumeID="vol-0aaaaaaaaaaaaaaaa" nodeID="i-0aaaaaaaaaaaaaaaa" devicePath="/dev/xvdaa"
The pod went back and forth between 2a and 2d seven times. The write interruption was 11.8 to 22.7 seconds, with a median of 15.5 seconds. Split into parts for the six runs with step times, the failover took 0.8 seconds each time, and most of the time went to detaching the volume from the old node.
| Part | Done by | Time (6 runs) |
|---|---|---|
| Old pod stops and is deleted | kubelet, PostgreSQL | 0.7 to 1.4 s |
| Volume detached from the old node | attach-detach controller, driver | 4.0 to 11.9 s |
| Failover and attach to the new node | driver controller | 3.5 to 5.2 s |
| Of that, from the failover call to its completion | driver controller | 0.82 to 0.87 s |
| Container start and Ready | kubelet, PostgreSQL | 1.7 to 2.4 s |
| First INSERT through the Service | kube-proxy, client | 0.4 to 1.5 s |
Table 2. Time by part in a planned move. The range of the six runs with step times; for the first move only the write interruption was measured
Detaching and attaching the volume and starting the pod are steps that a pod on a single-AZ volume also goes through when it moves to another node in the same AZ. What crossing the AZ added was a failover of less than a second.
05
I terminated the instance of the pod's node without warning. Karpenter received the termination event and drained the node, and the new pod was scheduled to the node in the standby AZ about 2 seconds later. However, it waited about 55 seconds for the volume to detach from the terminating instance, and the write interruption was a little over a minute both times.
In an AZ failure no termination event arrives; the node just stops responding. I made this state by stopping the kubelet of the node, while the instance and the PostgreSQL container keep running. After about 48 seconds the node became NotReady and writes started to fail, and after 5 minutes 48 seconds the pod was marked for deletion. Nothing happened after that. Until 8 minutes 17 seconds had passed the pod stayed in Terminating and the StatefulSet created no new pod. This is the behavior that non-graceful node shutdown handling in the Kubernetes docs describes.
The docs say to put the out-of-service taint on the node to declare that the node is given up. After the taint the old pod was force-deleted, the volume was detached, and the new pod came up in the standby AZ.
$ kubectl taint nodes ip-10-200-20-10.ap-northeast-2.compute.internal \
node.kubernetes.io/out-of-service=nodeshutdown:NoExecute
# The measurement record, relative to the time of the taint
+9.9s old pod: object deleted
+10.0s new pod: scheduled to ip-10-200-70-10
+15.4s VolumeAttachment for ip-10-200-20-10 deleted (detached)
+17.0s CSI controller: failover required (ap-northeast-2a -> ap-northeast-2d)
+17.9s CSI controller: failover completed
+20.6s CSI controller: attached
+31.5s new pod: Ready=True
+32.1s client: first INSERT after the outage acknowledged| Case | Runs | Write interruption | What a person did | Longest part |
|---|---|---|---|---|
| Planned move | 7 | 12 to 23 s (chapter 04) | cordon and delete the pod | Detaching the volume from the old node |
| Instance terminated | 2 | 64.2 s, 65.5 s | Nothing | Detaching the volume from the terminating instance, about 55 s |
| Node not responding | 3 | 25.7 s, 31.5 s, 32.1 s after the taint | out-of-service taint | The time until the taint. Without it there is no recovery |
Table 3. Write interruption in the three cases. For the node that does not respond the values start at the taint; the 48 seconds or so until the node turned NotReady and the time a person took to decide are not included
In the first run with an unresponsive node the new pod went to the same AZ. When another pod on that node was evicted, Karpenter launched a new node in the same AZ. In an AZ failure no new node comes up in that AZ, so for the other two runs I excluded the AZ from the NodePool for the duration, and the pod went to the standby AZ.
The Kubernetes docs say to check that the node is powered off before adding this taint. The node in this test was on and PostgreSQL was running. When I looked at the old node after the taint, the volume device was gone and the file system had been shut down. The old pod did not keep writing to the same volume.
# The old node, 43 seconds after the taint
$ lsblk -dn -o NAME,SIZE
nvme0n1 20G
$ dmesg | tail -4
[ 453.399276] EXT4-fs (nvme1n1): shut down requested (2)
[ 453.399898] Aborting journal on device nvme1n1-8.
[ 453.400536] Buffer I/O error on dev nvme1n1, logical block 2655236, lost sync page write
[ 453.401693] JBD2: I/O error when updating journal superblock for nvme1n1-8.Over the whole test the client had 11,327 INSERTs acknowledged, and when I compared them with the table at the end no row was missing.
06
I ran a planned move with the ec2:FailoverVolumes permission removed. The attach failed and the pod stayed in ContainerCreating. The cause was only in the log of the driver controller. The error message was longer than the 1,024 bytes a VolumeAttachment can hold, so it was not saved, and the pod events showed only a timeout.
# kubectl -n kube-system logs deploy/ebs-csi-controller -c ebs-plugin
"GRPC error" err="rpc error: code = Internal desc = Could not attach volume \"vol-0aaaaaaaaaaaaaaaa\"
to node \"i-0aaaaaaaaaaaaaaaa\": could not failover volume \"vol-0aaaaaaaaaaaaaaaa\" to AZ \"ap-northeast-2a\"
before attach: ... operation error EC2: FailoverVolumes, https response error StatusCode: 403,
api error UnauthorizedOperation ... because no identity-based policy allows the ec2:FailoverVolumes action."
# kubectl -n kube-system logs deploy/ebs-csi-controller -c csi-attacher
"Failed to save attach error to VolumeAttachment" err="... status.attachError.message: Too long:
may not be more than 1024 bytes"
# kubectl -n ebs-maz describe pod pg-0
Warning FailedAttachVolume AttachVolume.Attach failed for volume "pvc-..." : timed out waiting for
external-attacher of ebs.csi.aws.com CSI driver to attach volume vol-0aaaaaaaaaaaaaaaaThe interval between attach retries started at 2 seconds and grew to 130 seconds. So although I restored the permission after 87 seconds, the next attempt that succeeded started at 271 seconds, and the write interruption was 286 seconds.
This missing permission may not show when the volume is created, because the driver does not look up the latency when there is only one candidate for the standby AZ. A StorageClass with only two AZs in allowedTopologies created a volume without the GetAwsNetworkPerformanceData permission. In such a setup you meet the permission problem for the first time at the first move to the other AZ.
07
DetachVolume completes for an instance in a failed AZ. Kubernetes attaches the volume to the new node only after the detach from the old node is done, so this part decides the recovery time.08
Deleting the PVC makes the driver delete the volume, so delete the PVC before the driver.
kubectl -n ebs-maz delete statefulset pg
kubectl -n ebs-maz delete pvc --all # wait until the volume is deleted
kubectl delete storageclass ebs-maz-gp3
aws eks delete-addon --cluster-name my-cluster --addon-name aws-ebs-csi-driver
aws iam delete-role-policy --role-name ebs-csi-multi-az --policy-name multi-az
aws iam detach-role-policy --role-name ebs-csi-multi-az \
--policy-arn arn:aws:iam::aws:policy/AmazonEBSCSIDriverPolicyV2
aws iam delete-role --role-name ebs-csi-multi-azThe cost goes up at the volume. A Multi-AZ volume costs twice as much as a single-AZ volume; 20 GiB of gp3 in the Seoul Region goes from 1.82 to 3.65 USD a month. The write latency also grows by the trip to the standby AZ. Those values are in the earlier post. The AZ the pod moves to needs node capacity.
This setup fits a stateful workload that is hard to run with several replicas and can accept an interruption of tens of seconds to about a minute when it changes AZ. A planned move, such as replacing a node or emptying an AZ, finished within 23 seconds in this test. A service that has to switch within a few seconds is better left on replication at the application level, because even the shortest interruption in this test was over 10 seconds.
Things to settle before applying it:
out-of-service taint and under which condition. Without that decision the pod does not move.allowedTopologies.