Binding Persistent Volumes by Labels

    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 topic provides an end-to-end example for binding persistent volume claims (PVCs) to , by defining labels in the PV and matching selectors in the PVC. This feature is available for all storage options. It is assumed that a OKD cluster contains persistent storage resources which are available for binding by PVCs.

    A Note on Labels and Selectors

    Labels are an OKD feature that support user-defined tags (key-value pairs) as part of an object’s specification. Their primary purpose is to enable the arbitrary grouping of objects by defining identical labels among them. These labels can then be targeted by selectors to match all objects with specified label values. It is this functionality we will take advantage of to enable our PVC to bind to our PV. For a more in-depth look at labels, see .

    • An existing OKD cluster with at least one master and one node

    • A user with cluster-admin privileges

    Defining Specifications

    Example 1. glusterfs-pv.yaml

    It is important to note that a claim must match all of the key-value pairs included in its selector stanza. If no PV matches the claim, then the PVC will remain unbound (Pending). A PV can subsequently be created and the claim will automatically check for a label match.

    Example 2. glusterfs-pvc.yaml

    To attach the PV to the Gluster volume, endpoints should be configured before creating our objects.

    Example 3. glusterfs-ep.yaml

    For this example, run the oc commands as a cluster-admin privileged user. In a production environment, cluster clients might be expected to define and create the PVC.