Rollouts
Roll a Kubernetes service out gradually, blue-green or canary, with health gates and one-command promote and abort. Nothing is installed in the cluster: muster uses standard Deployments, Services and one ConfigMap per service.
Before you start
- kubectl with get/create/patch on Deployments, Services and ConfigMaps, and get on ReplicaSets and Pods. muster doctor checks this with kubectl auth can-i.
- jq.
- Remote services run the engine's kubectl calls over key-based SSH. Fleet Cloud remotes aren't supported for strategies yet.
Strategies
- blue-green: the new version comes up next to the old one with 0% of the traffic. You (or a gate) check it, then one Service selector change moves all traffic over. Switching back is just as quick.
- canary: the new version gets a slice of the traffic (10% → 25% → 50% → 100% by default). Health gates run at every step; a failing gate sends all traffic back to stable.
- rolling (default): your hook's normal kubectl rollout. muster shows which version every live ReplicaSet runs and how much traffic it carries.
Run a rollout
muster deploy api # uses the strategy from muster.json
muster deploy api --strategy canary # this run only
muster deploy api --version v1.4.2 # version label (default: tag / SHA)
muster deploy api --no-wait --json # CI: start it, stop at the first step, exit 0
muster rollout status [api] [--watch] [--json]
muster promote api # canary: next step; blue-green: switch traffic
muster promote api --to 50 # go to 50% and pause there
muster promote api --full # straight to 100%
muster abort api # 100% back to stable, candidate scaled to 0
muster rollback apipromote and abort ask for confirmation in a terminal (--yes, --json or no TTY skip it) and take the deploy lock. A paused rollout exits 0 with the result paused, so you can continue later from any machine that reaches the cluster. A new deploy of a service with a paused rollout is refused; deploy --force aborts it first.
| State | What muster rollback does |
|---|---|
| Rollout in progress | Same as muster abort |
| Completed blue-green | Switches the Service back to the previous colour, scaling it up first if needed |
| Completed canary, rolling | Runs rollback.sh (kubectl rollout undo on the stable Deployment) |
How it works
Blue-green (service-selector)
- First deploy only: acme-api is copied to acme-api-blue with muster.dev/track=blue. Once ready, the Service selector gets the label and the original is scaled to 0. Both serve during the copy.
- The inactive colour is (re)created from the live one at 0 replicas, the hook points it at the new image, and muster scales it up and waits.
- Gates run against it (optionally through the preview Service), then it waits for promotion or auto-promotes.
- Promote patches the selector, runs the gates again against production (flipping back on failure), drains, and scales the old colour down.
Canary (replicas)
The stable Deployment and <deploy>-canary both match the Service, so traffic follows the ratio of ready pods. With N stable replicas, the canary gets ceil(N × W / 100) pods (at least 1). muster reports the target and the effective weight; 10% of 2 pods is really 50%. At 100% the canary's image is copied onto the stable Deployment, which rolls out normally.
Gates
| Gate | Fails when |
|---|---|
| pod_stability | A candidate pod hits CrashLoopBackOff, an image pull error, InvalidImageName, CreateContainerConfigError, RunContainerError or OOMKilled, or restarts more than max_restarts. Fails at once |
| health | health.sh exits non-zero max_failures times in a row, run against the candidate |
State and labels
Each rollout is kept in ConfigMap/muster-rollout-<deployment>. Candidate pods get muster.dev/track, muster.dev/version and muster.dev/service. Hooks receive MUSTER_TARGET_DEPLOYMENT, MUSTER_IMAGE_TAG, MUSTER_DEPLOY_VERSION and MUSTER_STRATEGY; MUSTER_K8S_DEPLOYMENT points at the candidate, so generated hooks work unchanged.
Cancelling a rollout
Interrupting a rollout never leaves traffic on an unmonitored candidate. Before traffic moves, the candidate is scaled to 0. A canary with traffic split goes back to 100% stable (or keeps its weight with on_interrupt: pause if the last gate passed). Right after a blue-green switch, before the post-switch check passes, the Service is switched back. muster then records cancelled, releases the locks and exits 130.
With Argo CD or Flux
A GitOps controller with self-heal reverts the Service selector and replica changes muster makes during a rollout. Ignore those fields in the Application and respect that on sync:
spec:
ignoreDifferences:
- group: ""
kind: Service
name: acme-api
jsonPointers:
- /spec/selector/muster.dev~1track
- group: apps
kind: Deployment
name: acme-api
jsonPointers:
- /spec/replicas
syncPolicy:
syncOptions:
- RespectIgnoreDifferences=true-blue, -green and -canary Deployments and the rollout ConfigMap are not in Git. Make sure automated pruning won't delete them. An HPA on the stable Deployment fights the replica ratio (muster doctor warns about it).Configuration reference
Add strategy to a service in muster.json. Leaving it out means rolling. "strategy": "canary" uses all the defaults.
"api": {
"name": "API",
"k8s": { "deployment": "acme-api", "namespace": "prod" },
"strategy": {
"type": "canary",
"steps": [10, 25, 50, 100],
"pause": "manual"
}
}| Field | Default | Notes |
|---|---|---|
type | rolling | rolling, blue-green or canary. Blue-green and canary need k8s.deployment |
traffic | auto | service-selector (blue-green) or replicas (canary). gateway-api and ingress-nginx are reserved for later |
steps | [10, 25, 50, 100] | Canary weights, increasing; each can be {weight, pause} |
pause | 60 | Seconds or "manual", for every step except 100 |
auto_promote | false | Blue-green: switch as soon as the gates pass |
drain_seconds | 30 | Wait after switching before scaling the old version down |
keep_old_seconds | 0 | Blue-green: keep the old colour warm; -1 keeps it until the next deploy |
auto_rollback | true | Restore stable when a gate fails; false leaves it degraded to inspect |
on_interrupt | abort / pause | What Ctrl+C does (canary / blue-green defaults) |
preview.enabled | false | Blue-green: also create <service>-preview selecting the new colour |
analysis.interval_seconds | 10 | Time between gate checks (1–300) |
analysis.max_failures | 2 | Consecutive health failures before the gate fails |
analysis.max_restarts | 0 | Candidate container restarts allowed |
Switching an existing project
muster setup --update --strategy api=canary # or api=blue-green / api=rolling
muster hooks approve api
muster deploy api --dry-run # shows the step planThis writes the strategy and regenerates the service's hooks from the strategy templates. A hook you edited is kept; the new template is written next to it as deploy.sh.strategy-new.