The Notification Controller in Flux2 is a key component that enables outbound notifications to various platforms like Slack, Microsoft Teams, Discord, and others. It is used to create notifications from events and is driven by Alerts, another Custom Resource Definition (CRD) in the Flux Notification Controller’s API.
The Notification Controller manifests must contain an identifier to connect to the receiver platforms, usually in the form of spec.address
, and an authorization token which should be stored in a secret and referenced in the notification Provider as spec.secretRef.name
.
Flux supports various providers such as Discord, PagerDuty, Teams, Telegram, Sentry and many others. The notification controller is part of the default Flux installation. To define a provider, first create a secret with your platform token. For example, for Slack:
kubectl -n flagger-system create secret generic slack-bot-token --from-literal = token = xoxb-YOUR-TOKEN
Then, create a notification provider for Slack by referencing the above secret:
apiVersion : notification.toolkit.fluxcd.io/v1beta2
kind : Provider
metadata :
name : slack-bot
namespace : flagger-system
spec :
type : slack
channel : general
address : https://slack.com/api/chat.postMessage
secretRef :
name : slack-bot-token
To define an alert, create an alert definition for all repositories and kustomizations:
apiVersion : notification.toolkit.fluxcd.io/v1beta2
kind : Alert
metadata :
name : on-call-webapp
namespace : flux-system
spec :
summary : "cluster addons"
eventMetadata :
env : "production"
cluster : "my-cluster"
region : "us-east-2"
providerRef :
name : slack-bot
eventSeverity : info
eventSources :
- kind : GitRepository
name : '*'
- kind : Kustomization
name : '*'
You can find more information about the Notification Controller, its providers, alerts, and receivers in the following resources:
- Flux Notification Controller Image: https://edu.chainguard.dev/chainguard/chainguard-images/reference/flux-notification-controller/image_specs
- Flux Notification Controller Tags History: https://edu.chainguard.dev/chainguard/chainguard-images/reference/flux-notification-controller/tags_history
- Flux Components - Notification - Providers: https://fluxcd.io/flux/components/notification/providers
- Flux Components - Notification - Receivers: https://fluxcd.io/flux/components/notification/receivers
- Flux2 Notification Controller: https://fluxcd.io/flux/components/notification/alerting/
- Flux2 Alerts: https://fluxcd.io/flux/monitoring/alerts
- Flux2 Events: https://fluxcd.io/flux/monitoring/events
- Flux2 Monitoring: https://fluxcd.io/flux/monitoring
These resources cover the possible options and provide examples for each option. The Notification Controller is built using Go and Alpine Linux, and it depends on Kubernetes API Extension System, Git, Helm, Prometheus, GitOps, Kustomize, Docker, and YAML.