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:
- Selector Matches labels on the objects that the rule should monitor.
- Namespace Selector Matches labels on the Kubernetes namespaces the rule should monitor. This is optional, and the default is all namespaces.
- Conditions The metrics for the objects to monitor.
- Actions to perform once the metric conditions are met.
The subsequent sections describe common operations for managing these rules.
Creating an AutopilotRule
Create an
AutopilotRule
spec file.- The Use cases page provides end-to-end examples on specific Autopilot use cases. Refer to these to help you create your spec.
- The AutopilotRule Reference page page defines the specification of the rule spec.
Apply the spec in your cluster.
kubectl apply -f volume-resize-autopilotrule.yaml
autopilotrule.autopilot.libopenstorage.org/volume-resize created
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 addinvolvedObject.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