Selector-Label Volume Binding
You are viewing documentation for a release that is no longer supported. The latest supported version of version 3 is [3.11]. For the most recent version 4, see
This guide provides the steps necessary to enable binding of persistent volume claims (PVCs) to persistent volumes (PVs) via selector and label attributes. By implementing selectors and labels, regular users are able to target provisioned storage by identifiers defined by a cluster administrator.
In cases of statically provisioned storage, developers seeking persistent storage are required to know a handful identifying attributes of a PV in order to deploy and bind a PVC. This creates several problematic situations. Regular users might have to contact a cluster administrator to either deploy the PVC or provide the PV values. PV attributes alone do not convey the intended use of the storage volumes, nor do they provide methods by which volumes can be grouped.
Selector and label attributes can be used to abstract away PV details from the user while providing cluster administrators a way of identifying volumes by a descriptive and customizable tag. Through the selector-label method of binding, users are only required to know which labels are defined by the administrator.
A running OKD 3.3+ cluster
A user with a cluster-admin role binding
As the cluser-admin user, define the PV. For this example, we will be using a volume. See the appropriate storage provider for your provider’s configuration.
Example 1. Persistent Volume with Labels
-
Example 2. Persistent Volume Claim with Selectors
As the cluster-admin user, create the persistent volume:
Example 3. Create the Persistent Volume
Once the PV is created, any user whose selectors match all its labels can create their PVC.
Example 4. Create the Persistent Volume Claim