All jobs

Add Slack Alerts to a Flux GitOps Repository

Yes. An agent adds a Flux notification Provider and Alert for Slack to your GitOps repository, validates the manifests the way your CI does, and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads the repository layout before it adds anything, because where a Flux manifest lives decides which controller applies it and when. In a repository like fluxcd/flux2-kustomize-helm-example there are three top directories: apps/ holds a HelmRelease for podinfo in apps/base/podinfo/ with staging and production overlays that patch the chart version range and the httpRoute hostnames; infrastructure/controllers/ holds OCIRepository and HelmRelease pairs for cert-manager and Envoy Gateway; infrastructure/configs/ holds a ClusterIssuer, a GatewayClass and a Gateway, listed in its kustomization.yaml. Each cluster directory under clusters/ has an ArtifactGenerator in artifacts.yaml that splits the monorepo into an infrastructure and an apps artifact, and Flux Kustomization objects in infrastructure.yaml and apps.yaml with interval: 1h, retryInterval: 2m, timeout: 5m, prune: true and a dependsOn chain from infra-controllers to infra-configs to apps. clusters/production/infrastructure.yaml already shows the per-cluster pattern: a JSON patch on the letsencrypt ClusterIssuer swaps the ACME server.

Nothing in the repository mentions the notification controller yet, so the agent adds infrastructure/configs/notifications.yaml and lists it in that directory's kustomization.yaml. The file holds a Provider of type: slack in flux-system with a channel and a secretRef to a Secret named slack-url whose address key is the incoming webhook URL, and an Alert that names the Provider in providerRef and lists its eventSources: the Kustomization objects in flux-system by wildcard, and the HelmRelease objects in podinfo, cert-manager and envoy-gateway-system by namespace, since each lives in its own. The Alert carries a summary naming the cluster so two clusters posting to one channel can be told apart.

The webhook URL is a secret, so the agent commits none. .fluxschema.yml already skips Secret:/sops during validation, which says this repository expects SOPS-encrypted Secrets; the pull request shows the kubectl -n flux-system create secret generic slack-url --from-literal=address=… command for a cluster where you would rather create it by hand, and the SOPS path for committing it encrypted. Severity follows the existing per-cluster patch style: the base Alert uses eventSeverity: info, and clusters/production/infrastructure.yaml gains a patch on the infra-configs Kustomization that sets it to error, so production posts only failures while staging posts every reconciliation.

Then it checks the change the way .github/workflows/test.yaml does. It installs the Flux CLI with the install.sh script from the README and the Flux Schema CLI, runs scripts/validate.sh -d . -c .fluxschema.yml, which builds every kustomize overlay and validates each object against the ecosystem schema catalog, and runs flux migrate -f . --yes followed by git diff --stat to confirm the new objects use current API versions. The e2e.yaml workflow needs a Kind cluster, which the sandbox cannot start, so the agent says that check runs in CI on the pull request and does not claim to have run it.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add Flux notification alerts to Slack in this GitOps repository. Read the clusters, apps and infrastructure directories, the ArtifactGenerator and Kustomization objects per cluster, .fluxschema.yml, scripts/validate.sh and the GitHub workflows first. Add a Provider of type slack with a secretRef to a Secret named slack-url and an Alert whose eventSources cover every Flux Kustomization and every HelmRelease in the repository, in the directory the existing per-cluster patches already reach. Commit no webhook URL; document creating the Secret with kubectl or SOPS. Make staging alert on info and production on error using the same patch style the repository uses for the ClusterIssuer. Run the schema validation script and flux migrate exactly as the test workflow does and include their output. Do not claim to have run the Kind end-to-end job. Open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request that adds infrastructure/configs/notifications.yaml (the Provider and the Alert), extends infrastructure/configs/kustomization.yaml to include it, patches eventSeverity in clusters/production/infrastructure.yaml, and documents the slack-url Secret in the README under the bootstrap section. No Secret and no webhook URL are in the diff.

The description quotes the validate.sh summary with the new objects counted as valid and the empty git diff --stat after flux migrate, and lists each eventSources entry with the namespace it watches. The commands and full output are in the transcript at GET /o/{org}/sessions/{id}/messages; the test and e2e workflows run on the pull request itself.

Before merging, a reviewer creates the slack-url Secret on each cluster or adds the SOPS-encrypted file, checks the channel name, and decides whether info on staging is too noisy once the first reconciliations post. A follow-up message to the same session can add an exclusionList for events you never want to see.

Run it on every cluster added to the GitOps repository

A platform team that keeps one Flux repository per environment starts one run per repository with one POST /o/{org}/sessions each, the repository in resources and this prompt as input. Each run reads its own cluster directories and namespaces, so a repository with five HelmRelease namespaces gets five eventSources entries and the right per-cluster severity patches.

Send a request_id, a UUID v5 of the repository's full name, so a retried call returns the run it already started. The key's webhook_url reports when each run the key starts finishes, with the run's final answer in result.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

A notification manifest is small, and getting it wrong is quiet: a HelmRelease in a namespace the Alert does not list fails without a message, and an API version the controller no longer serves is only caught when Flux applies it. The agent runs the same schema validation and migration check the repository's CI runs, in a sandbox of its own, and the pull request shows that output.

The run also reads the repository's own conventions, the artifact split, the dependency chain and the per-cluster patch style, and follows them rather than adding a new pattern. Several repositories can be done at once, each in its own sandbox with its own pull request and its own list of namespaces.

Frequently asked questions

Does this need a new Flux component?

No. The notification controller is one of the controllers flux bootstrap installs by default, alongside source, kustomize and helm; the --components-extra=source-watcher flag in this README adds a fifth. The agent checks clusters/<name>/flux-system/ for a components list before saying so for your repository.

Where does the Slack webhook URL go?

In a Secret named slack-url in flux-system, under the address key, created with kubectl on the cluster or committed SOPS-encrypted. The Provider only references it. The agent never writes the URL into a tracked file, and the pull request says how to create the Secret both ways.

Why are HelmReleases listed per namespace?

An Alert's eventSources entry names a kind, a name or wildcard, and a namespace. In this repository the Flux Kustomization objects live in flux-system while each HelmRelease lives with its workload in podinfo, cert-manager or envoy-gateway-system, so one wildcard entry per namespace is what covers them all.

Can staging and production post to different channels?

Yes. Add a second Provider, or patch the Provider's channel per cluster the same way the agent patches eventSeverity. Say which channel each cluster should use in the prompt and the agent writes the patch.

More Flux jobs

More jobs like this: Hand off a long task

Keep reading