Notifications
Introduction to Notifications
Notifications is an easy way of k8s-cleaner to keep users in the loop about relevant updates. Each notification contains a list of successfully deleted or modified resources by the k8s-cleaner.
The below notifications are available. - Slack - Webex - Discord - Telegram - Teams - SMTP
Slack Notifications Example
Kubernetes Secret
To allow the k8s-cleaner to write messages or upload files to a channel, we need to create a Kubernetes secret
$ kubectl create secret generic slack --from-literal=SLACK_TOKEN=<YOUR TOKEN> --from-literal=SLACK_CHANNEL_ID=<YOUR CHANNEL ID>
Slack Notifications Defintion
---
apiVersion: apps.projectsveltos.io/v1alpha1
kind: Cleaner
metadata:
name: cleaner-with-slack-notifications
spec:
schedule: "0 * * * *"
action: Delete # Delete matching resources
resourcePolicySet:
resourceSelectors:
- namespace: test
kind: Deployment
group: "apps"
version: v1
notifications:
- name: slack
type: Slack
notificationRef:
apiVersion: v1
kind: Secret
name: slack
namespace: default
Anytime this Cleaner instance is processed, a Slack message is sent containing all the resources that were deleted by k8s-cleaner.
Webex Notifications Example
Kubernetes Secret
To allow the k8s-cleaner to write messages or upload files to a channel, we need to create a Kubernetes secret
$ kubectl create secret generic webex --from-literal=WEBEX_TOKEN=<YOUR TOKEN> --from-literal=WEBEX_ROOM_ID=<YOUR WEBEX CHANNEL ID>
Webex Notifications Defintion
---
apiVersion: apps.projectsveltos.io/v1alpha1
kind: Cleaner
metadata:
name: cleaner-with-webex-notifications
spec:
schedule: "0 * * * *"
action: Delete # Delete matching resources
resourcePolicySet:
resourceSelectors:
- namespace: test
kind: Deployment
group: "apps"
version: v1
notifications:
- name: webex
type: Webex
notificationRef:
apiVersion: v1
kind: Secret
name: webex
namespace: default
Discord Notifications Example
Kubernetes Secret
To allow the k8s-cleaner to write messages or upload files to a channel, we need to create a Kubernetes secret
$ kubectl create secret generic discord --from-literal=DISCORD_TOKEN=<YOUR TOKEN> --from-literal=DISCORD_CHANNEL_ID=<YOUR DISCORD CHANNEL ID>
Discord Notifications Defintion
---
apiVersion: apps.projectsveltos.io/v1alpha1
kind: Cleaner
metadata:
name: cleaner-with-discord-notifications
spec:
schedule: "0 * * * *"
action: Delete # Delete matching resources
resourcePolicySet:
resourceSelectors:
- namespace: test
kind: Deployment
group: "apps"
version: v1
notifications:
- name: discord
type: Discord
notificationRef:
apiVersion: v1
kind: Secret
name: discord
namespace: default
Telegram Notifications Example
Kubernetes Secret
To allow the k8s-cleaner to write messages or upload files to a group, we need to create a Kubernetes secret
$ kubectl create secret generic telegram --from-literal=TELEGRAM_TOKEN=<YOUR TOKEN> --from-literal=TELEGRAM_CHAT_ID=<YOUR TELEGRAM CHAT ID>
Telegram Notifications Defintion
---
apiVersion: apps.projectsveltos.io/v1alpha1
kind: Cleaner
metadata:
name: cleaner-with-telegram-notifications
spec:
schedule: "0 * * * *"
action: Delete # Delete matching resources
resourcePolicySet:
resourceSelectors:
- namespace: test
kind: Deployment
group: "apps"
version: v1
notifications:
- name: telegram
type: Telegram
notificationRef:
apiVersion: v1
kind: Secret
name: telegram
namespace: default
Teams Notifications Example
Kubernetes Secret
To allow the k8s-cleaner to write messages or upload files to a channel, we need to create a Kubernetes secret
Teams Notifications Defintion
---
apiVersion: apps.projectsveltos.io/v1alpha1
kind: Cleaner
metadata:
name: cleaner-with-teams-notifications
spec:
schedule: "0 * * * *"
action: Delete # Delete matching resources
resourcePolicySet:
resourceSelectors:
- namespace: test
kind: Deployment
group: "apps"
version: v1
notifications:
- name: teams
type: Teams
notificationRef:
apiVersion: v1
kind: Secret
name: teams
namespace: default
SMTP Notifications Example
Kubernetes Secret
To allow the k8s-cleaner to send an SMTP email, we need to create a Kubernetes secret:
$ kubectl create secret generic smtp \
--from-literal=SMTP_RECIPIENTS=<COMMA-SEPARATED EMAIL ADDRESSES> \
--from-literal=SMTP_BCC=<OPTIONAL, COMMA-SEPARATED EMAIL ADDRESSES> \
--from-literal=SMTP_IDENTITY=<OPTIONAL, IDENTITY/USERNAME OF THE SENDER> \
--from-literal=SMTP_SENDER=<EMAIL ADDRESS> \
--from-literal=SMTP_PASSWORD=<OPTIONAL, SMTP PASSWORD FOR EMAIL ADDRESS IF APPLICABLE> \
--from-literal=SMTP_HOST=<SMTP SERVER HOSTNAME> \
--from-literal=SMTP_PORT=<OPTIONAL, SMTP SERVER PORT, DEFAULTS TO "587">
SMTP Notifications Definition
---
apiVersion: apps.projectsveltos.io/v1alpha1
kind: Cleaner
metadata:
name: cleaner-with-smtp-notifications
spec:
schedule: "0 * * * *"
action: Delete # Delete matching resources
resourcePolicySet:
resourceSelectors:
- namespace: test
kind: Deployment
group: "apps"
version: v1
notifications:
- name: smtp
type: SMTP
notificationRef:
apiVersion: v1
kind: Secret
name: smtp
namespace: default