Working with Autopilot 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

Updating an AutopilotRule

Autopilot currently does not support modifying an existing rule. Instead, delete the existing rule and create a new one with the modified spec.

  1. Delete the rule you intend to modify by entering the kubectl delete autpilotrule command, specifying the rule you want to delete:

    kubectl delete autopilotrule volume-resize
    autopilotrule.autopilot.libopenstorage.org "volume-resize" deleted
  2. Apply the modified spec in your cluster.

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

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-5bfcabfd-d017-11e9-bcdf-aa931955114b transition from Initializing => Normal
default     21m         Normal   Transition   AutopilotRule   rule: pvc-5c9a6451-d017-11e9-bcdf-aa931955114b transition from Initializing => Normal
default     9m52s       Normal   Transition   AutopilotRule   rule: pvc-5bfcabfd-d017-11e9-bcdf-aa931955114b transition from Initializing => Normal
default     9m48s       Normal   Transition   AutopilotRule   rule: pvc-5c9a6451-d017-11e9-bcdf-aa931955114b transition from Initializing => Normal


Last edited: Friday, Nov 1, 2019