Self-hosted FlagsmithKubernetes operatorApache-2.0

A circuit breaker for Flagsmith flags

When a workload breaks right after a flag is switched on, Flagbreaker reports it to Flagsmith Feature Health, switches the flag off, restarts the crashed pods and confirms on the cluster that the workload recovered.

One command brings up kind, Flagsmith 2.295.2, Flagbreaker and a demo shop.

shop/checkout-new-pricing · a real runArmed
ArmedWatching new_pricing and 2 pods
  1. new_pricing was switched on in Production by admin@flagbreaker.local
  2. 1 of 2 pods started failing 2s after the switch-on
  3. Switched new_pricing off: the environment default and 1 segment override
  4. Restarted 1 crashed pod, so it reads the flag again now
  5. Verified recovery: 2 of 2 pods ready with no new crashes for 22s

The gap

A flag flip changes production without a deploy

Google's SRE book finds that roughly 70% of outages come from changes to a live system. A flag flip is one of those changes, and the tools that guard deploys never see it.

Rollout tools can't see it

Argo Rollouts and Flagger watch new ReplicaSets. A flag flip creates none, so a bad flag stays on until a person notices.

Flagsmith records, but acts only inside a pipeline

Feature Health marks a flag Unhealthy. Only a Release Pipeline stage (a closed beta) switches it off, and only while the flag waits in that stage. A flag switched on by hand stays on.

Built on open-source Flagsmith

Every decision starts and ends in Flagsmith

The demo runs Flagsmith 2.295.2 from its official Helm chart and sets everything up through its API: organisation, project, flags, a segment, two Feature Health providers and a signed webhook. No clicks.

Flags and segment overrides

Switches off the environment default and every segment override that is on, in one versioned change through /api/__future__, then reads it back.

Remote config values

When a new value breaks the workload, puts the previous value back and leaves the flag on.

Feature Health provider

Reports Unhealthy and Healthy with the incident timeline, failing pods and request counts, shown in the flag's Health tab.

Feature Health actuator

Trips on other providers' alerts, such as Grafana, and waits for them to clear. A person's Dismiss counts as an acknowledgement.

Signed webhooks

Reads FLAG_UPDATED events, checked with HMAC-SHA256, to learn exactly when a flag changed and who changed it.

Settings as flags

flagbreaker_enabled, flagbreaker_mode and flagbreaker_policy, read with the official Go SDK. It only watches until you say act, and never gets around change requests.

The loop

From a flag flip to a verified recovery

Each step lands in the guard's timeline, in Kubernetes Events, in Prometheus metrics and in Flagsmith's Health tab.

1

Notice

A signed webhook says who changed the flag and when; polling every 5s backs it up.

2

Watch

Pods, ReplicaSets and, if asked, each pod's request counter.

3

Decide

One pure function: was it fine before, did it break after, was there a deploy, which mode applies.

4

Act

Switch off or put the value back, confirm it, report Unhealthy, restart crashed pods.

5

Verify

Every pod ready with no crash, requests fine, no alert firing. Then Healthy.

Recorded, not typed

Three incidents from a green CI run

Every push runs these on a fresh kind cluster with self-hosted Flagsmith. The timelines are copied from the run's output.

Pods crash

new_pricing makes the shop exit. The flag is switched off and the pods are restarted.

13:05:17  new_pricing was switched on in Production by admin@flagbreaker.local
13:05:19  Deployment shop/checkout: 1 of 2 pods started failing 2s after the switch-on
13:05:19  Switched new_pricing off in Production (its environment default and 1 segment override)
13:05:19  Restarted 1 crashed pod
13:05:42  Verified recovery: all 2 pods ready with no new crashes for 22s

A bad config value

checkout_config gets a tax rate the shop can't parse. The previous value goes back; the flag stays on.

checkout_config's value was changed, from {"tax_rate": 0.08} to {"tax_rate": "8%"}
Deployment shop/checkout: 2 of 2 pods started failing 1s after the value changed
Put checkout_config's previous value back: {"tax_rate": 0.08}
Restarted 2 crashed pods
Verified recovery: all 2 pods ready for 23s. Recovered 25s after the value went back

Requests fail, pods stay up

new_payments fails every payment while every pod stays ready. Flagbreaker reads each pod's request counter, with no Prometheus server.

new_payments was switched on in Production by admin@flagbreaker.local
30 of 42 requests failed (71.4%, over the 5% limit) in the 8s after the switch-on
Switched new_payments off in Production (its environment default)
Verified recovery: all 2 pods ready, and 0 of 106 requests failed in 21s

Live dashboard

Every guarded flag, on one page

Flagbreaker serves a read-only dashboard of every guard: what Flagsmith serves for the flag, the workload's phase, request readings and each step of the incident. In the demo, bash hack/demo/dashboard.sh opens it at localhost:8091; in your cluster, set dashboard.enabled=true and port-forward (on main, not yet in release 0.2.0).

Flagbreaker's dashboard showing four guards on the demo shop, with flags on or off, phases Armed and Recovered, and incident timelines
The dashboard on the demo cluster after the end-to-end run: three flags switched off and recovered, one value put back.

Try it

On your laptop, in one command

You need Docker with about 3 GB of memory, bash, curl and jq. The scripts fetch their own pinned, checksummed kind, kubectl and helm, and never touch your kubeconfig.

  1. Bring up kind, self-hosted Flagsmith, Flagbreaker and a demo shop. About 8 minutes the first time.

    $ git clone https://github.com/Pradyuman-aviator/flagbreaker && cd flagbreaker
    $ bash hack/demo/up.sh
  2. Watch every guard live, in the browser or the terminal.

    $ bash hack/demo/dashboard.sh   # http://localhost:8091
    $ bash hack/demo/watch.sh
  3. Break the shop the way a person would, and watch it recover on its own.

    $ bash hack/demo/break.sh                  # pods crash
    $ bash hack/demo/break.sh checkout_config  # a bad config value
    $ bash hack/demo/break.sh new_payments     # payments fail, pods stay up
    $ bash hack/demo/alert.sh fire             # a Grafana alert through Feature Health
  4. Delete it all.

    $ bash hack/demo/down.sh

Install

In your cluster, from GHCR

Each release publishes the Helm chart and a multi-arch image (amd64 and arm64). It watches until you tell it to act.

$ helm install flagbreaker oci://ghcr.io/pradyuman-aviator/charts/flagbreaker --version 0.2.0 \
    -n flagbreaker-system --create-namespace \
    --set flagsmith.url=http://flagsmith-api.flagsmith:8000 \
    --set flagsmith.apiKey=<organisation API key> \
    --set flagsmith.healthWebhookPath=/api/v1/feature-health/<path> \
    --set flagsmith.settingsEnvironmentKey=<environment holding the flagbreaker_* flags>
$ kubectl annotate namespace shop flagbreaker.dev/allowed-environments=<client-side key>
$ kubectl annotate deployment checkout -n shop \
    flagbreaker.dev/flags=new_pricing,express_checkout \
    flagbreaker.dev/environment-key=<client-side key>

The deployment guide covers secrets, going live safely and upgrades; the runbook covers each step after a trip.

Proof

Checked on every push

174

Go tests with the race detector, including whole incidents run through the controller against a fake Flagsmith.

5

end-to-end scenarios on a fresh kind cluster with self-hosted Flagsmith, in CI.

3–8s

from the flag change to detection, across the five scenarios of one full run.

0s

from detection to the switch-off, then recovery checked on the pods themselves.