Skip to main content
Version: 3.2

Working with Autopilot Rules

Summary and Key concepts

Summary:

This article explains how to create, update, monitor, and delete AutopilotRule objects, which are used to define automation rules for Portworx's Autopilot feature in Kubernetes and OpenShift. The AutopilotRule CRD allows users to specify objects to monitor, conditions to track, and actions to execute when conditions are met (e.g., resizing PVCs). The article provides step-by-step instructions on creating AutopilotRule specs, applying them in the cluster, and viewing the associated events to monitor their status. It also covers how to modify or delete existing rules.

Kubernetes Concepts:

  • Custom Resource Definition (CRD): Allows users to create custom resources, such as AutopilotRule, to extend Kubernetes functionality.
  • Labels and Selectors: Labels are key-value pairs attached to objects, and selectors are used to match labels in the AutopilotRule to choose which objects to monitor.

Portworx Concepts:

  • Autopilot: A feature in Portworx that automates storage management tasks based on defined rules.

Understanding an AutopilotRule

Users use an AutopilotRule CRD to tell Autopilot which objects to monitor, the conditions to monitor, and the corresponding actions to perform when conditions occur.

An AutopilotRule has 4 main parts:

  1. Selector Matches labels on the objects that the rule should monitor.
  2. Namespace Selector Matches labels on the Kubernetes namespaces the rule should monitor. This is optional, and the default is all namespaces.
  3. Conditions The metrics for the objects to monitor.
  4. Actions to perform once the metric conditions are met.

The subsequent sections describe common operations for managing these rules.

Creating an AutopilotRule

  1. Create an AutopilotRule spec file.

  2. Apply the spec in your cluster.

    kubectl apply -f volume-resize-autopilotrule.yaml
    autopilotrule.autopilot.libopenstorage.org/volume-resize created

Creating an AutopilotRule

Updating an AutopilotRule

You can update an autopilot rule in-place with the kubectl edit command:

kubectl edit autopilotrule volume-resize

Deleting an AutopilotRule

Delete an Autopilot rule by using kubectl delete autpilotrule and specifying the rule you want to delete. When you do this, Autopilot stops monitoring all objects that match this rule.

kubectl delete autopilotrule volume-resize
autopilotrule.autopilot.libopenstorage.org "volume-resize" deleted

Monitoring AutopilotRules

Autopilot generates events, which you can monitor with the kubectl get events command:

  • To see events for all AutopilotRule objects:

    kubectl get events --field-selector involvedObject.kind=AutopilotRule --all-namespaces
  • To see events for a specific AutopilotRule object, you must add involvedObject.name and the name of your Autopilot rule.

    In below example, we are listing all events for the volume-resize rule.

    kubectl get events --field-selector involvedObject.kind=AutopilotRule,involvedObject.name=volume-resize --all-namespaces
     NAMESPACE   LAST SEEN   TYPE     REASON       KIND            MESSAGE
    default 21m Normal Transition AutopilotRule rule: pvc-xxxxxxxx-xxxx-xxxx-xxxx-aa931955114b transition from Initializing => Normal
    default 21m Normal Transition AutopilotRule rule: pvc-xxxxxxxx-xxxx-xxxx-xxxx-aa931955114b transition from Initializing => Normal
    default 9m52s Normal Transition AutopilotRule rule: pvc-xxxxxxxx-xxxx-xxxx-xxxx-aa931955114b transition from Initializing => Normal
    default 9m48s Normal Transition AutopilotRule rule: pvc-xxxxxxxx-xxxx-xxxx-xxxx-aa931955114b transition from Initializing => Normal

Was this page helpful?