Create a persistent volume (preview)
This article describes how to create a persistent volume using storage key authentication.
Prerequisites
This section describes the prerequisites for creating a persistent volume (PV).
Create a storage account following the instructions here.
Note
When you create your storage account, create it under the same resource group and region/location as your Kubernetes cluster.
Create a container in the storage account that you created in the previous step, following the instructions here.
Storage key authentication configuration
Create a file named add-key.sh with the following contents. No edits or changes are necessary:
#!/usr/bin/env bash while getopts g:n:s: flag do case "${flag}" in g) RESOURCE_GROUP=${OPTARG};; s) STORAGE_ACCOUNT=${OPTARG};; n) NAMESPACE=${OPTARG};; esac done SECRET=$(az storage account keys list -g $RESOURCE_GROUP -n $STORAGE_ACCOUNT --query [0].value --output tsv) kubectl create secret generic -n "${NAMESPACE}" "${STORAGE_ACCOUNT}"-secret --from-literal=azurestorageaccountkey="${SECRET}" --from-literal=azurestorageaccountname="${STORAGE_ACCOUNT}"
After you create the file, change the write permissions on the file and execute the shell script using the following commands. Running these commands creates a secret named
{YOUR_STORAGE_ACCOUNT}-secret
. This secret name is used for thesecretName
value when configuring your PV:chmod +x add-key.sh ./add-key.sh -g "$YOUR_RESOURCE_GROUP_NAME" -s "$YOUR_STORAGE_ACCOUNT_NAME" -n "$YOUR_KUBERNETES_NAMESPACE"
Create Persistent Volume (PV)
You must create a Persistent Volume (PV) for the Edge Storage Accelerator to create a local instance and bind to a remote BLOB storage account.
Note the metadata: name:
as you must specify it in the spec: volumeName
of the PVC that binds to it. Use your storage account and container that you created as part of the prerequisites.
Create a file named pv.yaml:
apiVersion: v1 kind: PersistentVolume metadata: ### Create a name here ### name: CREATE_A_NAME_HERE ### Use a namespace that matches your intended consuming pod, or "default" ### namespace: INTENDED_CONSUMING_POD_OR_DEFAULT_HERE spec: capacity: ### This storage capacity value is not enforced at this layer. ### storage: 10Gi accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain storageClassName: esa csi: driver: edgecache.csi.azure.com readOnly: false ### Make sure this volumeid is unique in the cluster. You must specify it in the spec:volumeName of the PVC. ### volumeHandle: YOUR_NAME_FROM_METADATA_NAME_IN_LINE_4_HERE volumeAttributes: protocol: edgecache edgecache-storage-auth: AccountKey ### Fill in the next two/three values with your information. ### secretName: YOUR_SECRET_NAME_HERE ### From the previous step, this name is "{YOUR_STORAGE_ACCOUNT}-secret" ### ### If you use a non-default namespace, uncomment the following line and add your namespace. ### ### secretNamespace: YOUR_NAMESPACE_HERE containerName: YOUR_CONTAINER_NAME_HERE
To apply this .yaml file, run:
kubectl apply -f "pv.yaml"
Next steps
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for