This is a cache of https://docs.openshift.com/container-platform/4.2/storage/persistent_storage/persistent-storage-azure-file.html. It is a snapshot of the page at 2024-11-26T02:36:39.388+0000.
Persistent storage using Azure File - Configuring persistent storage | Storage | OpenShift Container Platform 4.2
×

OpenShift Container Platform supports Microsoft Azure File volumes. You can provision your OpenShift Container Platform 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. Azure File volumes can be provisioned dynamically.

PersistentVolumes are not bound to a single project or namespace; they can be shared across the OpenShift Container Platform cluster. PersistentVolumeClaims 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.

Additional references

Create the Azure File share PersistentVolumeClaim

To create the PersistentVolumeClaim, you must first define a secret that contains the Azure account and key. This secret is used in the PersistentVolume definition, and will be referenced by the PersistentVolumeClaim 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 that contains the Azure File credentials:

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

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

    apiVersion: "v1"
    kind: "PersistentVolumeClaim"
    metadata:
      name: "claim1" (1)
    spec:
      accessModes:
        - "ReadWriteOnce"
      resources:
        requests:
          storage: "5Gi" (2)
      storageClassName: azure-file-sc (3)
      volumeName: "pv0001" (4)
    1 The name of the PersistentVolumeClaim.
    2 The size of this PersistentVolumeClaim.
    3 The name of the StorageClass that is used to provision the PersistentVolume. Specify the StorageClass used in the PersistentVolume definition.
    4 The name of the existing PersistentVolume that references the Azure File share.

Mount the Azure File share in a Pod

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

Prerequisites
  • A PersistentVolumeClaim exists that is mapped to the underlying Azure File share.

Procedure
  • Create a Pod that mounts the existing PersistentVolumeClaim:

    apiVersion: v1
    kind: Pod
    metadata:
      name: pod-name (1)
    spec:
      containers:
        ...
        volumeMounts:
        - mountPath: "/data" (2)
          name: azure-file-share
      volumes:
        - name: azure-file-share
          persistentVolumeClaim:
            claimName: claim1 (3)
    1 The name of the Pod.
    2 The path to mount the Azure File share inside the Pod.
    3 The name of the PersistentVolumeClaim that has been previously created.