Skip to content

feat(k8s): set the homelab domain in container env values #4542

Closed

Description

@dan-petty

Problem or Motivation

The cluster start page (Homepage) needs the homelab domain in two container environment values: HOMEPAGE_VAR_DOMAIN (each link is https://<name>.{{HOMEPAGE_VAR_DOMAIN}}/<path>) and HOMEPAGE_ALLOWED_HOSTS (the host check). Git holds only the placeholder domain example.com (AGENTS.md rule 10).

deploy-stack writes the real hosts as Kustomize patches into the Applications of CONST_K8S_ARGOCD_HOMELAB_APPLICATIONS_BY_STACK. The patch builder _host_fields (src/devops_cli/k8s/argocd_overrides.py:112-137) reads only Ingress rule and TLS hosts, IngressRoute match and the Mattermost host. It does not read a container env[].value. So a value that holds the placeholder stays example.com in the cluster.

Proposed Solution & Architectural Design

  • Extend _host_fields: for a Deployment, also return each container and init container env[].value that holds the placeholder domain (holds_template_domain_value, src/devops_cli/k8s/template.py:69-78).
  • deploy-stack tests and then replaces each such value, as it does for a host.
  • No object in the patched Applications has such a value today (grep: hosts only), so this change gives the same patches as before on main.
  • Add the new row to the table "Homelab Values at Deploy Time" in k8s/README.md.

Target Subsystem

Kubernetes & Minikube Automation (src/devops_cli/k8s/argocd_overrides.py).

Existing Tool Considered

Argo CD and Kustomize have no domain variable for a container environment value; Kustomize replacements copies one field or one segment and does not replace a substring in many values. So the existing patch builder is extended. Cost: about 150,000 tokens and 2 hours to build, about 5,000 tokens a month to keep, about 30,000 tokens to fix.

Acceptance Criteria

  • _host_fields returns each container and init container env[].value of a Deployment that holds the placeholder domain, and no other value.
  • Unit tests in tests/k8s/test_k8s_argocd_overrides.py cover a value with the placeholder and a value without it.
  • A dry run of deploy-stack on main gives the same patches as before.
  • k8s/README.md lists the new row in "Homelab Values at Deploy Time".
  • No real domain or hostname is in the repository.

Dependencies

None.

Source: #4517

Proposed design

Problem statement

deploy-stack writes the real homelab hosts into Argo CD Applications as Kustomize patches. The patch builder _host_fields reads Ingress, IngressRoute and Mattermost hosts, but not a Deployment container or init container env[].value. The Homepage start page therefore keeps the placeholder domain in HOMEPAGE_VAR_DOMAIN and HOMEPAGE_ALLOWED_HOSTS. The change extends the patch builder to test and replace each such env value.

Acceptance criteria

Requirement: Deployment container env value

The function _host_fields SHALL return the JSON pointer and value of each Deployment container env[].value that is a string and for which holds_template_domain_value returns true.

Scenario: Container env value holds the placeholder

  • WHEN A Deployment has a container env value example.com at index 0 and an env value info at index 1.
  • THEN _host_fields returns only /spec/template/spec/containers/0/env/0/value with the value example.com.

Requirement: Deployment init container env value

The function _host_fields SHALL return the JSON pointer and value of each Deployment init container env[].value that is a string and for which holds_template_domain_value returns true.

Scenario: Init container env value holds the placeholder

  • WHEN A Deployment has an init container env value example.com at index 0 and an env value info at index 1.
  • THEN _host_fields returns only /spec/template/spec/initContainers/0/env/0/value with the value example.com.

Requirement: Deployment without a domain value

The function _host_fields SHALL return an empty list for a Deployment with no env value for which holds_template_domain_value returns true.

Scenario: Deployment without a domain value

  • WHEN A Deployment has only the container env value info.
  • THEN _host_fields returns an empty list.

Requirement: Domain replacement inside an env value

The function host_patches SHALL emit a test of the original env value and a replace of each placeholder occurrence with the configured domain for each Deployment env value that _host_fields returns.

Scenario: Allowed host value contains the placeholder

  • WHEN A Deployment has HOMEPAGE_ALLOWED_HOSTS value homepage.example.com and the configured domain is example.org.
  • THEN the patch tests homepage.example.com and replaces it with homepage.example.org at /spec/template/spec/containers/0/env/0/value.

Requirement: No change to current patch list

The patch list for the current rendered Applications SHALL equal the patch list before this change.

Scenario: No matching env value on main

  • WHEN The rendered Applications hold no Deployment env value for which holds_template_domain_value returns true.
  • THEN the test asserts the same patch list as the recorded snapshot from before the change.

Requirement: README homelab values table

The table Homelab Values at Deploy Time in k8s/README.md SHALL list the Deployment env value row.

Scenario: README table names the env value source

  • WHEN A reader opens the table Homelab Values at Deploy Time.
  • THEN the table has a row that names container and init container env[].value entries under the configured domain.

Requirement: No real domain in repository

The change MUST use only the placeholder domains example.com and example.org in its tests and documentation.

Scenario: Test and documentation data

  • WHEN The test and documentation changes add domain examples.
  • THEN each example uses example.com or example.org and no homelab hostname appears.

Existing Tool Considered

Kustomize (open, maintained; src/devops_cli/ai/knowledge_base/it_domains/tools/kustomize.md) and Argo CD have no domain variable for a container environment value. Kustomize replacements copies one field or one delimited segment and cannot replace a substring inside many values, and it cannot emit a test/replace pair for each occurrence. The project therefore extends the existing patch builder (_host_fields/host_patches) at the written cost: about 150,000 tokens and 2 hours to build, about 5,000 tokens a month to keep, and about 30,000 tokens to fix.

Key questions

  • Which Deployment env lists should _host_fields read?: It should read spec.template.spec.containers[].env[].value and spec.template.spec.initContainers[].env[].value. (best practice) [sources: src/devops_cli/k8s/argocd_overrides.py:112-138, tests/support/k8s_tree.py:20-28, tests/gate/k8s_checks/deploy_stack.py:150-162, k8s/devops/roadmap-service/deployment.yaml:52, k8s/devops/roadmap-service/deployment.yaml:78]
    • Chosen: Read containers and init containers. A Deployment pod template has both lists, and the project reads both for container images (tests/gate/k8s_checks/deploy_stack.py:150-162); an init container can hold the same domain value.
    • Rejected: Read containers only. It leaves an init container value on the placeholder.
    • Rejected: Read every env value. It patches values that hold no domain.
  • Which env values should the patch builder return?: It should return only values for which holds_template_domain_value returns true. (best practice) [sources: src/devops_cli/k8s/template.py:69-78, src/devops_cli/config/constants.py:1098-1099]
    • Chosen: Use holds_template_domain_value. It keeps one definition of a domain value and covers the placeholder and template variables.
    • Rejected: Match the literal example.com only. It duplicates the predicate and misses a template domain variable.
    • Rejected: Return all env values. It changes values that hold no domain.
  • What should _host_fields return for a Deployment with no matching env value?: It should return an empty list, so callers can iterate the result without a None check. (best practice) [sources: src/devops_cli/k8s/argocd_overrides.py:138, src/devops_cli/k8s/argocd_gate.py:169]
    • Chosen: Return an empty list. The caller can iterate each Deployment result with no special case.
    • Rejected: Return None. The caller must add a None check for a normal Deployment.
    • Rejected: Return the Deployment with no pointers. The result shape differs from every other object.
  • How should the patch change a placeholder inside a longer env value?: It should test the original value and replace each placeholder occurrence with the configured domain. (best practice) [sources: tests/k8s/test_k8s_argocd_overrides.py:81-103]
    • Chosen: Replace each occurrence inside the value. A host list can hold the placeholder inside a longer string.
    • Rejected: Replace the whole value with the domain. It destroys prefixes and lists.
    • Rejected: Replace only a value equal to the placeholder. It leaves an allowed host on the placeholder.
  • Which tool should replace the placeholder domain in a Deployment env value?: Extend the existing _host_fields and host_patches builder. Kustomize and Argo CD are open, maintained tools, but Kustomize replacements copies a field or a delimited segment and cannot replace a substring inside many values, and Argo CD has no domain variable. ADR 0011 records that _host_fields is the single source shared with the gate, so a separate tool or a Rego copy would duplicate it. (best practice) [sources: docs/adr/0011-releases-come-from-trunk-towncrier-uv-and-semver-tags-instead-of-a-bespoke-cut.md:71, src/devops_cli/ai/knowledge_base/it_domains/tools/kustomize.md:14-27, src/devops_cli/k8s/argocd_overrides.py:151-176]
    • Chosen: Extend _host_fields and host_patches. ADR 0011 keeps _host_fields as the single source shared with the gate, and the builder already emits a test and a replace for each value.
    • Rejected: Kustomize replacements. It copies one field or one delimited segment and cannot replace a substring inside many values.
    • Rejected: Argo CD domain variable. Argo CD has no variable for a container environment value.
    • Rejected: A separate YAML processor such as yq. It would rewrite the rendered manifest and leave the Application's Kustomize patch mechanism, duplicating the builder.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

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

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. It enables the Homepage service domain but no live object uses the placeholder today, so it is not urgent.
    • Value: Medium. It unblocks a real service (Homepage) from using the correct domain in container env values.
    • Effort: Medium. Extends one function, adds unit tests, and updates one README table; about 2 hours of work per the candidate.
    • Related: fix(k8s): argo cd takes homelab values from deploy-time overrides, and the repository holds no private or placeholder config #1290, which asks for a different change. Both work on the deploy-time override mechanism in argocd_overrides.py, but #1290 established the patch system and the candidate extends it to cover container env[].value fields.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. added
    status/ready
    and removed
    status/new
    on Nov 11, 2026
  6. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 5f75d25 (see proposed design in issue body).

  7. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 11, 2026
  8. removed
    status/in-progress
    owner/agent
    on Nov 11, 2026
  9. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor
  10. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-11 14:13 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/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions