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=2or higher, SharedV4 volumes, or volumes with journal profiles as static pools. -
No Kubernetes node has the
pool-typelabel. A node label overrides the corresponding label on the storage pools of that node.To verify this requirement, run:
kubectl get nodes -L pool-typeVerify that the
POOL-TYPEcolumn 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 withrepl=2or 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.
-
List the storage pools:
pxctl service pool showNote the UUID of each pool and the node that currently hosts the pool.
-
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>withdynamicorstatic, depending on the intended use of the pool.
-
Repeat the previous step for each storage pool that you want to label.
note- Use the
--uidoption to specify the pool UUID. Otherwise, the command fails withinvalid 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.
- Use the
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 labeledpool-type=dynamic.static-pools: Restricts volume placement to pools labeledpool-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.
-
Save the following configuration to a file named
vps.yaml:apiVersion: portworx.io/v1beta2kind: VolumePlacementStrategymetadata:name: dynamic-poolsspec:replicaAffinity:- enforcement: requiredmatchExpressions:- key: pool-typeoperator: Invalues:- dynamic---apiVersion: portworx.io/v1beta2kind: VolumePlacementStrategymetadata:name: static-poolsspec:replicaAffinity:- enforcement: requiredmatchExpressions:- key: pool-typeoperator: Invalues:- static -
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.
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 withrepl=1on pools labeleddynamic. Use this StorageClass for volumes that meet dynamic pool requirements, such as KubeVirt VM disks.px-static: Provisions volumes withrepl=2on pools labeledstatic. Use this StorageClass for workloads that require replicated volumes.
-
Save the following configuration to a file named
storageclasses.yaml:apiVersion: storage.k8s.io/v1kind: StorageClassmetadata:name: px-dynamicprovisioner: pxd.portworx.comparameters:repl: "1"placement_strategy: dynamic-poolsvolumeBindingMode: WaitForFirstConsumerallowVolumeExpansion: true---apiVersion: storage.k8s.io/v1kind: StorageClassmetadata:name: px-staticprovisioner: pxd.portworx.comparameters:repl: "2"placement_strategy: static-poolsvolumeBindingMode: WaitForFirstConsumerallowVolumeExpansion: true -
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.
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.
-
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. -
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-dynamicreside on pools labeledpool-type=dynamic. - Volumes provisioned using
px-staticreside on pools labeledpool-type=static.
-
Check the status of the storage pools:
pxctl cluster provision-statusVerify that all pools labeled
pool-type=dynamicreportyesin theDYNAMICcolumn.If a pool labeled
dynamicreportsno, 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-typelabel to newly created storage pools. - Use StorageClasses that reference the appropriate VPS object when provisioning volumes.
- Regularly check the
DYNAMICcolumn in thepxctl cluster provision-statusoutput, 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.