Skip to main content

Self Service

Playbooks can be manually triggered on a component, config item or check.

restart-deployment.yaml
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: restart-deployment
spec:
description: Restart deployment
# only allow the playbook to run on Kubernetes::Deployment config items
configs:
- types:
- Kubernetes::Deployment
actions:
- name: kubectl rollout restart deployment
exec:
script: kubectl rollout restart deployment {{.config.name}} -n {{.config.tags.namespace}}

To run the playbook:

a. Navigate to a Deployment in the Catalog
b. Select Restart Deployment from the Playbooks menu
c. Click Run

Resource Filters

Playbooks can be restricted to run on specific config, check and components using resource selectors

restart-deployment.yaml
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
spec:
configs: # Only applicable to config items
- types:
- Kubernetes::Deployment # of this type

Parameters

scale-deployment.yaml
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: scale-deployment
spec:
description: Scale Deployment
configs:
- types:
- Kubernetes::Deployment
parameters:
- name: replicas
label: The new desired number of replicas.
actions:
- name: kubectl scale
exec:
script: |
kubectl scale --replicas={{.params.replicas}} \
--namespace={{.config.tags.namespace}} \
deployment {{.config.name}}

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

FieldDescriptionSchemeRequiredTemplatable
nameName of parameter.stringtrue
defaultDefault value of the parameter.stringtrue
labelLabel of the parameter.stringtrue
requiredSpecify if the parameter is requiredbool
iconIcon
descriptionDescription of the parameter.string
typeType of parameter. (Defaults to "text")string
propertiesProperties of parameter. Varies based on the typemap[string]string

Defaulting

Parameter values can be defaulted from the selected resource

default parameters.yaml
#...
kind: Playbook
spec:
parameters:
// Use the config items type and name in the parameter
- default: 'chore: update $(.config.type)/$(.config.name)'

When running the playbook on a Deployment named mysql the following will be prepopulated:

Types

nameDescriptionUI ComponentSchemaProperties
checkLimits the value to a check.DropdownstringCheck
checkboxBoolean value toggleCheckboxboolean-
codeText areaCode EditorstringCode
componentLimits the value to a component.DropdownstringComponent
configLimits the value to a config item.DropdownstringConfig
listSpecify a custom list of valuesDropdownstringList
peopleLimits the value to people.DropdownstringPeople
teamLimits the value to teams.Dropdownstring-
textText inputText InputstringText

component

FieldDescriptionSchema
filter.typeLimit the components to the given typestring

config

FieldDescriptionSchema
filter.typeLimit the components to the given typestring

checks

FieldDescriptionSchema
filter.typeLimit the components to the given typestring

code

FieldDescriptionSchema
languagee.g. yaml, json, toml, etc.string

people

FieldDescriptionSchema
roleLimit the people to the given role`string

text

FieldDescriptionSchema
multilineRender a multiline textareaboolean

list

FieldDescriptionSchema
options[].labelSpecify label of the list optionstring
options[].valueSpecify value of the list optionstring

Playbook parameters Fig: Playbook parameters