Expand every Portworx storage pool using Autopilot in Rancher
Summary and Key concepts
Summary:
This article provides guidance on using Portworx Autopilot to automatically expand storage pools in a Kubernetes cluster until they reach a specified capacity. The article outlines supported cloud providers for storage pool expansion (e.g., AWS, Azure, Google Cloud Platform, VMware vSphere, FlashArray) and provides an example of an Autopilot rule. The rule monitors the size of Portworx storage pools and triggers an action to expand them by adding new drives when their size is below 400GiB. The example Autopilot rule uses the add-drive
scaling method to double the pool's size while ensuring data remains in quorum during expansion.
Kubernetes Concepts:
- Custom Resource Definitions (CRD): The
AutopilotRule
CRD is used to define rules that automate actions like expanding storage pools. - PersistentVolumeClaim (PVC): Autopilot automates actions on storage pools to ensure PVCs remain properly sized as demand grows.
Portworx Concepts:
- Autopilot: Automates storage management tasks, such as expanding storage pools based on predefined conditions.
- Storage Pool Expansion: Automatically scales storage pools by adding drives when pool capacity is low, ensuring no volume goes out of quorum during the expansion process.
- Storage Pool: A Portworx construct representing a collection of storage resources, which Autopilot can scale or rebalance.
You can use Autopilot to expand Portworx every storage pool in your cluster until they reach a certain capacity.
Autopilot uses Portworx APIs to expand storage pools, and these APIs currently support the following cloud providers:
- Azure
- AWS
- Google Cloud Platform
Prerequisites
- Portworx cloud drives: Your Portworx installation must use one of the supported cloud drives where Portworx provisions the backing drives using the cloud provider
- Autopilot version: 1.3.13 or newer
Example
The following example Autopilot rules use the different scale types supported to resize all Portworx storage pools in the cluster until each pool exceeds 400 GiB. For more information about scale types, refer to openstorage.io.action.storagepool/expand
.
- Auto
- Add drive
- Resize drive
apiVersion: autopilot.libopenstorage.org/v1alpha1
kind: AutopilotRule
metadata:
name: pool-expand-till-400
spec:
enforcement: required
##### conditions are the symptoms to evaluate.
conditions:
expressions:
# pool size is less than 400 GiB
- key: "px_pool_stats_total_bytes/(1024*1024*1024)"
operator: Lt
values:
- "400"
##### action to perform when condition is true
actions:
- name: "openstorage.io.action.storagepool/expand"
params:
# resize pool by scalepercentage of current size. The 100% shown below will double the current pool size.
scalepercentage: "100"
# when scaling, add-drive/resize-drive to the pool based on available resources
scaletype: "auto"
Key Sections in the Spec
- The
conditions
section establishes threshold criteria dictating when the rule must perform its action. In this example, that criteria contains a single formula:- The key
px_pool_stats_total_bytes/(1024*1024*1024)
calculates the total pool capacity in GiB. - The
Lt
(less than) operator sets the threshold at 400GiB, meaning the action will trigger if a pool’s size is below this value.
- The key
- The
actions
section specifies what action Portworx performs when the conditions are met. Action parameters modify action behavior, and different actions contain different action parameters. In this example, the actions section directs Portworx to do the following:- The pool size is doubled by increasing it by 100% of its current size (
scalepercentage: "100"
). - The
auto
scale type is used, allowing Autopilot to either add new drives or resize existing ones automatically, based on available resources and configuration.
- The pool size is doubled by increasing it by 100% of its current size (
apiVersion: autopilot.libopenstorage.org/v1alpha1
kind: AutopilotRule
metadata:
name: pool-expand-till-400
spec:
enforcement: required
##### conditions are the symptoms to evaluate.
conditions:
expressions:
# pool size is less than 400 GiB
- key: "px_pool_stats_total_bytes/(1024*1024*1024)"
operator: Lt
values:
- "400"
##### action to perform when condition is true
actions:
- name: "openstorage.io.action.storagepool/expand"
params:
# resize pool by scalepercentage of current size. The 100% shown below will double the current pool size.
scalepercentage: "100"
# explicitly add new drives to the pool
scaletype: "add-drive"
Key Sections in the Spec
- The
conditions
section establishes threshold criteria dictating when the rule must perform its action. In this example, that criteria contains a single formula:- The key
px_pool_stats_total_bytes/(1024*1024*1024)
calculates the total pool capacity in GiB. - The
Lt
(less than) operator sets the threshold at 400GiB, meaning the action will trigger if a pool’s size is below this value.
- The key
- The
actions
section specifies what action Portworx performs when the conditions are met. Action parameters modify action behavior, and different actions contain different action parameters. In this example, the actions section directs Portworx to do the following:- The pool size is doubled by increasing it by 100% of its current size (
scalepercentage: "100"
). - The
add-drive
scale type is used, explicitly instructing Portworx to expand the pool by attaching new drives rather than resizing existing ones.
- The pool size is doubled by increasing it by 100% of its current size (
apiVersion: autopilot.libopenstorage.org/v1alpha1
kind: AutopilotRule
metadata:
name: pool-expand-till-400
spec:
enforcement: required
##### conditions are the symptoms to evaluate.
conditions:
expressions:
# pool size is less than 400 GiB
- key: "px_pool_stats_total_bytes/(1024*1024*1024)"
operator: Lt
values:
- "400"
##### action to perform when condition is true
actions:
- name: "openstorage.io.action.storagepool/expand"
params:
# resize pool by scalepercentage of current size. The 100% shown below will double the current pool size.
scalepercentage: "100"
# explicitly resize existing drives in the pool
scaletype: "resize-drive"
Key Sections in the Spec
- The
conditions
section establishes threshold criteria dictating when the rule must perform its action. In this example, that criteria contains a single formula:- The key
px_pool_stats_total_bytes/(1024*1024*1024)
calculates the total pool capacity in GiB. - The
Lt
(less than) operator sets the threshold at 400GiB, meaning the action will trigger if a pool’s size is below this value.
- The key
- The
actions
section specifies what action Portworx performs when the conditions are met. Action parameters modify action behavior, and different actions contain different action parameters. In this example, the actions section directs Portworx to do the following:- The pool size is doubled by increasing it by 100% of its current size (
scalepercentage: "100"
). - The
resize-drive
scale type is used, instructing Portworx to expand the pool by resizing the existing drives, ensuring no new drives are added.
- The pool size is doubled by increasing it by 100% of its current size (
Autopilot expands the pools such that no volume in the system will go out of quorum. For example, if volume1
has replicas on pool1
and pool2
, Autopilot first expands pool1
, waits for completion, and then expands pool2
.