Notifications and Alerts
Table of Contentsβ
1 - Conceptβ
Notification Controllerβ
The Notification Controller manages:
- Alerts: Send notifications on events
- Receivers: Receive external webhooks
Available CRDsβ
| CRD | Description |
|---|---|
| Provider | Notification destination |
| Alert | Notification rules |
| Receiver | Endpoint for inbound webhooks |
π Back to table of contentsβ
2 - Providersβ
Slackβ
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: slack
namespace: flux-system
spec:
type: slack
channel: deployments
secretRef:
name: slack-webhook
---
apiVersion: v1
kind: Secret
metadata:
name: slack-webhook
namespace: flux-system
stringData:
address: https://hooks.slack.com/services/xxx/yyy/zzz
Microsoft Teamsβ
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: teams
namespace: flux-system
spec:
type: msteams
secretRef:
name: teams-webhook
---
apiVersion: v1
kind: Secret
metadata:
name: teams-webhook
namespace: flux-system
stringData:
address: https://outlook.office.com/webhook/xxx
Discordβ
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: discord
namespace: flux-system
spec:
type: discord
secretRef:
name: discord-webhook
GitHub (commit status)β
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: github-status
namespace: flux-system
spec:
type: github
address: https://github.com/my-org/my-repo
secretRef:
name: github-token
---
apiVersion: v1
kind: Secret
metadata:
name: github-token
namespace: flux-system
stringData:
token: ghp_xxxxxxxxxxxx
All supported providersβ
| Provider | Type | Description |
|---|---|---|
| Slack | slack | Slack messages |
| Teams | msteams | Teams messages |
| Discord | discord | Discord messages |
| GitHub | github | Commit status |
| GitLab | gitlab | Commit status |
| Bitbucket | bitbucket | Commit status |
| Generic | generic | HTTP webhook |
| PagerDuty | pagerduty | Incidents |
| Opsgenie | opsgenie | Alerts |
π Back to table of contentsβ
3 - Alertsβ
Basic Alertβ
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: on-call
namespace: flux-system
spec:
providerRef:
name: slack
eventSeverity: error
eventSources:
- kind: Kustomization
name: '*'
- kind: HelmRelease
name: '*'
Filter by namespaceβ
spec:
eventSources:
- kind: Kustomization
name: '*'
namespace: production
Filter by severityβ
spec:
eventSeverity: info # info, error
Alert with exclusionsβ
spec:
eventSources:
- kind: Kustomization
name: '*'
exclusionList:
- ".*test.*"
- ".*dev.*"
Complete exampleβ
# Slack pour les erreurs production
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: production-errors
namespace: flux-system
spec:
summary: "Production deployment alert"
providerRef:
name: slack-production
eventSeverity: error
eventSources:
- kind: Kustomization
name: '*'
namespace: production
- kind: HelmRelease
name: '*'
namespace: production
---
# Slack pour tous les dΓ©ploiements (info)
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: all-deployments
namespace: flux-system
spec:
summary: "Deployment notification"
providerRef:
name: slack-deployments
eventSeverity: info
eventSources:
- kind: Kustomization
name: '*'
- kind: HelmRelease
name: '*'
π Back to table of contentsβ
4 - Receivers (Webhooks)β
Conceptβ
Receivers make it possible to trigger a Flux reconciliation from the outside.
Create a Receiverβ
apiVersion: notification.toolkit.fluxcd.io/v1
kind: Receiver
metadata:
name: github-webhook
namespace: flux-system
spec:
type: github
events:
- ping
- push
secretRef:
name: webhook-token
resources:
- kind: GitRepository
name: my-repo
Secret for the tokenβ
apiVersion: v1
kind: Secret
metadata:
name: webhook-token
namespace: flux-system
stringData:
token: <random-token>
Retrieve the webhook URLβ
# L'URL est gΓ©nΓ©rΓ©e automatiquement
kubectl get receiver github-webhook -n flux-system
# Format: /hook/<sha256-hash>
Configure in GitHubβ
- Go to Settings > Webhooks
- URL:
https://flux.example.com/hook/<hash> - Content-type:
application/json - Secret: the same token as in the Secret
Receiver typesβ
| Type | Source |
|---|---|
github | GitHub webhooks |
gitlab | GitLab webhooks |
bitbucket | Bitbucket webhooks |
generic | Generic HTTP POST |
π Back to table of contentsβ
5 - Hands-on exercisesβ
Exercise 1: Slack alertsβ
# slack-notifications.yaml
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: slack
namespace: flux-system
spec:
type: slack
channel: flux-alerts
secretRef:
name: slack-webhook
---
apiVersion: v1
kind: Secret
metadata:
name: slack-webhook
namespace: flux-system
stringData:
address: "YOUR_SLACK_WEBHOOK_URL"
---
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: all-events
namespace: flux-system
spec:
providerRef:
name: slack
eventSeverity: info
eventSources:
- kind: GitRepository
name: '*'
- kind: Kustomization
name: '*'
Exercise 2: GitHub commit statusβ
# github-status.yaml
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
name: github
namespace: flux-system
spec:
type: github
address: https://github.com/MY-ORG/MY-REPO
secretRef:
name: github-token
---
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Alert
metadata:
name: github-status
namespace: flux-system
spec:
providerRef:
name: github
eventSeverity: info
eventSources:
- kind: Kustomization
name: my-app
Quizβ
Q1. What is the difference between Alert and Receiver?
Answer
- Alert: Sends outbound notifications (Flux β Slack/Teams)
- Receiver: Receives inbound webhooks (GitHub β Flux)
Alert = notify, Receiver = trigger.
Q2. How do you filter alerts to only get errors?
Answer
spec:
eventSeverity: error
The possible values are info (everything) and error (errors only).
π Back to table of contentsβ
Key takeawaysβ
- Provider: destination (Slack, Teams, GitHub...)
- Alert: outbound notification rules
- Receiver: inbound webhooks to trigger
- Filter by severity and namespace
- Webhooks for instant sync (no polling wait)