Skip to main content

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.

PlaybookSpec

FieldDescriptionSchemeRequired
descriptionA short descriptionstringtrue
onSpecify events to automatically trigger the Playbook. .[]PlaybookEventDetailfalse
checksSpecify selectors for checks that can be run on the Playbook.[]ResourceFilterfalse
configsSpecify selectors for config items that can be run on the Playbook.[]ResourceFilterfalse
componentsSpecify selectors for component items that can be run on the Playbook.[]ResourceFilterfalse
parametersDefine a set of labeled parameters for the Playbook.Propertiesfalse
actionsSpecify the set of actions to run.[]Actiontrue
approvalSpecify who can approve runs on this playbook.Approvalfalse

ResourceFilter

Filters can define what resources (config or a component) are permitted be run on the Playbook.

FieldDescriptionSchemeRequired
typeSpecify type of component.stringfalse
tagsSpecify tags of component.map[string]stringfalse

Parameter

Playbook parameter defines a parameter that a playbook needs to run.

FieldDescriptionSchemeRequired
nameSpecify name of parameter.stringtrue
labelSpecify label of parameter.stringtrue

Examples

Scaling EC2 instance

apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: scale-deployment
spec:
description: Scale deployment
configs:
- type: Kubernetes::Deployment
tags:
environment: staging
parameters:
- name: replicas
label: The new desired number of replicas.
approval:
type: any
approvers:
people:
- admin@local
teams:
- DevOps
actions:
- name: 'scale deployment'
exec:
script: kubectl scale --replicas={{.params.replicas}} --namespace={{.config.tags.namespace}} deployment {{.config.name}}

Restart unhealthy database

apiVersion: 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}}

Restart pod when check fails for more than 10 times in the last hour

apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: stop-pod-of-failing-check
spec:
description: stop pod for failing checks
on:
canary:
- event: failed
filter: check_summary.failed > 10
labels:
alertname: KubePodCrashLoopingcontainer
actions:
- name: 'Stop pod'
exec:
script: kubectl delete pod {{index .check.labels "pod"}}