Skip to main content
Version: 3.7

Control Static and Dynamic Pools by Using VPS

A dynamic pool becomes static if it contains a volume with repl=2 or higher, a SharedV4 volume, or a volume with a journal profile. If the node hosting the pool fails, Portworx cannot fail over the pool.

To prevent this, use volume placement strategies (VPS) to control volume placement based on pool labels. By labeling storage pools as static or dynamic and configuring separate placement rules for each pool type, you can keep volumes that prevent pool failover on designated static pools.

This procedure describes how to label storage pools, create VolumePlacementStrategy and StorageClass objects for each pool type, and verify volume placement.

For information about VPS concepts and configuration, see Volume Placement Strategies and Create and use VolumePlacementStrategies.

Before you begin​

Ensure that the following requirements are met:

  • Dynamic pools are enabled on your cluster. For more information, see Configure Dynamic Pools During Installation or Upgrade.

  • Review the volume requirements for dynamic pools. For more information, see Maintain Dynamic Pool Failover Eligibility.

  • Identify the storage pools that you want to use as static and dynamic pools. Designate pools that already contain volumes with repl=2 or higher, SharedV4 volumes, or volumes with journal profiles as static pools.

  • No Kubernetes node has the pool-type label. A node label overrides the corresponding label on the storage pools of that node.

    To verify this requirement, run:

    kubectl get nodes -L pool-type

    Verify that the POOL-TYPE column is empty for all nodes.

Label the storage pools​

Use a custom label to identify the intended use of each storage pool. This procedure uses pool-type as the label key and dynamic and static as its values. You can choose any custom label key and values that suit your environment. Ensure that the label key and values match those specified in your VPS rules.

The following example uses the pool-type label:

  • pool-type=dynamic: Identifies pools intended for volumes that meet dynamic pool requirements.
  • pool-type=static: Identifies pools intended for volumes with repl=2 or higher, SharedV4 volumes, or volumes with journal profiles.

The pool-type label controls volume placement through VPS rules. Assigning this label does not change the actual dynamic or static status of a pool.

  1. List the storage pools:

    pxctl service pool show

    Note the UUID of each pool and the node that currently hosts the pool.

  2. From the Portworx pod on the node that hosts the pool, run the following command to assign the label:

    pxctl service pool update --uid <pool-uuid> --labels pool-type=<dynamic|static>

    Replace:

    • <pool-uuid> with the UUID of the storage pool.
    • <dynamic|static> with dynamic or static, depending on the intended use of the pool.
  3. Repeat the previous step for each storage pool that you want to label.

    note
    • Use the --uid option to specify the pool UUID. Otherwise, the command fails with invalid pool ID.
    • Run the command on the node that currently hosts the pool. Otherwise, the command fails with not found on this node. Because dynamic pools can move between nodes during failover and rebalance, verify the current node before labeling the pool.
important

Apply the appropriate pool-type label whenever you create a new storage pool. Pools without the required label do not match the VPS rules.

Create the VolumePlacementStrategy objects​

Create two VolumePlacementStrategy objects to control volume placement based on the pool-type label:

  • dynamic-pools: Restricts volume placement to pools labeled pool-type=dynamic.
  • static-pools: Restricts volume placement to pools labeled pool-type=static.

Both VPS objects use replicaAffinity with enforcement: required to ensure that Portworx places volume replicas only on pools that match the specified label.

  1. Save the following configuration to a file named vps.yaml:

    apiVersion: portworx.io/v1beta2
    kind: VolumePlacementStrategy
    metadata:
    name: dynamic-pools
    spec:
    replicaAffinity:
    - enforcement: required
    matchExpressions:
    - key: pool-type
    operator: In
    values:
    - dynamic
    ---
    apiVersion: portworx.io/v1beta2
    kind: VolumePlacementStrategy
    metadata:
    name: static-pools
    spec:
    replicaAffinity:
    - enforcement: required
    matchExpressions:
    - key: pool-type
    operator: In
    values:
    - static
  2. Apply the configuration:

    kubectl apply -f vps.yaml

If your cluster uses multiple FlashArrays and you want to restrict volume placement to specific FlashArrays, add a kube_datastore expression with the FlashArray names to each VPS rule. Use kube_datastore instead of kube_datastore_id.

important

Portworx Enterprise stores the VolumePlacementStrategy rule with each volume when it creates the volume. Changes to the VolumePlacementStrategy do not affect existing volumes. Therefore, you cannot move a dynamic pool to a static pool or vice versa, by modifying the VolumePlacementStrategy.

Ensure that you select the appropriate VolumePlacementStrategy and StorageClass before provisioning a volume.

Create the StorageClasses​

Create separate StorageClass objects for volumes that you want to provision on static and dynamic pools. Use the placement_strategy parameter in each StorageClass to reference the corresponding VPS object.

The following example creates two StorageClasses:

  • px-dynamic: Provisions volumes with repl=1 on pools labeled dynamic. Use this StorageClass for volumes that meet dynamic pool requirements, such as KubeVirt VM disks.
  • px-static: Provisions volumes with repl=2 on pools labeled static. Use this StorageClass for workloads that require replicated volumes.
  1. Save the following configuration to a file named storageclasses.yaml:

    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
    name: px-dynamic
    provisioner: pxd.portworx.com
    parameters:
    repl: "1"
    placement_strategy: dynamic-pools
    volumeBindingMode: WaitForFirstConsumer
    allowVolumeExpansion: true
    ---
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
    name: px-static
    provisioner: pxd.portworx.com
    parameters:
    repl: "2"
    placement_strategy: static-pools
    volumeBindingMode: WaitForFirstConsumer
    allowVolumeExpansion: true
  2. Apply the configuration:

    kubectl apply -f storageclasses.yaml

For SharedV4 volumes or volumes with journal profiles, create separate StorageClasses with the corresponding volume parameters and set placement_strategy to static-pools.

important

Do not set kube_datastore_affinity in these StorageClasses. The VPS rules control volume placement.

Verify volume placement​

Verify that Portworx provisions volumes on the intended storage pools and that the pools designated as dynamic remain dynamic.

  1. Create a test PVC using each StorageClass.

    Because the example StorageClasses use WaitForFirstConsumer, ensure that a workload consumes each test PVC so that Portworx provisions the volume.

  2. Identify the storage pools that host the replicas of each volume:

    VOL=$(kubectl get pvc <pvc-name> -n <namespace> -o jsonpath='{.spec.volumeName}')
    pxctl volume inspect $VOL -j | jq -r '.[0].replica_sets[].pool_uuids[]'

    Replace:

    • <pvc-name> with the name of the test PVC.
    • <namespace> with the namespace of the PVC.

    The output lists the UUIDs of the storage pools that host the volume replicas. Compare these UUIDs with the pools that you labeled in Label the storage pools.

    Verify the following:

    • Volumes provisioned using px-dynamic reside on pools labeled pool-type=dynamic.
    • Volumes provisioned using px-static reside on pools labeled pool-type=static.
  3. Check the status of the storage pools:

    pxctl cluster provision-status

    Verify that all pools labeled pool-type=dynamic report yes in the DYNAMIC column.

    If a pool labeled dynamic reports no, check whether it contains a volume that prevents pool failover. For more information, see Maintain Dynamic Pool Failover Eligibility.

Maintain volume placement​

As you add storage pools and provision volumes, follow these recommendations to maintain dynamic pool failover eligibility:

  • Apply the appropriate pool-type label to newly created storage pools.
  • Use StorageClasses that reference the appropriate VPS object when provisioning volumes.
  • Regularly check the DYNAMIC column in the pxctl cluster provision-status output, especially after provisioning volumes or changing volume replication factors.

For information about conditions that can make a dynamic pool static and how to resolve them, see Maintain Dynamic Pool Failover Eligibility.

In this topic: