Skip to content

feat(deploy): the colour dimension — two web-api Deployments, one Service selector - #461

Merged
athvin merged 1 commit into
mainfrom
bm/bluegreen-p9-colour
Nov 5, 2026
Merged

athvin merged 1 commit into
mainfrom
bm/bluegreen-p9-colour

Conversation

@athvin

@athvin athvin commented Nov 3, 2026

Copy link
Copy Markdown
Owner

The traffic half of blue/green, and the only part that needs no new controller. web-api becomes two Deployments, one per colour, and er-api/er-web select color.active. A cutover is one field on two Service objects; a rollback is that field moving back, with the old pod still running because its colour was never scaled down.

Measured on a live kind cluster, at the endpoint level

That is where "zero downtime" is either true or it isn't. 400 samples of endpoints/er-web across a cutover:

samples=400  EMPTY_SAMPLES=0  distinct_consecutive_states=2
10.244.0.35      <- blue pod
10.244.0.36      <- green pod

Zero empty samples. The Service transitions straight from one pod's IP to the other, with no window in which it has no backend. And the previews inverted correctly throughout:

color.active er-api er-api-preview
blue BLUE GREEN
green GREEN BLUE
rolled back to blue BLUE GREEN

Run in an isolated bg-probe namespace against the chart's own rendered Services, with stub pods carrying the chart's exact colour labels. The namespace was torn down and the pre-existing er-kind release was left untouched.

Four Services, and the preview pair is the point

er-api-preview / er-web-preview select the inactive colour, so a new colour can be deployed, probed and smoke-tested while taking no production traffic. They're ClusterIP like the others, so kubectl port-forward reaches them — which is why this works today, before task 1.4's ALB exists.

Three decisions that make the failure modes unrepresentable

color.active is a value; the inactive colour is derived. Two independent values could be set to the same colour, which renders a preview Service aimed at the live pod — and then the cutover's smoke test passes by testing what is already in production. That failure looks like success, which is the worst kind.

The chart refuses an invalid colour — fail, not a lint. A typo'd --set color.active=gren would render Services selecting a colour no Deployment carries: no endpoints, nothing served, and helm upgrade reporting success because every object applied cleanly. CI can't catch it either, since the value arrives on the deploy command line rather than in the tree. Refusing to render is the only place it's checkable at the moment it's wrong. Observed refusing:

Error: color.active must be "blue" or "green", got "gren" — the Services would
select a colour no Deployment carries, leaving them with no endpoints while the
upgrade reported success

Per-colour digests are why api/web nest under each colour: a deploy pins the new image into the inactive colour while the live one keeps the digest it's serving. One shared images.api would re-render both Deployments every upgrade and restart the colour taking traffic — the outage this exists to remove. Empty falls back to images.*, so kind, a developer namespace and make dev-up need no colour values at all.

This lands inert

