.NET on 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 labs/storage/lab/pvc-azurefile.yaml does that. The updated labs/storage/lab/deployment.yaml uses the new PVC.

Update the deployment:

kubectl apply -f labs/storage/lab/

kubectl get pods --watch

It will take a minute or two for the new Azure Files storage to get provisioned. When the new Pod is running you can delete it:

kubectl delete pod <pod-name>

And then check the database file in the new Pod:

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).