> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Alerts Providers

> Guide to configuring Flux Notification controller to send Flux alerts to a Slack channel, including Slack app setup, Kubernetes secret, Provider and Alert creation, and testing.

In this lesson you'll configure the Flux Notification controller to send alerts to a Slack channel. This guide walks through creating the Slack app, granting permissions, storing the bot token in Kubernetes, creating a Flux Provider and Alert, and triggering notifications by making a change Flux reconciles.

High-level steps

* Create a Slack workspace and channel (or pick an existing one).
* Create a Slack App and add the correct OAuth bot scopes.
* If the channel is private, invite the bot to the channel.
* Store the Slack bot token as a Kubernetes Secret in the `flux-system` namespace.
* Create a Flux Provider and an Alert to route Flux events to Slack.
* Trigger a change and observe notifications in Slack.

Prerequisites

* Administrative access to a Slack workspace (to create apps & install them).
* kubectl configured against the cluster where Flux is installed.
* Flux Notification controller installed (part of Flux toolkit).

Create the Slack channel
Create a public or private channel for Flux alerts. In this demo the channel is named FluxAlertsChannel (`flux-alerts-channel`).

![A dark-themed Slack workspace screenshot with the "Create a channel" dialog open in the center, showing fields for channel name, description, a private toggle, and a Create button while the "flux-alerts-channel" is selected in the sidebar.](https://mintcdn.com/kodekloud-c4ac6d9a/AyhVWHpoMIYCWiei/images/GitOps-with-FluxCD/Notification-Controller/Demo-Alerts-Providers/slack-dark-create-channel-flux-alerts.jpg?fit=max\&auto=format\&n=AyhVWHpoMIYCWiei\&q=85\&s=7af7bacad99a5c03e07380df685d8f42)

Create a Slack App
Create a Slack application for the workspace using the Slack API dashboard. Slack Apps with bot tokens are the recommended approach for posting messages from external systems (instead of legacy incoming webhooks).

![A screenshot of the Slack API "Your Apps" dashboard showing a list of Slack apps and a prominent "Create New App" button. The app list includes entries like "ArgoCD Notification App," "argo-test1," "ArgoCD-KK," and "Slack-Argo-V2" for the mcd-level2 workspace.](https://mintcdn.com/kodekloud-c4ac6d9a/AyhVWHpoMIYCWiei/images/GitOps-with-FluxCD/Notification-Controller/Demo-Alerts-Providers/slack-your-apps-list-create-app.jpg?fit=max\&auto=format\&n=AyhVWHpoMIYCWiei\&q=85\&s=1d0b3a8a491b2b89c00244a1fe09a66b)

OAuth scopes to add
Under Features → OAuth & Permissions add the bot scopes you need. At minimum:

| Bot scope | Purpose |
| - | - |
| `chat:write` | Allows the app to post messages as the bot. |
| `channels:read` | Lets the app read public channel information (needed for resolving channel names). |
| `chat:write.customize` | (Optional) Post messages with a custom username and avatar. |

After adding scopes, click Install to Workspace (or Reinstall) to obtain the Bot User OAuth Token (`xoxb-...`). Flux uses this bot token to authenticate to Slack.

![A Slack authorization screen showing the "Flux Alerts Application" requesting permission to access the mcd-level2 workspace. It lists what the app can view and do and shows "Cancel" and "Allow" buttons.](https://mintcdn.com/kodekloud-c4ac6d9a/AyhVWHpoMIYCWiei/images/GitOps-with-FluxCD/Notification-Controller/Demo-Alerts-Providers/slack-authorization-flux-alerts-app.jpg?fit=max\&auto=format\&n=AyhVWHpoMIYCWiei\&q=85\&s=7f20e7e060a31504a4054a84fcaef3f7)

Invite the bot to private channels
If your target channel is private, invite the bot user into that channel so it has permission to post messages.

![A screenshot of a Slack workspace in dark mode open to a private channel named "flux-alerts-channel," showing the left channel list and recent message activity in the main pane. The message composer is visible at the bottom.](https://mintcdn.com/kodekloud-c4ac6d9a/AyhVWHpoMIYCWiei/images/GitOps-with-FluxCD/Notification-Controller/Demo-Alerts-Providers/slack-dark-flux-alerts-channel-screenshot.jpg?fit=max\&auto=format\&n=AyhVWHpoMIYCWiei\&q=85\&s=6e86e1350149c7a4a7e23636e261545c)

Store the bot token in Kubernetes
Switch to your cluster and store the Slack bot token as a Kubernetes Secret in the `flux-system` namespace. Replace the token value with your Bot User OAuth Token:

```bash theme={null}
kubectl -n flux-system create secret generic slack-bot-token \
  --from-literal=token=xoxb-3323832857318-5077094974995-nOCxY5tZjnXAQgMGJ1sOfdC8
```

Expected output:

```text theme={null}
secret/slack-bot-token created
```

Keep bot tokens secret. Consider storing them in a sealed secret or using the cluster's secret-store integration where appropriate. Never commit tokens to Git.

Create a Flux Provider for Slack
Define a Provider that instructs the Flux Notification controller how to send messages to Slack. You can use the Flux CLI to create and export a Provider manifest:

```bash theme={null}
flux create alert-provider notification-provider-slack \
  --type slack \
  --channel flux-alerts-channel \
  --username flux-bot \
  --secret-ref slack-bot-token \
  --address https://slack.com/api/chat.postMessage \
  --export > notification-provider-slack.yml
```

Example generated Provider manifest (`notification-provider-slack.yml`):

```yaml theme={null}
apiVersion: notification.toolkit.fluxcd.io/v1beta2
kind: Provider
metadata:
  name: notification-provider-slack
  namespace: flux-system
spec:
  type: slack
  channel: flux-alerts-channel
  username: flux-bot
  address: https://slack.com/api/chat.postMessage
  secretRef:
    name: slack-bot-token
```

Apply the Provider to the cluster (or commit it to the Git repo Flux reconciles):

```bash theme={null}
kubectl apply -f notification-provider-slack.yml
```

Create an Alert to route events
Create an Alert resource that filters Flux events by severity and source kinds, and forwards matching events to the Slack Provider. The following example creates an alert that captures common Flux sources at `info` severity:

```bash theme={null}
flux create alert notification-alert-slack \
  --event-severity info \
  --provider-ref notification-provider-slack \
  --event-source Kustomization/* \
  --event-source GitRepository/* \
  --event-source Bucket/* \
  --event-source OCIRepository/* \
  --event-source HelmChart/* \
  --event-source HelmRepository/* \
  --event-source HelmRelease/* \
  --event-source ImageRepository/* \
  --event-source ImagePolicy/* \
  --event-source ImageUpdateAutomation/* \
  --export > notification-alert-slack.yml
```

Example Alert manifest (`notification-alert-slack.yml`):

```yaml theme={null}
apiVersion: notification.toolkit.fluxcd.io/v1beta2
kind: Alert
metadata:
  name: notification-alert-slack
  namespace: flux-system
spec:
  eventSeverity: info
  eventSources:
    - kind: Kustomization
      name: '*'
    - kind: GitRepository
      name: '*'
    - kind: Bucket
      name: '*'
    - kind: OCIRepository
      name: '*'
    - kind: HelmChart
      name: '*'
    - kind: HelmRepository
      name: '*'
    - kind: HelmRelease
      name: '*'
    - kind: ImageRepository
      name: '*'
    - kind: ImagePolicy
      name: '*'
    - kind: ImageUpdateAutomation
      name: '*'
  providerRef:
    name: notification-provider-slack
```

Apply the Alert resource:

```bash theme={null}
kubectl apply -f notification-alert-slack.yml
```

Verify Provider and Alert readiness
After applying the Provider and Alert, make Flux reconcile your Git source and verify the resources are initialized.

```bash theme={null}
flux reconcile source git flux-system
```

Example expected output:

```text theme={null}
✔ fetched revision main@sha1:508619e763c8d8221b95b092cf933b60d90ac67a
```

Check the Alert and Provider status:

```bash theme={null}
flux get alert
```

```text theme={null}
NAME                       SUSPENDED  READY  MESSAGE
notification-alert-slack   False      True   Initialized
```

```bash theme={null}
flux get alert-providers
```

```text theme={null}
NAME                         READY  MESSAGE
notification-provider-slack  True   Initialized
```

Once the Provider and Alert are Ready and Flux has reconciled the Git source, the Notification controller will start sending matching events to Slack.

![A screenshot of the Flux documentation page showing a list of notification providers (e.g., Azure Event Hub, Discord, GitHub dispatch, Google Chat, Grafana, Microsoft Teams, Slack, Telegram) with a left-hand navigation menu. The top black header shows the Flux logo and site navigation.](https://mintcdn.com/kodekloud-c4ac6d9a/AyhVWHpoMIYCWiei/images/GitOps-with-FluxCD/Notification-Controller/Demo-Alerts-Providers/flux-notification-providers-list.jpg?fit=max\&auto=format\&n=AyhVWHpoMIYCWiei\&q=85\&s=d77db947d0c27e70b1a893b9cf3ff39a)

Triggering and observing alerts

* Commit a change to a repository Flux reconciles (for example, update a Kustomization or change a Deployment replica count).
* Flux will fetch the commit, reconcile the resources, and the Notification controller will emit events.
* The Alert you configured will match those events and the Provider will dispatch messages to your Slack channel.

Example workflow

1. Update a kustomized application (for example, `bb-app-source`) to change replicas from 4 → 1.
2. Commit and push the change to the Git repository that Flux monitors.
3. Flux detects the commit, applies the Kustomization, and you will receive Slack notifications for the GitRepository artifact and the Kustomization/Deployment reconciliation.

Example Slack notifications (summarized)

* GitRepository event:
  * `gitrepository/2-demo-source-git-bb-app.flux-system`
  * stored artifact for commit 'changed replica'
  * revision `2-demo@sha1:310e0beacc0dea3b67239f3f92989717cdb6c635`

* Kustomization event:
  * `kustomization/2-demo-kustomize-git-bb-app.flux-system`
  * `Deployment/2-demo/block-buster configured`
  * revision `2-demo@sha1:310e0beacc0dea3b67239f3f92989717cdb6c635`

Validate cluster state
After reconciliation completes, verify resources were updated in the target namespace:

```bash theme={null}
kubectl -n 2-demo get pods
```

You should see the pod count reflect the changed replica value.

If notifications do not appear in Slack:

* Confirm the bot token is correct and stored in `flux-system`.
* Ensure the bot is a member of the target channel (for private channels).
* Check Flux Notification controller logs for errors: `kubectl -n flux-system logs deploy/notification-controller`.

Closing
You now have Flux alerts wired to Slack. Customize Providers (channels, username, address) and Alerts (event sources and severities) to fine-tune notifications for your environment.

Links and references

* Flux Notification Controller: [https://fluxcd.io/docs/components/notification/](https://fluxcd.io/docs/components/notification/)
* Slack Apps & OAuth: [https://api.slack.com/apps](https://api.slack.com/apps)
* Slack Bot Token scopes: [https://api.slack.com/authentication/scopes](https://api.slack.com/authentication/scopes)

> **[Watch Video](https://learn.kodekloud.com/user/courses/gitops-with-fluxcd/module/6f4f2854-e5a5-4f3e-8910-85c47c018029/lesson/dced4ec0-5ccc-4a5b-8603-b9cf5d737de4)**


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.