Skip to main content

Notifications and Alerts


Table of Contents​

  1. Concept
  2. Providers
  3. Alerts
  4. Receivers (Webhooks)
  5. Hands-on exercises

1 - Concept​

Notification Controller​

The Notification Controller manages:

  • Alerts: Send notifications on events
  • Receivers: Receive external webhooks

Available CRDs​

CRDDescription
ProviderNotification destination
AlertNotification rules
ReceiverEndpoint 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​

ProviderTypeDescription
SlackslackSlack messages
TeamsmsteamsTeams messages
DiscorddiscordDiscord messages
GitHubgithubCommit status
GitLabgitlabCommit status
BitbucketbitbucketCommit status
GenericgenericHTTP webhook
PagerDutypagerdutyIncidents
OpsgenieopsgenieAlerts

πŸ” 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​

  1. Go to Settings > Webhooks
  2. URL: https://flux.example.com/hook/<hash>
  3. Content-type: application/json
  4. Secret: the same token as in the Secret

Receiver types​

TypeSource
githubGitHub webhooks
gitlabGitLab webhooks
bitbucketBitbucket webhooks
genericGeneric 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)

← Previous chapter | Next chapter: Multi-tenancy β†’