Bhanu Prakash
Bhanu Prakash

Reputation: 1

Is it possible to mount a shared Azure disk in Azure Kubernetes to multiple PODs/Nodes. At a time

Warning  FailedAttachVolume  49s (x15 over 15m)  attachdetach-controller  AttachVolume.Attach failed for volume "test" : rpc error: code = InvalidArgument desc = Volume capability not supported.

directly I am creating azure disk in resource group level. when pods are running with replicas. the existing disk is not using . i am getting error (Volume capability not supported).

if i place ReadWriteOnce only pod is getting attached to disk and its running another pod in another node is pending state.

can we mount the disk for multi nodes.

 ---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: manual
provisioner: disk.csi.azure.com
parameters:
  skuname: StandardSSD_LRS
  kind: managed
  maxShares: "3"
  cachingMode: None  
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowVolumeExpansion: true

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: test
spec:
  capacity:
    storage: 256Gi
  volumeMode: Block
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain 
  storageClassName: manual   
  azureDisk:
    kind: Managed
    diskURI: /subscriptions/b3446H73N3933/resourceGroups/PPFD-RG-STG/providers/Microsoft.Compute/disks/test
    diskName: test 
    cachingMode: None
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      nodeSelector:
        app: test
      containers: 
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
        volumeDevices:
        - name: test
          devicePath: /data
      volumes:
      - name: test
        persistentVolumeClaim:
          claimName: pod-claim
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
      name: pod-claim
spec:
    resources:
        requests:
          storage: 256Gi
    volumeMode: Block
    storageClassName: "manual"
    volumeName: test
    accessModes:
        - ReadWriteMany

Upvotes: 0

Views: 1038

Answers (1)

CLNRMN
CLNRMN

Reputation: 1457

Azure Disk can only be attached to one AKS Node [1] and has to be used with the option ReadWriteOnce. If you have to use a PersistantVolume across your deployment (ReadWriteMany) then have a look into Azure Files [2].

Before you use Azure Files, check the pricing, since it's different in compare to the Azure Disk [3].

[1]https://learn.microsoft.com/en-us/azure/aks/concepts-storage#azure-disk

[2]https://learn.microsoft.com/en-us/azure/aks/azure-files-csi#use-a-persistent-volume-with-azure-files

[3] https://learn.microsoft.com/en-us/azure/storage/files/understanding-billing

Upvotes: 0

Related Questions