AKS(Azure Kubernetes Service)에서 Azure CSI(Container Stroage Interface) 드라이버를 사용하여 Azure Files, Blob, Managed Disk를 Persistent Volume으로 사용할 수 있습니다.
본문에서는 Managed Disk ZRS를 사용하여 StrageClass, PVC, PV를 생성하고 장애 상황을 발생하여 Zone1 노드에 배포된 Pod가 Zone2로 재생성 되었을 때 여전히 PV 상에 정보가 남아 있는지 확인 합니다.
해당 테스트는 다음 링크 문서를 참고합니다.
제한 사항
- 사용 중인 VM SKU에 따라 Azure Disk CSI 드라이버에 노드 당 볼륨 제한
- 제공되는 VM SKU 목록 및 해당 세부 용량 제한은 범용 가상 머신 크기를 참조
기본 제공 StorageClass
AKS를 생성하면 기본으로 제공되는 StorageClass가 존재합니다.
- managed-csi: Azure Standard SSD LRS(로컬 중복 스토리지)를 사용하여 관리 디스크를 만듬
- managed-csi-premium: Azure Premium LRS를 사용하여 관리 디스크를 만듬
테스트 환경
- Azure Kubernetes 1.27.3
- Nodepool 2개 생성
- nodepool1(Zone1), nodepool2(Zone2)
ZRS용 Managed Disk Storage Class 생성
1. 다음 YAML 파일을 사용하여 Storage Class를 생성합니다.
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: azuredisk-csi-zrs
provisioner: disk.csi.azure.com
parameters:
skuname: StandardSSD_ZRS
allowVolumeExpansion: true
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
2. 다음 YAML 파일을 사용하여 PVC를 생성합니다.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-azuredisk
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
storageClassName: azuredisk-csi-zrs
3. Deployment를 배포하여 PV를 생성합니다.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-azuredisk
labels:
app: nginx-azuredisk
spec:
replicas: 3 # Replica 수, 필요에 따라 조절 가능합니다.
selector:
matchLabels:
app: nginx-azuredisk
template:
metadata:
labels:
app: nginx-azuredisk
spec:
containers:
- name: nginx-azuredisk
image: mcr.microsoft.com/oss/nginx/nginx:1.17.3-alpine # 사용할 컨테이너 이미지
ports:
- containerPort: 80
command:
- "/bin/sh"
- "-c"
- while true; do echo $(date) >> /mnt/azuredisk/outfile; sleep 1; done
volumeMounts:
- name: azuredisk01
mountPath: "/mnt/azuredisk"
volumes:
- name: azuredisk01
persistentVolumeClaim:
claimName: pvc-azuredisk
4. 정상적으로 실행되면 Pod에 접속하여 test.txt라는 새 파일을 만듭니다.
kubectl exec <Pod이름> -- touch /mnt/azuredisk/test.txt
5. 디스크가 올바르게 탑재되었는지 확인하려면 다음 명령을 실행하여 출력에 test.txt 파일이 표시되는지 확인합니다.
kubectl exec nginx-azuredisk -- ls /mnt/azuredisk
lost+found
outfile
test.txt
결론
1. Managed Disk ZRS는 Zone에 걸쳐서 사용할 수는 없습니다.
Zone1에서 사용하다가 Zone2로 넘어갈 수 는 있지만 여러 Zone에서 공유해서 사용은 불가합니다.
왜냐하면 ZRS는 ReadWriteOnce만 지원하기 때문입니다.
2. Zone이 동일한 노드 풀 내에서 다른 노드끼리도 공유가 불가합니다.
왜냐하면 ZRS는 ReadWriteOnce만 지원하기 때문입니다.
3. 하나의 Deployment에서 replica 수를 늘리면 같은 노드에 배포된 Pod끼리는 PV를 공유합니다.
4. 서로 다른 Deployment에서 동일한 pv에 연결은 가능합니다.(단, 같은 노드에 위치해야 함)
ReadWrite 모두 가능합니다.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-azuredisk2
labels:
app: nginx-azuredisk2
spec:
replicas: 1 # Replica 수, 필요에 따라 조절 가능합니다.
selector:
matchLabels:
app: nginx-azuredisk2
template:
metadata:
labels:
app: nginx-azuredisk2
spec:
containers:
- name: nginx-azuredisk2
image: mcr.microsoft.com/oss/nginx/nginx:1.17.3-alpine # 사용할 컨테이너 이미지
ports:
- containerPort: 80
command:
- "/bin/sh"
- "-c"
- while true; do echo $(date) >> /mnt/azuredisk/outfile; sleep 1; done
volumeMounts:
- name: azuredisk01
mountPath: "/mnt/azuredisk"
volumes:
- name: azuredisk01
persistentVolumeClaim:
claimName: pvc-azuredisk
'클라우드 > Azure' 카테고리의 다른 글
[Kubernetes] Azure PVC Read-Only로 사용하는 법 (0) | 2025.01.23 |
---|---|
[Kubernetes] Static Volume으로 다중 클러스터 Persistent Volume 연동 (0) | 2025.01.23 |
[Kubernetes] GPU NodePool 사용하기 (0) | 2025.01.23 |
[Kubernetes] AKS Custom Worker Node Image (0) | 2025.01.23 |
[DNS] External DNS 연동 테스트 (0) | 2025.01.23 |