Repository navigation
Description
Problem or Motivation
devops infra drift (#5127) and devops infra plan (#5124) run on a workstation. Nobody runs them on a schedule, and a pull request of an infra repo shows no plan before review. ADR 0021 moves Service work to cluster Jobs and Argo Workflows that an event or a CronWorkflow starts.
Proposed Solution & Architectural Design
Phase 3 of tracker #5120 (design section 8).
- A WorkflowTemplate
infra-driftand a CronWorkflow (daily) in namespacedevopsrundevops infra drift <repo>for each repo ininfra.reposwhose level isplanor higher. The runner image gets the pinned[python.ansible]tool environment. - A step job
infra-planruns on each push to an open pull request of an infra repo (the webhook router creates the unit, ADR 0021) and posts the plan table as one PR comment with a marker, updated on the next push. - The Ansible SSH key reaches the pod as a key of a Secret. The owner writes the Secret (
devops k8s push-secretsfrom the keyring); the pod mounts it read-only and passes it asansible_ssh_private_key_file. - A NetworkPolicy admits egress from these pods on TCP 22 to the node addresses only.
- The pods count as agent callers: the access level of each repo applies.
Target Subsystem
Kubernetes & Minikube Automation
Existing Tool Considered
Argo Workflows (CronWorkflow, WorkflowTemplate) and the webhook router of ADR 0021; ansible-runner transmit | worker | process is available if the run must stream from another pod. Cost: about 4M tokens to build, 0.5M a quarter to keep, 6 hours.
Acceptance Criteria
- Tests: the WorkflowTemplate and the CronWorkflow render, run with the
devops-cli-joblabel, mount the Secret read-only, and pass no other credential. - A test: the NetworkPolicy admits TCP 22 to the configured node addresses and nothing else beyond the existing egress.
- Live: the CronWorkflow runs once on demand for dan-petty/homelab and sets
devops_cli_infra_drift_hosts; a test PR of dan-petty/homelab gets 1 plan comment, and a second push updates it.
Dependencies
#5127; owner: the SSH key Secret.
Alternatives check of 2026-11-19: in-use.
The repository already uses this tool.
Tool: argoproj/argo-workflows (https://github.com/argoproj/argo-workflows), Apache-2.0, last activity 2026-11-19, maintained.
Reason: Search found Argo Workflows, the project's cluster workflow engine, which covers scheduled CronWorkflow runs and templated pod steps but lacks the drift loop, the PR plan comment and the SSH key/egress glue the issue needs.
Covers:
- Daily schedules through a CronWorkflow
- Reusable WorkflowTemplate step definitions
- Kubernetes-native pod execution for cluster jobs
Lacks:
- Drift loop over infra.repos access levels
- Marked plan comment updated on an infra PR
- Keyring-to-Secret mount and TCP 22 egress policy
Proposed design
Problem statement
devops infra drift (#5127) and devops infra plan (#5124) run only on a workstation. No schedule runs drift, and an infra pull request shows no plan before review. This change runs drift from a daily Argo CronWorkflow in namespace devops. It starts one infra-plan Job on each push to an infra pull request. It posts one marked plan comment that the next push edits.
Acceptance criteria
Requirement: Drift covers plan repos
The devops infra drift --all command SHALL run the drift of each repo in infra.repos whose agent access level is plan or higher, and SHALL run no drift for a repo at none.
Scenario: Plan repo drifts and none repo does not
- WHEN
uv run pytest tests/infra/test_infra_drift_all.py -qruns with a settings fixture that holds one repo atplanand one atnone - THEN the command runs the drift once for the
planrepo and no time for thenonerepo
Requirement: Drift CronWorkflow is daily
The infra-drift CronWorkflow SHALL run the infra-drift WorkflowTemplate once a day.
Scenario: Daily CronWorkflow passes the Kubernetes check
- WHEN
uv run devops ci --check --only k8sruns - THEN the command prints
k8s: <N> cases, 0 failed
Requirement: Drift pod is a job pod with the key Secret
The infra-drift pod template SHALL carry the app.kubernetes.io/name: devops-cli-job label, SHALL run the runner image, and SHALL mount the SSH key Secret read-only as its only SSH credential.
Scenario: Rendered drift pod passes the Kubernetes check
- WHEN
uv run devops ci --check --only k8sruns - THEN the command prints
k8s: <N> cases, 0 failed
Requirement: Runner image holds the Ansible runner
The runner image SHALL hold ansible-runner, and RUNNER_TOOLS SHALL name it with a job: reason.
Scenario: Runner tools name the Ansible runner
- WHEN
uv run pytest tests/roadmap/test_roadmap_runner_tools.py -qruns - THEN
ansible-runneris inRUNNER_TOOLSwith ajob:reason
Requirement: Drift egress is SSH to node CIDRs only
The infra-ssh-egress NetworkPolicy SHALL admit TCP 22 egress from the drift and plan pods only to the configured node CIDRs.
Scenario: Rendered policy passes the Kubernetes check
- WHEN
uv run devops ci --check --only k8sruns - THEN the command prints
k8s: <N> cases, 0 failed
Requirement: One plan job per pull request head
A pull_request synchronize delivery for an open infra pull request SHALL create exactly one infra-plan Job for that head.
Scenario: Two deliveries for one head create one Job
- WHEN
uv run pytest tests/server/test_server_infra_plan.py -qruns with twosynchronizedeliveries for the same pull request head - THEN the launcher creates one
infra-planJob with the repository, the pull request number and the head, and the second delivery gets the existing unit
Requirement: Plan comment is one and updates
The infra-plan step SHALL post one plan comment with the marker <!-- devops roadmap infra-plan --> and SHALL edit that comment on the next push.
Scenario: Second run edits the first comment
- WHEN
uv run pytest tests/roadmap/steps/test_roadmap_step_infra_plan.py -qruns the step twice with a fake GitHub client - THEN the first run creates one comment with the marker, and the second run edits that comment and creates no other
Requirement: Access level gates the plan step
The infra-plan step SHALL run only when the agent access level of the infra repo is plan or higher.
Scenario: Repo at none gets no plan
- WHEN
uv run pytest tests/roadmap/steps/test_roadmap_step_infra_plan.py -qruns with an infra repo at levelnone - THEN the step exits 0, posts no plan comment, and records that
infra.repos[].agent_accessrefused the run
Existing Tool Considered
The alternatives check in the issue body gives the verdict in-use for argoproj/argo-workflows (https://github.com/argoproj/argo-workflows). The repository already uses this tool, so no person decides it. The check block holds what the tool covers and what it lacks. The proposal adds the parts that the tool lacks. devops infra drift --all loops over infra.repos and selects each repo at plan or higher. The infra-plan step posts one comment with the marker <!-- devops roadmap infra-plan --> and edits it on the next push. A read-only Secret volume carries the Ansible SSH key, and the infra-ssh-egress NetworkPolicy admits TCP 22 to the node CIDRs only. That glue costs about 4M tokens to build, 0.5M tokens a quarter to keep, and 6 hours.
Key questions
- Should the scheduled drift run use Argo Workflows or a Kubernetes CronJob?: Use an Argo WorkflowTemplate
infra-driftand a daily CronWorkflow in namespacedevops. (best practice) [sources: docs/adr/0008-argo-workflows-run-the-roadmap-jobs-after-a-measured-go.md, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, k8s/devops/workflowtemplate-rag-ingest.yaml, k8s/devops/cronworkflow-rag-ingest.yaml]- Chosen: Argo Workflows. ADR 0008 makes Argo Workflows the engine, and ADR 0021 puts a WorkflowTemplate and a CronWorkflow on each job.
- Rejected: Kubernetes CronJob. It duplicates the Argo scheduling and templating that the project already runs.
- Rejected: GitHub Actions. The SSH key and the node access live in the cluster, not in GitHub Actions.
- Which infra repos get a drift run?: Each repo in
infra.reposatplan,safeorfullgets a drift run. A repo atnonegets none. [sources: SECURITY.md, src/devops_cli/infra/access.py, tests/config/test_infra_repos_setting.py] - How does one CronWorkflow cover every repo in
infra.repos?: The CronWorkflow holds one static step,devops infra drift --all. That command readsinfra.reposand loops over the repos atplanor higher. A static Argo manifest cannot hold a list that the ConfigMap changes. (best practice) [sources: src/devops_cli/config/settings.py:2341, tests/config/test_infra_repos_setting.py, k8s/devops/cronworkflow-rag-ingest.yaml, k8s/devops/kustomization.yaml]- Chosen:
devops infra drift --all. One static step, and the selection reads the same settings as every otherdevops infracommand. - Rejected: One CronWorkflow step per repo, rendered from
infra.repos. No renderer exists for a workflow from settings, and Argo CD syncs the static manifests ofk8s/devops. - Rejected: A shell loop over
devops config get infra.repos. It parses the settings in shell and duplicates the command's own read.
- Chosen:
- Which component creates the
infra-planstep job on a pull request push?: The Service webhook router takes thepull_requestsynchronizedelivery for a repo ininfra.reposand starts oneinfra-planJob from the runner template throughjob_launcher.launch. The sweep is the fallback. The change addspull_requestto the consumer, the typed payload andCONST_ROADMAP_WEBHOOK_EVENTS. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, src/devops_cli/server/routes/webhooks.py, src/devops_cli/models/webhooks.py, src/devops_cli/config/constants.py:4040, src/devops_cli/roadmap/job_launcher.py, docs/CLUSTER.md]- Chosen: The webhook router creates the Job. ADR 0021 makes the router a creator of units, and the Job launcher is the existing seam for a step Job.
- Rejected: The sweep only. It delays the plan by the sweep interval, and the issue names the router as the creator.
- Rejected: GitHub Actions. It needs the cluster credentials and duplicates the unit of work.
- Rejected: A new controller. It duplicates the router that ADR 0021 defines.
- How does the Ansible SSH key reach the pod?: Mount the key as a read-only Secret volume and pass its file path as
ansible_ssh_private_key_file. (best practice) [sources: openspec/specs/infra-plan/spec.md, src/devops_cli/infra/plan.py, k8s/devops/workflowtemplate-rag-ingest.yaml]- Chosen: Read-only Secret volume. Ansible reads a key file, and a volume keeps the key out of the process arguments and the environment.
- Rejected: Environment variable. The key would appear in the process environment, and Ansible still needs a file.
- Rejected: Inline extra variable. The key would appear in the process arguments and the logs.
- How does the step keep one plan comment per pull request?: Post one comment with the stable marker
<!-- devops roadmap infra-plan -->through the existing comment step. The next push finds the marker and edits that comment. The marker holds no head SHA, so a new head edits the same comment. (best practice) [sources: src/devops_cli/roadmap/steps/comment.py, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, docs/CLUSTER.md]- Chosen: Stable marker and edit. It finds the same comment on each push and leaves a person's comment alone.
- Rejected: A marker with the head SHA. A new head would not match the old marker and would create a second comment.
- Rejected: Post a new comment on each push. It adds one comment for each push and hides the current plan.
- Rejected: Edit the last comment. A person's comment can be last, so the step would overwrite it.
- How does the NetworkPolicy name the node addresses?: Name them as
ipBlockCIDRs with a prefix shorter than 32 (the node subnet ranges) in a committed manifest underk8s/devops. Select the drift and plan pods byapp.kubernetes.io/component: infra. A /32 private address cannot be committed, and a policy rendered outside Git would not reach an Argo CD cluster. (best practice) [sources: k8s/devops/networkpolicy.yaml, tests/invariants/test_committed_addresses.py, tests/gate/k8s_checks/network_policies.py, k8s/overlays/homelab/devops/kustomization.yaml]- Chosen:
ipBlocknode CIDRs ink8s/devops. A CIDR range names no machine, so the committed-address invariant allows it, and both deploy-stack and Argo CD apply it. - Rejected: A policy rendered from the infra inventory. It would not be in Git, so Argo CD would not sync it, and the deploy-stack and Argo CD network-policy check would fail.
- Rejected:
0.0.0.0/0except the metadata address. It admits every public address and every private range on TCP 22, not the nodes.
- Chosen:
- Which Ansible tool does the runner image need?:
ansible-runneronansible-core.RUNNER_TOOLSnamesansible-runnerwith ajob:reason. The devtools image gives its version, so the table compares no version. (best practice) [sources: src/devops_cli/roadmap/runner_tools.py:119, tests/roadmap/test_roadmap_runner_tools.py]- Chosen:
ansible-corewithansible-runner. The drift and plan steps runansible-runner, and the core package holds the runner. - Rejected: The community
ansiblepackage. It adds the community collections that the drift and plan steps do not use.
- Chosen:
- Which access level applies to the drift and plan pods?: A cluster Job is an agent caller, so the
agent_accessof the infra repo applies. A repo atnoneis refused before any Ansible process starts. [sources: src/devops_cli/infra/access.py, src/devops_cli/config/settings.py:2445, SECURITY.md] - Who writes the Ansible SSH key Secret that the drift and plan pods mount?: The owner writes the Secret in namespace
devopsfrom the keyring withdevops k8s push-secrets. No agent writes it. The drift and plan pods wait on that Secret. (a person decides)
Open questions
- Who writes the Ansible SSH key Secret that the drift and plan pods mount? (a person decides)
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 12, 2026
Both belong to the same infra tracker; #5120 is the umbrella that defines all phases, while this candidate is Phase 3 that adds cluster scheduling and PR-comment integration.devops-cli-service commentedon Nov 17, 2026
Refine cannot set this item to Ready at c58b592 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
devops-cli-service commentedon Nov 19, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (7)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 24, 2026
Owner question: See the first point of Open questions in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
feat(infra): run drift in the cluster and plan infra PRs (#5129)
devops-cli-service commentedon Nov 24, 2026
Released in v0.209.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.209.0
devops-cli-service commentedon Nov 24, 2026
Live since 2026-11-24 13:45 UTC