Defaults are blue at one replica, green at zero, so the existing CI deploy keeps doing exactly what it did. The three-phase cutover job is the next change; so is moving the init container to a pre-upgrade hook that may only add, which is what er-server migrate --expect-additive (#456) was built for.

Adopting it costs one restart — web-api is renamed web-api-blue, so the first upgrade deletes the old object and creates the new one. Every upgrade after that can be a cutover.

Two call sites that would have broken silently

  • make dev-resume ran rollout status deployment/web-api, which no longer resolves, and scale --all would have woken both colours — so both would serve and the preview Service would point at a live pod. It now reads the live colour from the Service selector, the same single source of truth the cutover uses.
  • kind.yml's failure diagnostic logged deploy/web-api. Now by label, stable across both colours and across a cutover. A diagnostic that silently prints nothing is worse than none, and it only runs when something has already failed.

One property documented where it will be needed

allow-alb-to-web is colour-agnostic on purpose. Both colours carry name: web-api, so the hole admits whichever is live without knowing which. Pinned to a colour, a cutover would blackhole the newly-active pod until someone also updated a NetworkPolicy in the other chart — and the symptom would be a green deploy serving 100% errors with every probe passing.

Verification

  • make check green; helm lint clean.
  • helm template + kubeconform -strict on the dev, kind and namespace profiles. The kind profile correctly renders both colours and no er-web* Services, since web.enabled: false.
  • The colour guard observed refusing an invalid value.
  • The cutover, rollback and zero-gap measurement above, on a real cluster.

Note on CI: GitHub is currently refusing to allocate runners for this account (jobs die in seconds with steps=0, repo-wide, every branch — see ci-jobs-fail-to-start-quota). Every gate above was run locally. This PR's checks will need runners to report.

🤖 Generated with Claude Code

…vice selector

The traffic half of blue/green, and the only part that needs no new controller:
`web-api` becomes two Deployments, one per colour, and `er-api`/`er-web` select
`color.active`. A cutover is one field on two Service objects. A rollback is
that field moving back, with the old pod still running because its colour was
never scaled down.

**Measured on a live kind cluster, in an isolated namespace, at the endpoint
level — which is where "zero downtime" is either true or not:**

    samples=400  EMPTY_SAMPLES=0  distinct_consecutive_states=2
    10.244.0.35      <- blue pod
    10.244.0.36      <- green pod

400 samples of `endpoints/er-web` across a cutover, none of them empty. The
Service transitions directly from one pod's IP to the other with no window in
which it has no backend. Before and after, the previews inverted correctly:

    active=blue    er-api -> BLUE   er-api-preview -> GREEN
    active=green   er-api -> GREEN  er-api-preview -> BLUE
    rollback       er-web -> BLUE   er-web-preview -> GREEN

**Four Services, and the preview pair is the point.** `er-api-preview` and
`er-web-preview` select the INACTIVE colour, so a new colour can be deployed,
probed and smoke-tested while taking no production traffic. They are ClusterIP
like the others, so `kubectl port-forward` reaches them — which is why this
works today, before task 1.4's ALB exists.

**`color.active` is a value; the inactive colour is DERIVED.** Two independent
values could be set to the same colour, which renders a preview Service aimed
at the live pod — and then the cutover's smoke test passes by testing what is
already in production. That failure looks like success, so the shape makes it
unrepresentable.

**The chart REFUSES an invalid colour** (`fail`, not a lint). A typo'd
`--set color.active=gren` would render Services selecting a colour no Deployment
carries: no endpoints, nothing served, and `helm upgrade` reporting success
because every object applied cleanly. CI cannot catch it either — the value
arrives on the deploy command line, not in the tree. Refusing to render is the
only place it is checkable at the moment it is wrong. Observed refusing.

**Per-colour digests** are why the `api`/`web` blocks nest under each colour: a
deploy pins the new image into the inactive colour while the live one keeps the
digest it is serving. One shared `images.api` would re-render BOTH Deployments
on every upgrade and restart the colour taking traffic — the outage this exists
to remove. Empty falls back to `images.*`, so kind, a developer namespace and
`make dev-up` need no colour values and get the topology they had.

**This lands inert.** Defaults are `blue` at one replica and `green` at zero, so
the existing CI deploy keeps doing exactly what it did. The three-phase cutover
job is the next change; so is moving the init container to a pre-upgrade hook
that may only add, which is what `er-server migrate --expect-additive` was built
for. Adopting this costs ONE restart, because `web-api` is renamed
`web-api-blue`.

Two call sites would have broken silently and are fixed here:

- `make dev-resume` ran `rollout status deployment/web-api`, which no longer
  resolves, and `scale --all` would have woken BOTH colours — so both would
  serve and the preview Service would point at a live pod. It now READS the live
  colour from the Service selector, the same single source of truth the cutover
  uses, so it cannot drift from whichever colour is actually serving.
- `kind.yml`'s failure diagnostic logged `deploy/web-api`. Now by label, which
  is stable across both colours and across a cutover — a diagnostic that
  silently prints nothing is worse than none, and it only runs when something
  has already failed.

And one property documented where it will be needed: `allow-alb-to-web` is
colour-agnostic ON PURPOSE. Both colours carry `name: web-api`, so the hole
admits whichever is live without knowing which. Pinned to a colour, a cutover
would blackhole the newly-active pod until someone updated a NetworkPolicy in
the other chart — and the symptom would be a green deploy serving 100% errors
with every probe passing.

Verified: `make check` green; `helm lint` clean; `helm template` +
`kubeconform -strict` on the dev, kind and namespace profiles (the kind profile
correctly renders both colours and no `er-web*` Services, since `web.enabled` is
false); the guard observed refusing an invalid colour; and the cutover,
rollback and zero-gap measurement above on a real cluster. The probe namespace
was torn down and the pre-existing `er-kind` release was left untouched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin force-pushed the bm/bluegreen-p9-colour branch from 26096b5 to a97b7db Compare November 5, 2026 01:18
@athvin
athvin merged commit fea1bd0 into main Nov 5, 2026
36 checks passed
athvin added a commit that referenced this pull request Nov 5, 2026
…g it (#499)

Re-ran the three CUR probes against the November partition. One probe is
unchanged and the spend underneath it is not.

Split cost allocation is still producing nothing: 0 non-null out of 19,770
November rows, three days after the first probe said the same. Three more
days of pod-level cost are permanently unrecoverable.

The thing the re-run was not looking for is that November is on pace for
roughly six times October. $160.47 in five days against $184.23 for all of
October. S3 was not in October's top five; in November it is $76.27, and all
of it is one line: 837 GB of `USE2-DataTransfer-Out-Bytes` from
`er-ci-sccache` at $0.090/GB. That is internet egress — GitHub-hosted runners
are not in the VPC, so a Gateway Endpoint cannot help and every sccache read
leaves the region at the public rate.

Nov 4 isolates the cause for free: that is the day the Actions billing block
stopped CI running, and it egressed $0.00 against a $21.55 total. A day with
no CI costs ~$20 and ships nothing; a day with CI costs $32-52 and the whole
difference is this line. Nov 1 reads as $0.03 only because the first 100 GB a
month is free, which was consumed during Nov 2.

This is the price of the CI speedup and it was never measured. #424 removed
rust-cache, which made sccache the only cache; the test job was then sharded,
which multiplied the runners each pulling from it; and the hit rate is ~99%,
so nearly every compilation unit downloads its object. PR wall time went
32-35 min to ~10 min. At ~$31 per CI day that is ~$600-900/month against a
$600 budget that breaches mid-month.

The baseline rose independently too — EC2 from ~$1.50/day to ~$7.60/day —
which is the observability stack, the second web-api Deployment from #461 and
the dispatcher. Real, new, and not sccache.

Recorded as a decision with four options rather than a fix, because trading
25 minutes of wall clock for this is a judgement call and the defect was not
knowing the number. The one thing the doc rules out is emptying the bucket: a
cold sccache costs a 42-minute PR, which is what it was built to fix.

Co-authored-by: bmoore813 <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants