Volume Placement Strategies


When creating PersistentVolumeClaims (PVCs) in the cluster, Portworx allows you to specify placement strategies for the volume. Below are some of the use cases that can be satisfied by placement strategies:

  • Distribute volumes across failure domains (This is the default Portworx behavior).
  • Specify failure domains to include (affinity) or exclude (anti-affinity) when placing volume replicas.
  • Specify storage pools to include (affinity) or exclude (anti-affinity) based on
    • Pool Cos (Class of Service): Select between high, medium or low pools
    • Pool media type: Use pools with SSD drives
    • Pool labels: Select pools based on custom user specified labels

The VolumePlacementStrategy CRD

Portworx provides a CustomResouceDefinition (CRD) called VolumePlacementStrategy. The specification for this CRD is composed of 4 main sections:

replicaAffinity

The replicaAffinity section allows you to specify a rule which creates an affinity for replicas within a volume. You should use this to place one or more replicas of a volume on the same failure domain, on multiple failure domains, nodes, or storage pools that match the given labels.

Schema
Field Description Optional? Default
enforcement Specifies if the given rule is required (hard) or preferred (soft) Yes required
matchExpressions matchExpressions is a list of label selector requirements. The requirements are ANDed.

The labels provided here are matched against the following:
  • Kubernetes node labels
  • PVC labels
  • Portworx storage pool labels
Yes empty
Example uses cases

By default, Portworx automatically adds the following labels to each of its storage pools. These can be used for replica affinity anti-affinity rules to target replicas on a specific storage pool type:

  • iopriority
  • medium

replicaAntiAffinity

The replicaAntiAffinity section allows you to specify a rule that creates an anti-affinity for replicas within a volume. You should use this to exclude failure domains, nodes or storage pools that match the given labels for one or more replicas of a volume.

Schema
Field Description Optional? Default
enforcement Specifies if the given rule is required (hard) or preferred (soft) Yes required
matchExpressions matchExpressions is a list of label selector requirements. The requirements are ANDed.

The labels provided here are matched against the following:
  • Kubernetes node labels
  • PVC labels
  • Portworx storage pool labels
Yes empty
Example uses cases

Anti-affinity to not use SATA pools

How to use

Pre-requisities

  1. Portworx version: 2.1.2 and above
  2. CRD version: Make sure the VolumePlacementStrategy CRD (CustomResourceDefinition) is at the right version:

    • Unregister existing CustomResourceDefinition
    kubectl delete crd volumeplacementstrategies.portworx.io
    • Register the following CustomResourceDefinition
    apiVersion: apiextensions.k8s.io/v1beta1
    kind: CustomResourceDefinition
    metadata:
      name: volumeplacementstrategies.portworx.io
    spec:
      group: portworx.io
      version: v1beta2
      scope: Cluster
      names:
        plural: volumeplacementstrategies
        singular: volumeplacementstrategy
        kind: VolumePlacementStrategy
        shortNames:
        - vps
        - vp

End user workflow

  1. User applies one or more VolumePlacementStrategy specs as per their requirements
  2. User creates a StorageClass that references the VolumePlacementStrategy. (Example)
  3. Users creates a PVC from the StorageClass (Example)


Last edited: Wednesday, Oct 9, 2019