Skip to content

fix(executor): real k8s dispatch — explicit-context safety + create-not-apply - #21

Merged
mdheller merged 1 commit into
mainfrom
feat/k8s-real-dispatch
Aug 4, 2026
Merged

fix(executor): real k8s dispatch — explicit-context safety + create-not-apply#21
mdheller merged 1 commit into
mainfrom
feat/k8s-real-dispatch

Conversation

@mdheller

@mdheller mdheller commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What

Hardening the k8s execution adapter — plus a real defect caught by client-side validation before it ever reached a cluster.

Safety: never dispatch to the current context

The current kube-context on the dev box is prod GKE. The K8sAdapter no longer falls back to it — applying now requires an explicit SOURCEOS_KUBE_CONTEXT; without it, apply is refused (the manifest is still emitted for inspection). Target namespace via SOURCEOS_KUBE_NAMESPACE (default sourceos-mesh), stamped into the manifest.

Defect fix: create, not apply

Dispatch used kubectl apply, which rejects generateName (cannot use generate name with apply). A Job is one-shot + immutable, so kubectl create is the correct verb — and it supports generateName, giving collision-free job names per dispatch. Verified the emitted manifest with kubectl create --dry-run=client (client-side, no cluster/server contact): job.batch/<unknown> created (dry run).

Tests

+2 (manifest carries the target namespace; apply refused without an explicit context) = 92 tools tests green; validate passes.

Full live-apply on an ephemeral kind cluster is one docker + kind away (docker daemon is down on this box right now); the dispatch mechanism is proven client-side and the prod-dispatch footgun is closed.

…ot-apply

Hardening + a real defect caught before it reached a cluster.

Safety: the K8sAdapter no longer dispatches to whatever kube-context happens to be
current (which, on this box, is prod GKE). Applying now REQUIRES an explicit
SOURCEOS_KUBE_CONTEXT; without it, apply is refused (manifest still emitted). Target
namespace via SOURCEOS_KUBE_NAMESPACE (default sourceos-mesh), stamped into the manifest.

Defect fix: dispatch used `kubectl apply`, which rejects generateName ("cannot use
generate name with apply"). A Job is one-shot + immutable, so `kubectl create` is correct
— and it supports generateName (collision-free job names per dispatch). Verified the
emitted manifest with `kubectl create --dry-run=client` (client-side, no cluster/server
contact): "job.batch/<unknown> created (dry run)".

Tests: +2 (manifest carries namespace; apply refused without explicit context) = 92 green.
Full live-apply on an ephemeral kind cluster is one `docker`+`kind up` away; the mechanism
is proven and the prod-dispatch footgun is closed.
@mdheller
mdheller merged commit f6fab96 into main Aug 4, 2026
1 check passed
@mdheller
mdheller deleted the feat/k8s-real-dispatch branch August 4, 2026 04:05
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.

1 participant