You have configured a Slack Webhook to receive notifications from your monitoring.
Create a secret containing the URL of your webhook:
---
apiVersion: v1
kind: Secret
metadata:
name: my-slack-webhook
namespace: default
stringData:
URL: "<your slack webhook URL>"
Then create the following Reactor resource:
---
apiVersion: kubirds.com/v1
kind: Reactor
metadata:
name: slack-notifier
namespace: default
spec:
unitSelector:
app: my-service
triggers:
successful: no
failed: no
fixed: yes
regression: yes
image:
name: curlimages/curl:latest
pullPolicy: Always
command: >
curl -X POST $HOST -H "Content-Type: application/json" \
-d "{ \"text\": \"state: $UNIT_STATE\" }"
env:
- name: HOST
valueFrom:
secretKeyRef:
name: my-slack-webhook
key: URL
The
unitSelectorproperty selects the units (by label) that need to trigger this reactor.The
triggersproperty controls when the reactor will be executed.The
imageandenvproperties serves the same purpose as for the Unit resource.The container environment is automatically populated with the variable
UNIT_STATE(the Unitโs last exit code).
For the complete Reactor schema, see this page.