Skip to content

k8s rollout: restart by image instead of variant label - #41

Closed
daanpersoons wants to merge 1 commit into
mainfrom
feature/rollout-restart-by-image
Closed

k8s rollout: restart by image instead of variant label#41
daanpersoons wants to merge 1 commit into
mainfrom
feature/rollout-restart-by-image

Conversation

@daanpersoons

@daanpersoons daanpersoons commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What

Change the k8s deploy rollout to restart every deployment running the just-built image, instead of relying on a synthesized variant=<monorepo-folder> label selector.

Why

Today docker/setup appends variant=<path> to the rollout label selector, which forces every infra repo to hand-patch a variant: label onto its deployments.

  • one monorepo image typically backs several deployments (api, worker, scheduler, websockets, …) you must remember to label all of them;
  • a missed/typo'd label silently skips a restart.

Matching on the image the pipeline just pushed is precise and needs zero labels.

Changes

  • infra/k8s/rollout — new rollout-image input + image-match branch. Selection priority (first match wins):
    1. rollout-deployments (explicit names) — override
    2. rollout-labels (selector) — override
    3. rollout-image — default: kubectl get deploy -o json | jq (image startswith) | xargs kubectl rollout restart
    4. else: restart all in namespace
  • docker/setup — stop synthesizing variant=<path>; pass K8S_LABELS through as-is.
  • docker-build-and-deploy / docker-promote-to-environment — pass rollout-image = <registry>/<image>.
  • Docs updated.

Backward compatibility

Repos that set K8S_DEPLOYMENTS or K8S_LABELS keep them as overrides. Repos that relied on the auto variant selector now restart by image — strictly more correct (catches all deployments sharing the image) and the variant: label patch becomes unnecessary.

The deploy pipelines restarted deployments via a synthesized `variant=<monorepo-folder>`
label selector, which required every infra repo to hand-patch a `variant:` label onto its
deployments — brittle and easy to miss (one image often backs several deployments).

Instead, restart every deployment whose pods actually run the just-built image:
- infra/k8s/rollout: new `rollout-image` input + image-match branch. Priority is
  deployments (explicit) > labels (explicit) > image (default) > all.
- docker/setup: stop synthesizing the `variant=<path>` selector; pass K8S_LABELS through as-is.
- docker-build-and-deploy / docker-promote-to-environment: pass rollout-image = <registry>/<image>.

Backward compatible: repos that set K8S_DEPLOYMENTS or K8S_LABELS keep those as overrides.
Repos that relied on the auto variant selector now restart by image (strictly more correct —
catches api + worker + scheduler that share the image), and no longer need the variant label.
@daanpersoons
daanpersoons deleted the feature/rollout-restart-by-image branch August 4, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant