Skip to content

fix(k8s): set the kube context and namespace on devops pods - #4514

Merged
dan-petty merged 3 commits into
mainfrom
fix/4512-set-the-kube-context-and-namespace
Nov 11, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/4512-set-the-kube-context-and-namespace

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Each devops-cli container in k8s/devops sets K8S_CONTEXT to homelab-k3s, the cluster name of the monitoring stack, and POD_NAMESPACE to its namespace. The namespace comes from the Downward API. The runner template sets the plain value devops, because the admission policy roadmap-service-jobs refuses valueFrom in a Job of the Service.

The tracer reads these two values first. No pod set them, so the spans and log records named the cluster minikube (the default of k8s.context) and had no k8s.namespace.name.

A check of the k8s row of devops ci reads the render of k8s/devops and fails when a devops-cli container does not set both values. A test holds the tracer to the two names.

Closes #4512
Change: openspec/changes/archive/2026-11-11-4512-set-the-kube-context-and-namespace/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/k8s Kubernetes commands, Helm charts, pods, services, and policies labels Nov 11, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Proof

Fail-to-pass of the manifest check. I ran tests/gate/k8s_checks/telemetry_resource.py against the k8s/ tree of origin/main (git archive origin/main k8s) and against this branch:

origin/main manifests: FAILED (AssertionError)  # 5 containers, K8S_CONTEXT None, POD_NAMESPACE None
branch manifests:      PASSED

uv run devops ci fail-to-pass --base origin/main: 0 failed on base (0 failed and 37 passed in tests/telemetry/test_telemetry.py). This is expected. The defect is in the manifests, not in src/. The new pytest test holds the names that the tracer already reads (K8S_CONTEXT, POD_NAMESPACE), so it passes on the base too. The Fail-to-Pass Check workflow runs only for src/** changes, and this PR changes no file under src/. The k8s row check above is the fail-to-pass proof.

Admission policy. The policy roadmap-service-jobs, run with the helpers of tests/gate/k8s_checks/job_admission_policy.py against the Job that build_job makes from the runner template:

plain value:  []
downward API: ['An env entry must not use valueFrom.']

Local checks (rebased on 453aed0): uv run devops ci --check --only lint,format,typecheck,docs,test-tree,k8s: all pass (k8s: 104 cases, 0 failed). The 26 pytest files that read the changed manifests: 920 passed.

Live steps (after the merge)

No hand step. Argo CD (Application devops) applies the 5 changed objects. The ConfigMap and the Secrets do not change.

  • roadmap-service and mcp-server roll at the sync. A new runner Job takes the values from CronJob devops-cli-runner at its creation.
  • Check: in Grafana Explore, Tempo, run { resource.service.name = "roadmap-service" && resource.k8s.cluster.name = "minikube" } | count_over_time() over the 30 minutes after the roll. Expect 0. { resource.service.name = "roadmap-service" } | count_over_time() by (resource.k8s.cluster.name) shows homelab-k3s.

Each devops-cli container in k8s/devops sets K8S_CONTEXT to the cluster
name of the monitoring stack and POD_NAMESPACE to its namespace, so the
spans and log records stop naming the cluster minikube. A check of the
k8s row of devops ci holds the values.
@dan-petty
dan-petty force-pushed the fix/4512-set-the-kube-context-and-namespace branch from 515c48d to a5b05cc Compare November 11, 2026 05:59
@dan-petty
dan-petty marked this pull request as ready for review November 11, 2026 06:10
@dan-petty
dan-petty enabled auto-merge (squash) November 11, 2026 06:10
@dan-petty
dan-petty merged commit 9087b39 into main Nov 11, 2026
31 checks passed
@dan-petty
dan-petty deleted the fix/4512-set-the-kube-context-and-namespace branch November 11, 2026 06:11
dan-petty pushed a commit that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.112.0](v0.111.0...v0.112.0)
(2026-11-11)


### Features

* **k8s:** export gateway spans without key metadata
([#4520](#4520))
([7234d71](7234d71))
* **k8s:** set the homelab domain in container env values
([#4608](#4608))
([a3bcf7c](a3bcf7c))
* **telemetry:** send pydantic-ai spans through the exporter seam
([#4538](#4538))
([fcf2a7a](fcf2a7a))


### Bug Fixes

* **ai:** price cached prompt tokens of chat calls
([#4584](#4584))
([f84bbe6](f84bbe6))
* **devcontainer:** stop uv noise lines in agent shells
([#4592](#4592))
([9ba375c](9ba375c))
* **k8s:** delete gateway management bodies from spans
([#4551](#4551))
([b835d3c](b835d3c))
* **k8s:** set the kube context and namespace on devops pods
([#4514](#4514))
([9087b39](9087b39))
* **roadmap:** a refused spec after the archive is a plan defect
([#4549](#4549))
([1db29f7](1db29f7))
* **roadmap:** count and log the reason of a left-out stage item
([#4541](#4541))
([5600179](5600179))
* **roadmap:** default the step ceiling to twice the budget
([#4556](#4556))
([1dfb6c8](1dfb6c8))
* **roadmap:** explain --trace shows the argument digest
([#4526](#4526))
([c92195f](c92195f))
* **roadmap:** explain totals count dropped model events
([#4543](#4543))
([fe0e979](fe0e979))
* **roadmap:** give each eval verify run its own report file
([#4534](#4534))
([ad27f2d](ad27f2d))
* **roadmap:** one event loop and a time limit for decide_all
([#4585](#4585))
([ec51e01](ec51e01))
* **roadmap:** scoped updates send requests with no row scope
([#4531](#4531))
([5f75d25](5f75d25))
* **roadmap:** the caller gate reads an added parameter span
([#4548](#4548))
([1ba07c1](1ba07c1))
* **roadmap:** the implement shell waits for its command
([#4536](#4536))
([571e044](571e044))
* **roadmap:** the module-test and caller gates read imports and calls
([#4490](#4490))
([8a22e82](8a22e82))
* **service:** put trace ids on Service JSON log lines
([#4511](#4511))
([0d7a0d2](0d7a0d2))


### Performance Improvements

* **ai:** keep intake embeddings between CLI runs
([#4546](#4546))
([812871e](812871e))
* **roadmap:** intake reads only the issues that changed
([#4552](#4552))
([7dfd155](7dfd155))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/k8s Kubernetes commands, Helm charts, pods, services, and policies type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(k8s): set the kube context and namespace on devops pods

1 participant