Skip to content

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

Closed

Description

@dan-petty

Problem or Motivation

The owner said on 2026-11-12: "once infra environment repo management is supported, we can move homelab configuration artifacts to that repo and update argocd config". devops-cli now holds two kinds of content under k8s/: the environment of the homelab (Argo CD apps, Helm values, overlays, dashboards, alert rules, Image Updater config) and product content that devops needs or ships. Code, tests and CI read the environment files at fixed paths in this repository (DEFAULT_K8S_DIR, CONST_K8S_ARGOCD_APPLICATION_DIRS, PAUSE_PARENTS, CONST_K8S_GITEA_APPLICATIONS, CONST_K8S_OLLAMA_PROFILES_PATH, the dashboards folder default, the gateway and profile paths, the "homelab" Cloudflare policy names). The files cannot move while the product reads them here.

devops k8s image-pins and argocd_gate also read each Application source from the local root. Today _value_file maps every $ref to the local root (image_pins.py:183-185), and a path source always renders from the local root (image_pins.py:244-245). argocd_gate requires the origin repoURL. tests/support/k8s_tree.py assumes the prefix $values/. In the homelab copy, Application devops names devops-cli, and Application prometheus has a second ref on devops-cli. So these checks cannot check the homelab tree.

Proposed Solution & Architectural Design

Phase 2 of tracker #5120 (design section 10), step 4 of the corrected plan on #5120. This item is one pull request (PR 1), before the source commit S of dan-petty/homelab#23 (plan step 9). The fixture work (the old item 4) is #5298 now. It must merge before #5134 step 6 (plan step 17).

  1. (PR 1) The product commands read the environment tree from the profile fact kubernetes.dir of the infra repo, which the repo declares in .devops/project.toml, or from the option --k8s-dir. infra.repos[] has no k8s_dir key: InfraRepoConfig forbids extra keys (settings.py:1578-1606). The commands are devops k8s deploy-stack, bootstrap, teardown-stack, image-pins, lint, check-deprecated, devops grafana dashboards, devops ai gateway, devops k8s ollama, argocd_gate and the roadmap stage paths. deploy-stack keeps the product root (k8s/devops) apart from the environment root.
  2. (PR 1) Foreign-source support. image-pins and argocd_gate resolve each $ref and each path source by its repoURL. The origin maps to the local root. A public repository that is not the origin is fetched at its targetRevision. tests/support/k8s_tree.py accepts a ref name other than $values. Also add a kustomization-path mode to image-pins (for example k8s/devops).
  3. (PR 1) The environment data in src becomes settings, or comes from the environment root: the constants listed above, DEFAULT_K8S_DIR and the paths that are joined to it at import time (stack_lifecycle.py:120-331), the DEFAULT_LLM_* paths, DEFAULT_GRAFANA_DASHBOARDS_DIR, the path of ollama prune, the argo.py defaults, the team default homelab and the Cloudflare Access names. CONST_K8S_ARGOCD_HOMELAB_APPLICATIONS does not become a setting, because feat(argocd): read the environment from the homelab repo #5134 step 5c (plan step 15) deletes it.
  4. The product-contract tests on a fixture tree are in test(k8s): test the product contracts on a fixture tree #5298.
  5. k8s/devops/* stays as a Kustomize base that devops-cli ships (Service, runner CronJob template, mcp-server, admission policy).
  6. A list in the PR names each reader that stays, moves or is deleted.
    • Stays in devops-cli: test_k8s_crawl4ai.py, test_k8s_searxng.py, third-party-image-scan.yml, the promtool step, trivy config, the Renovate kubernetes manager scoped to ^k8s/devops/, and image-pins.yml scoped to k8s/devops/**. Only the cloudflared and README checks of the two test files change: the cloudflared checks move to homelab, and the README checks follow the product sections to docs/ (docs(k8s): move the product README sections to docs/ #5293), as the README read of test_runner_image.py does.
    • Moves to dan-petty/homelab (feat(k8s): run the environment checks in homelab CI #5296 brings them to homelab CI): test_k8s_argocd_apps.py, the manifest part of test_k8s_manifests.py, the k8s row of devops ci, the environment alert and dashboard tests, the cloudflared checks, and the other k8s managers of .github/renovate.json. sre-service.json and llm-stack.json are environment dashboards.
    • Deleted: the dead design-token filters of ci.yml, together with DESIGN_FILTER in test_workflow_contracts.py:1880-1891 in the same PR; the cross-repo pin tests.
  7. No file moves in this item. The environment files stay until feat(argocd): read the environment from the homelab repo #5134 step 6.

Order and dependencies (corrected plan on #5120):

Target Subsystem

Kubernetes & Minikube Automation

Existing Tool Considered

Kustomize remote bases and the settings system already cover the need; the work is to remove fixed paths. Cost: about 6M tokens to build, 0.5M a quarter to keep, 8 hours. The foreign-source support adds about 2M tokens and 3 hours.

Acceptance Criteria

  • With kubernetes.dir or --k8s-dir pointing at a copy of k8s/ outside this repository, devops k8s image-pins, deploy-stack --dry-run and devops grafana dashboards lint give the same result as today.
  • image-pins and argocd_gate pass on a test tree whose Application devops names devops-cli k8s/devops and whose Application prometheus has two refs.
  • image-pins accepts a kustomization path (k8s/devops).
  • git grep finds no environment constant listed above in src/.
  • The PR lists each kept, moved and deleted reader.
  • uv run devops ci passes.

Dependencies

#5121 (closed: the infra settings and the project profile). This item blocks dan-petty/homelab#23 through release vX. #5298 (the fixture tests) blocks #5134 step 6.

Activity

  1. added
    type/refactor
    source/agent
    scope/k8s
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 12, 2026
  4. added
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 13, 2026
  5. added
    status/in-review
    and removed
    status/in-progress
    on Nov 13, 2026
  6. removed
    status/in-review
    owner/agent
    on Nov 13, 2026
  7. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor
  8. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-13 02:53 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/k8ssource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions