Dynamic provisioning

    The OKD persistent volume framework enables this functionality and allows administrators to provision a cluster with persistent storage. The framework also gives users a way to request those resources without having any knowledge of the underlying infrastructure.

    Many storage types are available for use as persistent volumes in OKD. While all of them can be statically provisioned by an administrator, some types of storage are created dynamically using the built-in provider and plugin APIs.

    OKD provides the following provisioner plugins, which have generic implementations for dynamic provisioning that use the cluster’s configured provider’s API to create new storage resources:

    Any chosen provisioner plugin also requires configuration for the relevant cloud, host, or third-party provider as per the relevant documentation.

    StorageClass objects are currently a globally scoped object and must be created by cluster-admin or storage-admin users.

    The Cluster Storage Operator might install a default storage class depending on the platform in use. This storage class is owned and controlled by the Operator. It cannot be deleted or modified beyond defining annotations and labels. If different behavior is desired, you must define a custom storage class.

    The following resource shows the parameters and default values that you use to configure a storage class. This example uses the AWS ElasticBlockStore (EBS) object definition.

    Sample StorageClass definition

    1(required) The API object type.
    2(required) The current apiVersion.
    3(required) The name of the storage class.
    4(optional) Annotations for the storage class.
    5(required) The type of provisioner associated with this storage class.
    6(optional) The parameters required for the specific provisioner, this will change from plugin to plug-iin.

    Storage class annotations

    To set a storage class as the cluster-wide default, add the following annotation to your storage class metadata:

    1. storageclass.kubernetes.io/is-default-class: "true"

    For example:

    1. apiVersion: storage.k8s.io/v1
    2. kind: StorageClass
    3. metadata:
    4. annotations:
    5. storageclass.kubernetes.io/is-default-class: "true"
    6. ...

    This enables any persistent volume claim (PVC) that does not specify a specific storage class to automatically be provisioned through the default storage class. However, your cluster can have more than one storage class, but only one of them can be the default storage class.

    The beta annotation storageclass.beta.kubernetes.io/is-default-class is still working; however, it will be removed in a future release.

    To set a storage class description, add the following annotation to your storage class metadata:

    1. kubernetes.io/description: My Storage Class Description

    For example:

    1. apiVersion: storage.k8s.io/v1
    2. kind: StorageClass
    3. metadata:
    4. annotations:
    5. kubernetes.io/description: My Storage Class Description
    6. ...

    OpenStack Cinder object definition

    cinder-storageclass.yaml

    1. kind: StorageClass
    2. apiVersion: storage.k8s.io/v1
    3. metadata:
    4. name: <storage-class-name> (1)
    5. provisioner: kubernetes.io/cinder
    6. parameters:
    7. type: fast (2)
    8. availability: nova (3)
    9. fsType: ext4 (4)

    Once installed, the OpenStack Manila CSI Driver Operator and ManilaDriver automatically create the required storage classes for all available Manila share types needed for dynamic provisioning.

    AWS Elastic Block Store (EBS) object definition

    aws-ebs-storageclass.yaml

    1(required) Name of the storage class. The persistent volume claim uses this storage class for provisioning the associated persistent volumes.
    2(required) Select from io1, gp3, sc1, st1. The default is gp3. See the AWS documentation for valid Amazon Resource Name (ARN) values.
    3Optional: Only for io1 volumes. I/O operations per second per GiB. The AWS volume plugin multiplies this with the size of the requested volume to compute IOPS of the volume. The value cap is 20,000 IOPS, which is the maximum supported by AWS. See the for further details.
    4Optional: Denotes whether to encrypt the EBS volume. Valid values are true or false.
    5Optional: The full ARN of the key to use when encrypting the volume. If none is supplied, but encypted is set to true, then AWS generates a key. See the AWS documentation for a valid ARN value.
    6Optional: File system that is created on dynamically provisioned volumes. This value is copied to the fsType field of dynamically provisioned persistent volumes and the file system is created when the volume is mounted for the first time. The default value is .

    Azure Disk object definition

    azure-advanced-disk-storageclass.yaml

    1. apiVersion: storage.k8s.io/v1
    2. metadata:
    3. name: <storage-class-name> (1)
    4. provisioner: kubernetes.io/azure-disk
    5. volumeBindingMode: WaitForFirstConsumer (2)
    6. allowVolumeExpansion: true
    7. parameters:
    8. kind: Managed (3)
    9. storageaccounttype: Premium_LRS (4)
    10. reclaimPolicy: Delete
    1Name of the storage class. The persistent volume claim uses this storage class for provisioning the associated persistent volumes.
    2Using WaitForFirstConsumer is strongly recommended. This provisions the volume while allowing enough storage to schedule the pod on a free worker node from an available zone.
    3Possible values are Shared (default), Managed, and Dedicated.

    Red Hat only supports the use of kind: Managed in the storage class.

    With Shared and Dedicated, Azure creates unmanaged disks, while OKD creates a managed disk for machine OS (root) disks. But because Azure Disk does not allow the use of both managed and unmanaged disks on a node, unmanaged disks created with Shared or Dedicated cannot be attached to OKD nodes.

    4Azure storage account SKU tier. Default is empty. Note that Premium VMs can attach both Standard_LRS and Premium_LRS disks, Standard VMs can only attach Standard_LRS disks, Managed VMs can only attach managed disks, and unmanaged VMs can only attach unmanaged disks.
    1. If kind is set to Shared, Azure creates all unmanaged disks in a few shared storage accounts in the same resource group as the cluster.

    2. If kind is set to Managed, Azure creates new managed disks.

    3. If kind is set to Dedicated and a storageAccount is specified, Azure uses the specified storage account for the new unmanaged disk in the same resource group as the cluster. For this to work:

      • The specified storage account must be in the same region.

      • Azure Cloud Provider must have write access to the storage account.

    4. If kind is set to Dedicated and a storageAccount is not specified, Azure creates a new dedicated storage account for the new unmanaged disk in the same resource group as the cluster.

    The Azure File storage class uses secrets to store the Azure storage account name and the storage account key that are required to create an Azure Files share. These permissions are created as part of the following procedure.

    Procedure

    1. Define a ClusterRole object that allows access to create and view secrets:

      1. apiVersion: rbac.authorization.k8s.io/v1
      2. kind: ClusterRole
      3. metadata:
      4. # name: system:azure-cloud-provider
      5. name: <persistent-volume-binder-role> (1)
      6. rules:
      7. - apiGroups: ['']
      8. resources: ['secrets']
      9. verbs: ['get','create']
      1The name of the cluster role to view and create secrets.
    2. Add the cluster role to the service account:

      1. $ oc adm policy add-cluster-role-to-user <persistent-volume-binder-role> system:serviceaccount:kube-system:persistent-volume-binder
      1. kind: StorageClass
      2. apiVersion: storage.k8s.io/v1
      3. metadata:
      4. name: <azure-file> (1)
      5. provisioner: kubernetes.io/azure-file
      6. parameters:
      7. location: eastus (2)
      8. skuName: Standard_LRS (3)
      9. storageAccount: <storage-account> (4)
      10. reclaimPolicy: Delete

    Considerations when using Azure File

    The following file system features are not supported by the default Azure File storage class:

    • Symlinks

    • Hard links

    • Extended attributes

    • Sparse files

    • Named pipes

    Additionally, the owner user identifier (UID) of the Azure File mounted directory is different from the process UID of the container. The uid mount option can be specified in the StorageClass object to define a specific user identifier to use for the mounted directory.

    The following StorageClass object demonstrates modifying the user and group identifier, along with enabling symlinks for the mounted directory.

    1. kind: StorageClass
    2. apiVersion: storage.k8s.io/v1
    3. metadata:
    4. name: azure-file
    5. mountOptions:
    6. - uid=1500 (1)
    7. - gid=1500 (2)
    8. - mfsymlinks (3)
    9. provisioner: kubernetes.io/azure-file
    10. parameters:
    11. location: eastus
    12. skuName: Standard_LRS
    13. reclaimPolicy: Delete
    14. volumeBindingMode: Immediate
    1Specifies the user identifier to use for the mounted directory.
    2Specifies the group identifier to use for the mounted directory.
    3Enables symlinks.

    GCE PersistentDisk (gcePD) object definition

    gce-pd-storageclass.yaml

    1Name of the storage class. The persistent volume claim uses this storage class for provisioning the associated persistent volumes.
    2Select either pd-standard or pd-ssd. The default is pd-standard.

    VMware vSphere object definition

    vsphere-storageclass.yaml

    1. kind: StorageClass
    2. apiVersion: storage.k8s.io/v1
    3. metadata:
    4. name: <storage-class-name> (1)
    5. provisioner: kubernetes.io/vsphere-volume (2)
    6. parameters:
    7. diskformat: thin (3)
    1Name of the storage class. The persistent volume claim uses this storage class for provisioning the associated persistent volumes.
    2For more information about using VMware vSphere with OKD, see the VMware vSphere documentation.
    3diskformat: thin, zeroedthick and eagerzeroedthick are all valid disk formats. See vSphere docs for additional details regarding the disk format types. The default value is thin.

    Use the following procedure to change the default storage class.

    For example, if you have two defined storage classes, gp3 and standard, and you want to change the default storage class from gp3 to standard.

    Prerequisites

    • Access to the cluster with cluster-admin privileges.

    Procedure

    To change the default storage class:

    1. List the storage classes:

      1. $ oc get storageclass

      Example output

      1. NAME TYPE
      2. gp3 (default) kubernetes.io/aws-ebs (1)
      3. standard kubernetes.io/aws-ebs
      1(default) indicates the default storage class.
    2. Make the desired storage class the default.

      For the desired storage class, set the storageclass.kubernetes.io/is-default-class annotation to true by running the following command:

      1. $ oc patch storageclass standard -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "true"}}}'
    3. Remove the default storage class setting from the old default storage class.

      For the old default storage class, change the value of the storageclass.kubernetes.io/is-default-class annotation to false by running the following command:

      1. $ oc patch storageclass gp3 -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "false"}}}'
    4. Verify the changes:

      1. NAME TYPE
      2. standard (default) kubernetes.io/aws-ebs