-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from flanksource/playbooks-new-features
Playbooks new features
- Loading branch information
Showing
5 changed files
with
145 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Playbook Action Filter | ||
|
||
```yaml title="delete-kubernetes-pod.yaml" | ||
--- | ||
apiVersion: mission-control.flanksource.com/v1 | ||
kind: Playbook | ||
metadata: | ||
name: delete kubernetes pod | ||
spec: | ||
configs: | ||
- type: Kubernetes::Pod | ||
actions: | ||
- name: Delete the pod | ||
exec: | ||
script: kubectl delete pod {{.config.name}} | ||
- name: Log Maintenance Success | ||
delay: 2m | ||
if: failure() | ||
notification: | ||
connection: connection://telegram/aditya | ||
title: 'Failed to delete kubernetes pod {{.config.name}}' | ||
message: 'Something went wrong with deleting kubernetes pod {{.config.name}}' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Delay Actions | ||
|
||
```yaml title="delay-deletion.yaml" | ||
apiVersion: mission-control.flanksource.com/v1 | ||
kind: Playbook | ||
metadata: | ||
name: write-config-to-file | ||
spec: | ||
description: Creates a file with the content of the config | ||
configs: | ||
- type: Kubernetes::Pod | ||
actions: | ||
- name: Create the config file | ||
exec: | ||
script: echo -n '{{.config.config}}' > /tmp/{{.config.id}} | ||
- name: Delete the file | ||
delay: 'config.name.startsWith("actual") ? "1m" : "0s"' | ||
exec: | ||
script: rm /tmp/{{.config.id}} | ||
``` | ||
This playbook saves the config of a `Kubernetes::Pod` to a temporary file. A delay is introduced before deleting that file. If the name of the pod beings with | ||
`actual` then the deletion is delayed by a minute, else it is deleted immediately. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters