How to mount a volume with a windows container in kubernetes?

6/7/2018

i'm trying to mount a persistent volume into my windows container, but i alwys get this error:

Unable to mount volumes for pod "mssql-with-pv-deployment-3263067711-xw3mx_default(....)": timeout expired waiting for volumes to attach/mount for pod "default"/"mssql-with-pv-deployment-3263067711-xw3mx". list of unattached/unmounted volumes=[blobdisk01]

i've created a github gist with the console output of "get events" and "describe sc | pvc | po" maybe someone will find the solution with it.

Below are my scripts that I'm using for deployment.

my storageclass:

kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: azure-disk-sc provisioner: kubernetes.io/azure-disk parameters: skuname: Standard_LRS

my PersistentVolumeClaim:

apiVersion: v1 kind: PersistentVolumeClaim metadata: name: azure-disk-pvc spec: storageClassName: azure-disk-sc accessModes:

  • ReadWriteOnce resources: requests: storage: 20Gi

and the deployment of my container:

apiVersion: apps/v1beta1 kind: Deployment metadata: name: mssql-with-pv-deployment spec: replicas: 1 template: metadata: labels: app: mssql-with-pv spec: nodeSelector: beta.kubernetes.io/os: windows terminationGracePeriodSeconds: 10 containers: - name: mssql-with-pv image: testacr.azurecr.io/sql/mssql-server-windows-developer ports: - containerPort: 1433 env: - name: ACCEPT_EULA value: "Y" - name: SA_PASSWORD valueFrom: secretKeyRef: name: mssql key: SA_PASSWORD volumeMounts: - mountPath: "c:/volume" name: blobdisk01 volumes: - name: blobdisk01 persistentVolumeClaim:

      claimName: azure-disk-pvc

apiVersion: v1 kind: Service metadata: name: mssql-with-pv-deployment spec: selector: app: mssql-with-pv ports: - protocol: TCP port: 1433 targetPort: 1433 type: LoadBalancer

what am i doing wrong? is there another way to mount a volume?

thank for every help :)

-- Lukas
azure
azure-container-service
docker
kubernetes

2 Answers

6/10/2018

I would try:

  1. Change API version to v1: https://kubernetes.io/docs/concepts/storage/storage-classes/#azure-disk
  2. kubectl get events to see you if have a more detailed error (I could figure out the reason when I used NFS watching events)
  3. maybe is this bug, I read in this post?
-- Nicola Ben
Source: StackOverflow

10/29/2019

You will need a new volume in D: drive, looks like folders in C: are not supported for Windows Containers, see here:

https://github.com/kubernetes/kubernetes/issues/65060

Demos: https://github.com/andyzhangx/demo/tree/master/windows/azuredisk

-- glm
Source: StackOverflow