Skip to content

refactor(k8s): read the environment tree from the infra repo - #5334

Merged
dan-petty merged 9 commits into
mainfrom
refactor/5131-environment-root-from-the-infra-repo
Nov 13, 2026
Merged

dan-petty merged 9 commits into
mainfrom
refactor/5131-environment-root-from-the-infra-repo

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

devops reads the environment tree from --k8s-dir or the profile fact kubernetes.dir, not from fixed paths, so the homelab tree can move to its infra repo (#5120). deploy-stack reads the product base k8s/devops apart (--product-dir). image-pins and the Argo CD gate fetch a source of another public repo at its revision. image-pins also renders one kustomization folder; --managed names repos the deploy tags. The names of live objects are settings.

Readers of k8s/:

Closes #5131

Change: openspec/changes/archive/2026-11-13-5131-environment-root-from-the-infra-repo/

@dan-petty dan-petty added type/refactor Type refactor: a new structure, same behavior scope/k8s Kubernetes commands, Helm charts, pods, services, and policies labels Nov 13, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Checks and evidence (review and publish)

Branch rebased on origin/main 6d11eb0 before the push.

Local checks

  • uv run devops ci --check --only lint,format,actionlint,zizmor,docs: pass.
  • uv run mypy --python-version 3.14 --strict src: pass (841 source files).
  • uv run devops docs generate --check and uv run devops openspec check: pass.
  • uv run pytest tests/k8s tests/commands tests/grafana tests/invariants tests/gate tests/argo tests/cloudflare tests/docs tests/ai/mcp tests/ai/client tests/security tests/config tests/dry_run tests/lang tests/project tests/infra tests/prometheus tests/design tests/ai/test_ai_gateway_render.py tests/ai/benchmark/test_k8s_llm_gateway.py -n 8: 9014 passed.
  • uv run devops k8s image-pins (full mode, real tree, real registries): exit 0, 40 images resolve.
  • uv run devops k8s image-pins k8s/devops --managed ghcr.io/dan-petty/devops-cli/service --managed ghcr.io/dan-petty/devops-cli/runner --managed ghcr.io/dan-petty/devops-cli/mcp-server: exit 0, 2 images resolve (searxng, crawl4ai).
  • tests/core/test_git_contract.py::...[review_window] fails on origin/main without this change too (fix(roadmap): the review_window git transcript does not match the code #4865 tracks it). Not run here.

Render diff (Argo CD)
The only file under k8s/ that this PR changes is k8s/README.md, and no kustomization lists it. kubectl kustomize of git archive origin/main and of the branch gives byte-identical output for k8s (11078 bytes), k8s/devops (38941), k8s/monitoring (1094763), k8s/overlays/homelab/ingress (10920) and k8s/overlays/homelab/devops (38941). Argo CD syncs nothing new at the merge.

Review fixes on top of the builder commits

  1. devops k8s image-pins k8s/devops exited 1 on the real product base: the base names the service, runner and mcp-server images with no tag, because ImageUpdater devops of the environment sets their digests, and a folder holds no ImageUpdater object. The builder ran only --dry-run, which renders nothing. New option --managed <repository>, test first (red: exit 2 for the unknown option, then green). The plan scopes image-pins.yml to k8s/devops/** in the folder mode (feat(argocd): read the environment from the homelab repo #5134 step 6), so that step must pass the three repositories.
  2. docs/ERRORS.md cut the summary of ApplicationSourceError in the middle of a sentence. The docstring has a one-line summary now.
  3. docs/SDLC.md still named k8s/startpage/ in the filter of the Design Tokens job, which this PR deletes.
  4. The README and app_sources.py said that the fetch of another repository has no credential. A git child gets the session token, and the git configuration of the host can give a credential, so the text now says that the fetch adds no credential of its own (fix(k8s): deploy-stack fetches a private Application repo #5294 owns the private case).

Choices for the person who merges

  • With no folder, devops grafana dashboards sync and lint read monitoring/dashboards of the tree, then dashboards of the product base only when the current repository holds it.
  • With no target, devops k8s lint and check-deprecated scan the environment tree, not ..
  • The roadmap stage paths stay, as the final plan of feat(infra): manage infra repos with devops infra #5120 says (the issue body listed them in item 1).
  • The defaults of the new settings are the live names, so no live object changes.
  • The product-contract tests on a fixture tree are test(k8s): test the product contracts on a fixture tree #5298.

@dan-petty
dan-petty force-pushed the refactor/5131-environment-root-from-the-infra-repo branch from 81fcb79 to dc8dfc9 Compare November 13, 2026 02:11
@dan-petty

Copy link
Copy Markdown
Owner Author

Fix after the first CI run

Static Analysis failed on the k8s and test-tree rows of devops ci. The builder did not run these two rows, and the review did not run them before the first push.

  • k8s: three gate checks read the paths of MANIFESTS_BY_STACK under the repository root (FileNotFoundError: ... /argocd/networkpolicy.yaml), or compared the relative path k8s/llm/gateway with the absolute path of the dry run. They read the paths under the tree now, and the product paths of PRODUCT_MANIFESTS_BY_STACK and PRODUCT_POST_HELM_BY_STACK under k8s/devops, through a new helper deploy_stack_manifests of tests/support/k8s_tree.py. So the checks cover the same files as before.
  • test-tree: tests/k8s/test_environment.py:116 found the root from its own file (it reads REPO_ROOT now), and src/devops_cli/commands/ai_gateway.py:827 held a cached local function that the test floor does not reset (the render resolves the tree once, with no cache).

Local proof: uv run devops ci --check --only k8s,test-tree passes (110 and 16 cases). mypy and the tests of the changed files pass.

The commands that read the environment tree take its root from --k8s-dir,
else from the profile fact kubernetes.dir of the current repository, else
from the one infra repo that gives it. deploy-stack reads the product base
apart from the tree (--product-dir). image-pins and the Argo CD gate fetch
a git source of another public repository at its revision, and image-pins
renders one kustomization folder. The names of live objects are settings.

Refs #5131
k8s/README.md, CONTEXT.md and docs/SDLC.md say where a command takes the
environment tree and the product base from, and config.example.yaml shows
the new settings with the names of the live objects.

Refs #5131
The prometheus release of #5292 reads its product values file from the
product base of the current repository.

Refs #5131
An infra repo holds no product base, so devops grafana dashboards lint
with no path reads the dashboards of the environment tree alone. The plan
names the product values and the dashboard folders of #5292.

Refs #5131
…sets

A render of k8s/devops alone names the service, runner and mcp-server
images with no tag, because Image Updater of the environment sets them.
A folder holds no ImageUpdater object, so image-pins k8s/devops exited 1.
The option --managed names such a repository: the check does not refuse
or resolve its images. The README also says that the fetch adds no
credential of its own.
… credential

The first docstring line of ApplicationSourceError was cut in docs/ERRORS.md.
docs/SDLC.md still named k8s/startpage/ in the filter of the Design Tokens
job. The fetch of another repository adds no credential of its own, but the
git configuration of the host can give one.
…e rows

The k8s row of devops ci read the paths of MANIFESTS_BY_STACK under the
repository root, but they are relative to the environment tree now, and the
product paths are in PRODUCT_MANIFESTS_BY_STACK. The test-tree row refused a
test that found the root from its own file, and a cached local function of
gateway render that the test floor does not reset.
#5331 gave render_at_revision the GitHub credential of the session (#5294)
while this branch was open. The fetch of image-pins and the gate still adds
no credential of its own.
@dan-petty
dan-petty force-pushed the refactor/5131-environment-root-from-the-infra-repo branch from dc8dfc9 to 7663474 Compare November 13, 2026 02:28
@dan-petty

Copy link
Copy Markdown
Owner Author

Rebase on origin/main c0d3afd

The PR conflicted with #5312, which moved the sections Image Pins and Service Image Updates from k8s/README.md to docs/CLUSTER.md. I kept the README of main and put the Image Pins text of this PR (environment tree, $<ref> sources, fetch of another public repository, folder mode and --managed) into docs/CLUSTER.md. #5331 closed #5294 in the same period, so the text and the archived change now say that render_at_revision has the session credential, and that the fetch of image-pins and the gate adds no credential of its own.

After the rebase: uv run devops ci --check --only lint,format,actionlint,zizmor,docs,k8s,test-tree pass, mypy pass, docs generate --check and openspec check pass, and 8561 covering tests pass. kubectl kustomize of origin/main and of the branch is still byte-identical for k8s, k8s/devops (39143 bytes after #5324), k8s/monitoring, k8s/overlays/homelab/ingress and k8s/overlays/homelab/devops.

@dan-petty
dan-petty marked this pull request as ready for review November 13, 2026 02:35
@dan-petty
dan-petty merged commit c33d78c into main Nov 13, 2026
25 checks passed
@dan-petty
dan-petty deleted the refactor/5131-environment-root-from-the-infra-repo branch November 13, 2026 02:37
dan-petty pushed a commit that referenced this pull request Nov 13, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.125.4](v0.125.3...v0.125.4)
(2026-11-13)


### Bug Fixes

* **k8s:** find the source of the hawk host crashes
([#5336](#5336))
([e6c5216](e6c5216))


### Code Refactoring

* **k8s:** read the environment tree from the infra repo
([#5334](#5334))
([c33d78c](c33d78c))

---
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/refactor Type refactor: a new structure, same behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(k8s): read the environment tree from the infra repo

1 participant