Playbook
Playbooks are configurable automated processes that can be used to perform a variety of actions for a component or a config item. They are defined using a YAML configuration.
restart-unhealthy-database.yamlapiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: restart-unhealthy-database
spec:
description: Restart when a database becomes unhealthy
on:
component:
- event: unhealthy
filter: component.type == 'database'
labels:
industry: e-commerce
actions:
- name: 'Restart kubernetes deployment'
exec:
script: kubectl rollout restart deployment {{.component.name}}
Spec
Field | Description | Scheme | Required |
---|---|---|---|
description | A short description | string | true |
icon | Icon for the playbook | string | |
on | Specify events to automatically trigger the Playbook. . | []Trigger | |
checks | Specify selectors for checks that can be run on the Playbook. | []ResourceFilter | |
configs | Specify selectors for config items that can be run on the Playbook. | []ResourceFilter | |
components | Specify selectors for component items that can be run on the Playbook. | []ResourceFilter | |
parameters | Define a set of labeled parameters for the Playbook. | []Parameter | |
actions | Specify the set of actions to run. | []Action | true |
approval | Specify who can approve runs on this playbook. | Approval |
Trigger
Field | Description | Scheme | Required |
---|---|---|---|
canary | Setup trigger on canary events | EventTrigger | |
component | Setup trigger on health check events. | EventTrigger | |
webhook | Setup a webhook endpoint that triggers the playbook. | WebhookTrigger |
ResourceFilter
Filters can define what resources (checks, configs or components) are permitted be run on the Playbook.
Field | Description | Scheme | Required |
---|---|---|---|
type | Specify type of component. | string | |
tags | Specify tags of component. | map[string]string |
Parameter
Playbook parameter defines a parameter that a playbook needs to run.
Field | Description | Scheme | Required |
---|---|---|---|
name | Specify name of parameter. | string | true |
label | Specify label of parameter. | string | true |
Run
A run is the execution of a Playbook consisting of a sequence of actions. A run can be trigger either
- manually
- on events
- on schedule (upcoming)
For example, a playbook can be executed when a health check passes or fails.
Start Time
Every run must have a start time which is the time the run is scheduled to start. By default, the it is set to the current time.
Start time can be in future or even in the past.
Action
Actions are the fundamental tasks executed by a playbook. A playbook can comprise multiple actions, which are executed sequentially. If any action encounters an error and fails, the execution of the playbook is halted.
Field | Description | Scheme | Required |
---|---|---|---|
name | Name of action. | string | true |
delay | Delay the execution of the action. (Sensitive to the minute.) | DurationString | |
timeout | Timeout on this action. | DurationString | |
exec | Specify exec of action. | ExecAction | |
gitops | Specify gitops of action. | GitopsAction | |
http | Specify http of action. | HttpAction | |
sql | Specify sql of action. | SqlAction | |
pod | Specify pod of action. | PodAction | |
notification | Specify notification of action. | NotificationAction |
Specify one or more actions; but at least one.
Duration String
Duration strings specify duration in a human readable format.
Examples:
1m15s
1h5m
23h
1d8h
1w6d8h
19w0d8h