Azure Course Labs

Lab Solution

You need to set the access mode and the storage class name in the PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-azurefile
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: azurefile
  resources:
    # ...

The sample file in lab/pvc-azurefile.yaml does that. The updated lab/deployment.yaml uses the new PVC.

Update the deployment:

kubectl apply -f labs/aks-persistentvolumes/lab/

kubectl get pods --watch

It will take a minute or two for the new Azure Files storage to get provisioned. When the new Pods are running you could delete one:

kubectl delete pod <pod-name>

And then check the database file in any of the Pods:

kubectl exec -it deploy/queue-worker -- cat /mnt/database/app.db

In the Portal if you open the autogenerated MC_ Resource Group, you’ll see a Storage Account resource with a random name. Open that and select File shares on the left nav. You’ll see a share with a random name, starting pvc-. Open that and you’ll see the app.db file the Pods are writing to (you can even edit in the Portal and see the changes in the Pod).

The file share is available to multiple Pods on multiple Nodes.