I have a cronjob which creates postgres backup job.. I would like to send notification to slack channels via webhook with cronjob status fail or success. How can I add a condition or specify the status of Job and sending to slack? I suppose that also below curl request will work but please warn if you see any fault.
kind: CronJob
metadata:
name: standup
spec:
schedule: "* 17 * * 1-5"
jobTemplate:
spec:
template:
spec:
containers:
- name: standup
image: busybox
resources:
requests:
cpu: 1m
memory: 100Mi
env:
- args: /bin/sh
- -c
- curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' https://hooks.slack.com/services/TQPCENFHP/
restartPolicy: OnFailure
~ semural$ kubectl logs $pods -n database
The following backups are available in specified backup path:
Added `s3` successfully.
[2020-04-13 14:24:46 UTC] 0B postgresql-cluster/
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
postgresql-postgresql-helm-backup 0 0 * * * False 0 8h 18h
NAME COMPLETIONS DURATION AGE
postgresql-postgresql-helm-backup-1586822400 1/1 37s 8h
postgresql-postgresql-helm-backup-list 1/1 2s 18h
postgresql-postgresql-helm-pgmon 1/1 49s 18h