Persistent storage using Azure File

OKD supports Microsoft Azure File volumes. You can provision your OKD cluster with persistent storage using Azure. Some familiarity with Kubernetes and Azure is assumed.

The Kubernetes persistent volume framework allows administrators to provision a cluster with persistent storage and gives users a way to request those resources without having any knowledge of the underlying infrastructure. You can provision Azure File volumes dynamically.

Persistent volumes are not bound to a single project or namespace, and you can share them across the OKD cluster. Persistent volume claims are specific to a project or namespace, and can be requested by users for use in applications.

High availability of storage in the infrastructure is left to the underlying storage provider.

Azure File volumes use Server Message Block.

Additional resources

Create the Azure File share persistent volume claim

To create the persistent volume claim, you must first define a Secret object that contains the Azure account and key. This secret is used in the PersistentVolume definition, and will be referenced by the persistent volume claim for use in applications.

Prerequisites

  • An Azure File share exists.

  • The credentials to access this share, specifically the storage account and key, are available.

Procedure

  1. Create a Secret object that contains the Azure File credentials:

    1. $ oc create secret generic <secret-name> --from-literal=azurestorageaccountname=<storage-account> \ (1)
    2. --from-literal=azurestorageaccountkey=<storage-account-key> (2)
    1The Azure File storage account name.
    2The Azure File storage account key.
  2. Create a PersistentVolume object that references the Secret object you created:

    1. apiVersion: "v1"
    2. kind: "PersistentVolume"
    3. metadata:
    4. name: "pv0001" (1)
    5. spec:
    6. capacity:
    7. storage: "5Gi" (2)
    8. accessModes:
    9. - "ReadWriteOnce"
    10. storageClassName: azure-file-sc
    11. azureFile:
    12. secretName: <secret-name> (3)
    13. shareName: share-1 (4)
    14. readOnly: false
    1The name of the persistent volume.
    2The size of this persistent volume.
    3The name of the secret that contains the Azure File share credentials.
    4The name of the Azure File share.
  3. Create a PersistentVolumeClaim object that maps to the persistent volume you created:

    1. apiVersion: "v1"
    2. kind: "PersistentVolumeClaim"
    3. metadata:
    4. name: "claim1" (1)
    5. spec:
    6. accessModes:
    7. - "ReadWriteOnce"
    8. resources:
    9. requests:
    10. storage: "5Gi" (2)
    11. storageClassName: azure-file-sc (3)
    12. volumeName: "pv0001" (4)
    1The name of the persistent volume claim.
    2The size of this persistent volume claim.
    3The name of the storage class that is used to provision the persistent volume. Specify the storage class used in the PersistentVolume definition.
    4The name of the existing PersistentVolume object that references the Azure File share.

Mount the Azure File share in a pod

After the persistent volume claim has been created, it can be used inside by an application. The following example demonstrates mounting this share inside of a pod.

Prerequisites

  • A persistent volume claim exists that is mapped to the underlying Azure File share.

Procedure

  • Create a pod that mounts the existing persistent volume claim:

    1. apiVersion: v1
    2. kind: Pod
    3. metadata:
    4. name: pod-name (1)
    5. spec:
    6. containers:
    7. ...
    8. volumeMounts:
    9. - mountPath: "/data" (2)
    10. name: azure-file-share
    11. volumes:
    12. - name: azure-file-share
    13. persistentVolumeClaim:
    14. claimName: claim1 (3)
    1The name of the pod.
    2The path to mount the Azure File share inside the pod. Do not mount to the container root, /, or any path that is the same in the host and the container. This can corrupt your host system if the container is sufficiently privileged, such as the host /dev/pts files. It is safe to mount the host by using /host.
    3The name of the PersistentVolumeClaim object that has been previously created.