1

we plan to use Azure Kubernetes Service for K8S. We have our Azure File Share. Is it possible to reference somehow Azure File Share within the Pod or Deployment yaml definition so that volume can be mounted on the container (Pod) level? Is this reference something which needs to be defined during the AKS cluster creation or it is enough to reference it somehow when we execute kubectl apply command to deploy our containers Pods.

Thanks

vel
  • 1,000
  • 1
  • 13
  • 35

1 Answers1

1

So, as per Mount the file share as a volume documentation, provided by @AndreyDonald, you can reference like this

apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - image: mcr.microsoft.com/oss/nginx/nginx:1.15.5-alpine
    name: mypod
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 250m
        memory: 256Mi
    volumeMounts:
      - name: azure
        mountPath: /mnt/azure
  volumes:
  - name: azure
    azureFile:
      secretName: azure-secret
      shareName: aksshare
      readOnly: false

But prior to that you should Create a Kubernetes secret.

kubectl create secret generic azure-secret --from-literal=azurestorageaccountname=$AKS_PERS_STORAGE_ACCOUNT_NAME --from-literal=azurestorageaccountkey=$STORAGE_KEY

And in order to create that secret you should use assign correct values to vars

$AKS_PERS_STORAGE_ACCOUNT_NAME
$STORAGE_KEY

You dont have to create new File Share, just

# Get storage account key
STORAGE_KEY=$(az storage account keys list --resource-group $AKS_PERS_RESOURCE_GROUP --account-name $AKS_PERS_STORAGE_ACCOUNT_NAME --query "[0].value" -o tsv)

and use it.

Vit
  • 7,740
  • 15
  • 40
  • Thanks, but I am confused also in which cases I need to use PersistentVolume and PersistentVolumeClaim?? I do not need it for this use case? I can reference mount volume without an issue? Thank you – vel Feb 01 '21 at 14:17
  • can you please tell me if PersistenVolume and PersistentVolumeClaim should be defined as well through their dedicated yaml files? – vel Feb 01 '21 at 18:19
  • can you please tell me if PersistentVolument and PersistentVolumeClaim should be defined within the YAML as well? Thanks – vel Feb 02 '21 at 18:31