Mount a shared Azure disk in Azure Kubernetes to multiple windows PODs

1k views Asked by At

I want to attach a shared disk to multiple windows containers on AKS. From post learned that it can be done for Linux containers.

I am trying to do the same with windows container but it's failing to mount a shared disk, with below error

MapVolume.MapPodDevice failed for volume "pvc-6e07bdca-2126-4a5b-806a-026016c3798d" : rpc error: code = Internal desc = Could not mount "2" at "\var\lib\kubelet\plugins\kubernetes.io\csi\volumeDevices\publish\pvc-6e07bdca-2126-4a5b-806a-026016c3798d\4e44da87-ea33-4d85-a7db-076db0883bcf": rpc error: code = Unknown desc = not an absolute Windows path: 2 Error occured

Used below to dynamically provision Shared Azure Disk

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: managed-csi-custom
provisioner: disk.csi.azure.com
parameters:
  skuname: Premium_LRS  
  maxShares: "2"
  cachingMode: None
reclaimPolicy: Delete
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pvc-azuredisk-dynamic
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 4Gi  
  volumeMode: Block
  storageClassName: managed-csi-custom
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: test-shared-disk
  name: deployment-azuredisk
spec:
  replicas: 2
  selector:
    matchLabels:
      app: test-shared-disk
  template:
    metadata:
      labels:
        app: test-shared-disk
      name: deployment-azuredisk
    spec:
      nodeSelector:
        role: windowsgeneral
      containers:
        - name: deployment-azuredisk
          image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
          volumeDevices:
            - name: azuredisk
              devicePath: "D:\test"
      volumes:
        - name: azuredisk
          persistentVolumeClaim:
            claimName: pvc-azuredisk-dynamic

Is it possible to mount shared disk for windows container on AKS? Thanks for help.

1

There are 1 answers

0
RahulKumarShaw On

Azure shared disks is an Azure managed disks feature that enables attaching an Azure disk to agent nodes simultaneously. But it doesn't apply for window node pool only

To overcome this issue or mounting Azure Disk CSI driver to window node you need to provisoned or create the window node pool first. Please refer this MS tutorial to add a Windows node pool.

After you have a Windows node pool, you can now use the same built-in storage classes managed-csi to mount the DISK.

For more information and Validating Volume Mapping you can refer this MS Document