Questo contenuto non è disponibile nella lingua selezionata.

Chapter 8. Dynamic provisioning


In dynamic provisioning, instead of a manually creating a pool of persistent volumes (PVs), an administrator creates a storage class. Using the storage class, OpenShift Dedicated automatically triggers the storage backend to create a brand-new volume of the exact size and type requested, creates the PV object, and then the PV binds to the persistent volume claim (PVC).

8.1. About dynamic provisioning

The StorageClass resource object describes and classifies storage that can be requested, and provides a means for passing parameters for dynamically provisioned storage on-demand.

StorageClass objects can also serve as a management mechanism for controlling different levels of storage and access to the storage. Cluster Administrators (cluster-admin) or Storage Administrators (storage-admin) define and create the StorageClass objects that users can request without needing any detailed knowledge about the underlying storage volume sources.

The OpenShift Dedicated 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 OpenShift Dedicated. 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.

8.2. Available dynamic provisioning plugins

Provisioner plugins automatically create storage resources on-demand by connecting to your cloud provider’s API. This lets you dynamically provision persistent volumes (PVs) without manual intervention, adapting to your cluster’s storage needs as they arise.

Important

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

Expand
Storage typeProvisioner plugin nameNotes

Amazon Elastic Block Store (Amazon EBS)

ebs.csi.aws.com

For dynamic provisioning when using multiple clusters in different zones, tag each node with Key=kubernetes.io/cluster/<cluster_name>,Value=<cluster_id> where <cluster_name> and <cluster_id> are unique per cluster.

GCE Persistent Disk (gcePD)

kubernetes.io/gce-pd

In multi-zone configurations, it is advisable to run one OpenShift Dedicated cluster per GCE project to avoid persistent volumes (PVs) from being created in zones where no node exists in the current cluster.

IBM Power® Virtual Server Block

powervs.csi.ibm.com

After installation, the IBM Power® Virtual Server Block CSI Driver Operator and IBM Power® Virtual Server Block CSI Driver automatically create the required storage classes for dynamic provisioning.

8.3. Defining a storage class

StorageClass objects apply cluster-wide and are available to all namespaces. Only users with cluster-admin or storage-admin privileges can create or modify them. This centralized control ensures consistent storage policies across your cluster while requiring application teams to coordinate with administrators for custom storage configurations.

Important

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 required, you must define a custom storage class.

The following sections describe the basic definition for a StorageClass object and specific examples for each of the supported plugin types.

8.3.1. Basic StorageClass object definition

A StorageClass object defines the metadata, provisioner type, and plugin-specific parameters that determine how persistent volumes (PVs) are dynamically created in your cluster. Each storage provisioner type requires different parameters, and annotations control cluster-wide defaults, making this structure the foundation for all dynamic storage provisioning.

Example StorageClass definition

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: <storage-class-name>
  annotations:
    storageclass.kubernetes.io/is-default-class: 'true'
    ...
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp3
...

  • kind: API object type.
  • apiversion: The current apiVersion.
  • metadata.name: The name of the storage class.
  • Optional: metadata.annotations: Annotations for the storage class.
  • provisioner: The type of provisioner associated with this storage class.
  • Optional: parameters: The parameters required for the specific provisioner. This is different for each plugin.

8.3.2. AWS Elastic Block Store (EBS) StorageObject object definition

This AWS EBS storage class example shows how to configure volume type, IOPS performance, encryption settings, and filesystem type for dynamically provisioned persistent volumes.

Example AWS EBS storage class YAML file

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: <storage-class-name>
provisioner: ebs.csi.aws.com
parameters:
  type: io1
  iopsPerGB: "10"
  encrypted: "true"
  kmsKeyId: keyvalue
  fsType: ext4

  • metadata.name: Name of the storage class. The persistent volume claim uses this storage class for provisioning the associated persistent volumes.
  • parameters.type: Select from io1, gp3, sc1, st1. The default is gp3. For valid Amazon Resource Name (ARN) values, see the AWS documentation, Identify AWS resources with Amazon Resource Names (ARNs).
  • Optional: parameters.iopsPerGB. 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 maximum value is 20,000 IOPS, which is the maximum supported by AWS.

    For more information, see the AWS documentation, Identify AWS resources with Amazon Resource Names (ARNs).

  • Optional: parameters.encrypted. Indicates whether to encrypt the EBS volume. Valid values are true or false.
  • Optional: parameters.kmsKeyId. 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.

    For valid ARN values, see the AWS documentation, Identify AWS resources with Amazon Resource Names (ARNs).

  • Optional: parameters.fsType. 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 ext4.

8.3.3. GCE PersistentDisk (gcePD) object definition

This Google Compute Engine Persistent Disk (GCE PD) storage class example shows how to configure disk performance tiers (SSD, standard, or hyperdisk-balanced), enable volume expansion, and use delayed binding to optimize zone placement for your workloads.

Example GCE PD storage class YAML file

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: <storage-class-name>
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-ssd
  replication-type: none
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
reclaimPolicy: Delete

  • metadata.name: The name of the storage class. The persistent volume claim uses this storage class for provisioning the associated persistent volumes.
  • parameters.type: Select pd-ssd, pd-standard, or hyperdisk-balanced. The default is pd-ssd.

8.4. Setting the default storage class

A default storage class automatically provisions persistent volumes when you create persistent volume claims (PVCs) without specifying a storage class. This simplifies storage management by removing the need for users to select a storage class for each claim. To designate a storage class as the cluster-wide default, add an annotation to the storage class metadata.

Prerequisites

  • Logged in to a running OpenShift Dedicated cluster with administrator privileges.

Procedure

  1. For your required storage class, set the metadata.annotations.storageclass.kubernetes.io/is-default-class field to true as in the following example:

    Example storage class YAML file

    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      annotations:
        storageclass.kubernetes.io/is-default-class: "true"
    ...

    Note

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

  2. Optional: Create a storage class description in the metadata.annotations.kubernetes.io/description field as in the following example:

    Example storage class YAML file

    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      annotations:
        kubernetes.io/description: My Storage Class Description
    ...

8.5. Changing the default storage class

Change the default storage class to ensure new persistent volume claims (PVCs) automatically use your preferred storage backend. This helps you optimize costs, align with infrastructure changes, or ensure consistent storage types across new deployments without requiring users to specify a storage class for each claim.

In this example, 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

  1. List the storage classes by running the following command:

    $ oc get storageclass

    Example output

    NAME                 TYPE
    gp3 (default)        ebs.csi.aws.com
    standard             ebs.csi.aws.com

    The text (default) indicates the default storage class. In this example gp3 is the current default storage class.

  2. Make the required storage class the default.

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

    $ oc patch storageclass standard -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "true"}}}'
    Note

    You can have many default storage classes for a short time. However, you must ensure that only one default storage class exists eventually.

    With many default storage classes present, any persistent volume claim (PVC) requesting the default storage class (pvc.spec.storageClassName=nil) gets the most recently created default storage class, regardless of the default status of that storage class. The administrator receives an alert in the alerts dashboard that there are many default storage classes, MultipleDefaultStorageClasses.

  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:

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

    $ oc get storageclass

    Example output

    NAME                 TYPE
    gp3                  ebs.csi.aws.com
    standard (default)   ebs.csi.aws.com

    The standard storage class is now the default.

Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni sulla documentazione di Red Hat

Legal Notice

Theme

© 2026 Red Hat
Torna in cima