보통 Azure를 사용할 때 1개 클러스터에서 동적으로 볼륨을 할당받아 사용한다. 하지만 특수한 경우에 다중 클러스터에서 동일한 스토리지를 마운트하여 사용해야 하는 경우가 존재한다. Azure에서는 정적 볼륨을 사용하여 해당 문제를 해결할 수 있다.
테스트 환경
- 스토리지 스펙 : Standard_ZRS General_v2 Storage Account
- 클러스터 스펙 : Azure Kubernetes 1.27.3
테스트
1. 볼륨으로 사용할 Strage Account Container를 하나 생성합니다.
2. 생성한 Storage Account 액세스 키를 토대로 Kubernetes Secret을 생성합니다.
kubectl create secret generic azure-storage-account-secret --from-literal azurestorageaccountname=NAME --from-literal azurestorageaccountkey="KEY" --type=Opaque
3. Storage Class 를 생성합니다.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: <StorageClassName>
provisioner: blob.csi.azure.com
parameters:
resourceGroup: <ResourceGroup>
storageAccount: <StorageAccountName>
server: <StorageAccountDNS>
skuName: Standard_ZRS # available values: Standard_LRS, Premium_LRS, Standard_GRS, Standard_RAGRS, Standard_ZRS, Premium_ZRS
reclaimPolicy: Retain
volumeBindingMode: Immediate
allowVolumeExpansion: true
mountOptions:
- -o allow_other
- --file-cache-timeout-in-seconds=120
- --use-attr-cache=true
- --cancel-list-on-mount-seconds=10 # prevent billing charges on mounting
- -o attr_timeout=120
- -o entry_timeout=120
- -o negative_timeout=120
- --log-level=LOG_WARNING # LOG_WARNING, LOG_INFO, LOG_DEBUG
- --cache-size-mb=1000 # Default will be 80% of available memory, eviction will happen beyond that.
4. PersistentVolume을 생성합니다.
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
pv.kubernetes.io/provisioned-by: blob.csi.azure.com
name: <PersistentVolumeName>
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain # If set as "Delete" container would be removed after pvc deletion
storageClassName: <StorageClassName>
mountOptions:
- -o allow_other
- --file-cache-timeout-in-seconds=120
csi:
driver: blob.csi.azure.com
readOnly: false
# volumeid has to be unique for every identical storage blob container in the cluster
# character `#`and `/` are reserved for internal use and cannot be used in volumehandle
volumeHandle: unique-volumeid
volumeAttributes:
containerName: <ContainerName>
nodeStageSecretRef:
name: <SecretName>
namespace: <SecretNamespace>
5. PersistentVolumeClaim을 생성합니다.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: <PersistentVolumeClaimName>
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
volumeName: <PersistentVolumeName>
storageClassName: <StorageClassName>
6. 상기 작업을 다중 클러스터 내에서 동일하게 진행하면 1개 PV를 다중 클러스터가 사용 가능합니다.
참고 링크
AKS(Azure Kubernetes Service)에서 Azure Blob Storage로 영구 볼륨 만들기 - Azure Kubernetes Service
AKS(Azure Kubernetes Service)에서 여러 Pod에 동시 사용하기 위해 Azure Blob Storage로 정적 또는 동적 영구 볼륨을 만드는 방법을 알아봅니다.
learn.microsoft.com
'클라우드 > Azure' 카테고리의 다른 글
[ApplicationGateway] 종단 간 TLS 통신 구성 (0) | 2025.01.23 |
---|---|
[Kubernetes] Azure PVC Read-Only로 사용하는 법 (0) | 2025.01.23 |
[Kubernetes] AKS Managed Disk ZRS 테스트 (0) | 2025.01.23 |
[Kubernetes] GPU NodePool 사용하기 (0) | 2025.01.23 |
[Kubernetes] AKS Custom Worker Node Image (0) | 2025.01.23 |