Provision Azure NetApp Files dual-protocol volumes for Azure Kubernetes Service

After you configure Azure NetApp Files for Azure Kubernetes Service, you can provision Azure NetApp Files volumes for Azure Kubernetes Service.

Azure NetApp Files supports volumes using NFS (NFSv3 or NFSv4.1), SMB, and dual-protocol (NFSv3 and SMB, or NFSv4.1 and SMB).

This article shows you how to statically provisioning volumes for dual-protocol access using NFS or SMB.

Before you begin

Provision a dual-protocol volume in Azure Kubernetes Service

This section describes how to expose an Azure NetApp Files dual-protocol volume statically to Kubernetes. Instructions are provided for both SMB and NFS protocols. You can expose the same volume via SMB to Windows worker nodes and via NFS to Linux worker nodes.

Create the persistent volume for NFS

  1. Define variables for later usage. Replace myresourcegroup, myaccountname, mypool1, myvolname with an appropriate value from your dual-protocol volume.

    RESOURCE_GROUP="myresourcegroup"
    ANF_ACCOUNT_NAME="myaccountname"
    POOL_NAME="mypool1"
    VOLUME_NAME="myvolname"
    
  2. List the details of your volume using the az netappfiles volume show command.

    az netappfiles volume show \
        --resource-group $RESOURCE_GROUP \
        --account-name $ANF_ACCOUNT_NAME \
        --pool-name $POOL_NAME \
        --volume-name $VOLUME_NAME -o JSON
    

    The following output is an example of the above command executed with real values.

    {
      ...
      "creationToken": "myfilepath2",
      ...
      "mountTargets": [
        {
          ...
          "ipAddress": "10.0.0.4",
          ...
        }
      ],
      ...
    }
    
  3. Create a file named pv-nfs.yaml and copy in the following YAML. Make sure the server matches the output IP address from the previous step, and the path matches the output from creationToken above. The capacity must also match the volume size from Step 2.

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: pv-nfs
    spec:
      capacity:
        storage: 100Gi
      accessModes:
        - ReadWriteMany
      mountOptions:
        - vers=3
      nfs:
        server: 10.0.0.4
        path: /myfilepath2
    
  4. Create the persistent volume using the kubectl apply command:

    kubectl apply -f pv-nfs.yaml
    
  5. Verify the status of the persistent volume is Available by using the kubectl describe command:

    kubectl describe pv pv-nfs
    

Create a persistent volume claim for NFS

  1. Create a file named pvc-nfs.yaml and copy in the following YAML. This manifest creates a PVC named pvc-nfs for 100Gi storage and ReadWriteMany access mode, matching the PV you created.

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: pvc-nfs
    spec:
      accessModes:
        - ReadWriteMany
      storageClassName: ""
      resources:
        requests:
          storage: 100Gi
    
  2. Create the persistent volume claim using the kubectl apply command:

    kubectl apply -f pvc-nfs.yaml
    
  3. Verify the Status of the persistent volume claim is Bound by using the kubectl describe command:

    kubectl describe pvc pvc-nfs
    

Mount within a pod using NFS

  1. Create a file named nginx-nfs.yaml and copy in the following YAML. This manifest defines a nginx pod that uses the persistent volume claim.

    kind: Pod
    apiVersion: v1
    metadata:
      name: nginx-nfs
    spec:
      containers:
      - image: mcr.microsoft.com/oss/nginx/nginx:1.15.5-alpine
        name: nginx-nfs
        command:
        - "/bin/sh"
        - "-c"
        - while true; do echo $(date) >> /mnt/azure/outfile; sleep 1; done
        volumeMounts:
        - name: disk01
          mountPath: /mnt/azure
      volumes:
      - name: disk01
        persistentVolumeClaim:
          claimName: pvc-nfs
    
  2. Create the pod using the kubectl applykubectl-apply command:

    kubectl apply -f nginx-nfs.yaml
    
  3. Verify the pod is Running by using the kubectl apply command:

    kubectl describe pod nginx-nfs
    
  4. Verify your volume has been mounted on the pod by using kubectl exec to connect to the pod, and then use df -h to check if the volume is mounted.

    kubectl exec -it nginx-nfs -- sh
    
    / # df -h
    Filesystem             Size  Used Avail Use% Mounted on
    ...
    10.0.0.4:/myfilepath2  100T  384K  100T   1% /mnt/azure
    ...
    

Next steps

Astra Trident supports many features with Azure NetApp Files. For more information, see: