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 Copia collegamentoCollegamento copiato negli appunti!
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 Copia collegamentoCollegamento copiato negli appunti!
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.
Any chosen provisioner plugin also requires configuration for the relevant cloud, host, or third-party provider as in the relevant documentation.
| Storage type | Provisioner plugin name | Notes |
|---|---|---|
| Amazon Elastic Block Store (Amazon EBS) |
|
For dynamic provisioning when using multiple clusters in different zones, tag each node with |
| GCE Persistent Disk (gcePD) |
| 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 |
| 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 Copia collegamentoCollegamento copiato negli appunti!
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.
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 Copia collegamentoCollegamento copiato negli appunti!
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 Copia collegamentoCollegamento copiato negli appunti!
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 fromio1,gp3,sc1,st1. The default isgp3. 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 aretrueorfalse. Optional:
parameters.kmsKeyId. The full ARN of the key to use when encrypting the volume. If none is supplied, butencyptedis set totrue, 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 thefsTypefield of dynamically provisioned persistent volumes, and the file system is created when the volume is mounted for the first time. The default value isext4.
8.3.3. GCE PersistentDisk (gcePD) object definition Copia collegamentoCollegamento copiato negli appunti!
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: Selectpd-ssd,pd-standard, orhyperdisk-balanced. The default ispd-ssd.
8.4. Setting the default storage class Copia collegamentoCollegamento copiato negli appunti!
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
For your required storage class, set the
metadata.annotations.storageclass.kubernetes.io/is-default-classfield totrueas 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" ...NoteThe beta annotation
storageclass.beta.kubernetes.io/is-default-classis still working; however, it will be removed in a future release.Optional: Create a storage class description in the
metadata.annotations.kubernetes.io/descriptionfield 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 Copia collegamentoCollegamento copiato negli appunti!
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
List the storage classes by running the following command:
$ oc get storageclassExample output
NAME TYPE gp3 (default) ebs.csi.aws.com standard ebs.csi.aws.comThe text
(default)indicates the default storage class. In this examplegp3is the current default storage class.Make the required storage class the default.
For the required storage class, set the
storageclass.kubernetes.io/is-default-classannotation totrueby running the following command:$ oc patch storageclass standard -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "true"}}}'NoteYou 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.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-classannotation tofalseby running the following command:$ oc patch storageclass gp3 -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "false"}}}'Verify the changes by running the following command:
$ oc get storageclassExample output
NAME TYPE gp3 ebs.csi.aws.com standard (default) ebs.csi.aws.comThe
standardstorage class is now the default.