Please follow the instructions up to step 'Acquire storage account access details' from the document 'Mounting an Azure file share with Azure Container Instances', to create a share and note the following information:
- storage account name
- storage account key
- file share name
ACI connector utilizes kubernetes secrets to save the information required to access Azure file share from the container.
Please follow the steps below to create the kubernetes secret.
-
Fill in the storage account name and key in azurefile.secret.yaml (Note: values needs to be base64 encoded before filling into the file)
-
Run the following command:
kubectl create -f azurefile.secret.yaml
The step above will create a secret with name 'azurefilekey'.
More information about the kubernetes secret can be found at the following link.
Now let's get to the exciting stuff :-)
In the container specification(example provided in busybox.azurefile.yaml), we need to fill in the information at two locations:
- First is the volume mounts. This indicates where we intend the container to mount the volume and the name of the volume.
volumeMounts:
- name: acishare
mountPath: "/mnt/aci/"
- Second is the volume we intend to mount. In our case the volume is an azure file share.
volumes:
- name: acishare
azureFile:
secretName: azurefilekey
shareName: < azure file share name>
readOnly: false
Please fill the 'shareName' collected when creating the file share in Azure initially and fill in the kubernetes secret name in 'secretName'. At this point we are ready to run the container creation command by using:
kubectl -f busybox.azurefile.yaml
A sample DockerFile is provided for reference on how to create an busybox image which watches the mounted azure file share.
Here is the output from a container created using the files from the samples. We can run:
az container logs --name <container name> --resource-group <resource name>
to get the logs from the console. Here is part of the logs from the container:
Every 2s: ls /mnt/aci
test1
test2