Skip to content

feat(k8s): add the CI gate WorkflowTemplate #4691

Open

Description

@dan-petty

Update 2026-11-26 (infra move): the Argo CD project is now in dan-petty/homelab.

  • The orphan glob of step 5 is a follow-up issue there (k8s/argocd/apps/projects.yaml).
  • The template, the limits, the NetworkPolicy and the test stay here in k8s/devops/.
  • Argo Workflows and Gitea values are also in homelab.

Follow-up: dan-petty/homelab#273.


Problem or Motivation

In the census week (2026-11-04 to 2026-11-11), 630 of 1,211 pull request CI runs ran on heads that were not final. One GitHub round takes a median of 4.6 min in the queue (p90 27.3 min) and 25.5 min of wall clock (p90 53.1 min). No place in the cluster runs the full checks of a change before a push.

The owner decided on 2026-11-11 that the iteration lane runs on the Argo cluster gate, with no Gitea for now (OD1 a). The gates run on the large node <build-node>, with a semaphore of 2 and 16 CPUs (OD2).

Proposed Solution & Architectural Design

  1. Spike first: run the gate on 20 recent heads.
  2. Add the WorkflowTemplate devops-ci-gate under k8s/devops/. After fix(k8s): the Argo controller manages namespace devops for rag-ingest #5289 and feat(k8s): let Argo Workflows run roadmap pods in devops #4566, the controller watches only devops, so a gate in argo-workflows does not run:
    • The runner image by digest.
    • No token and no Secret in the main container, and the restricted security profile.
    • 16 CPUs (request = limit) and PYTEST_XDIST_AUTO_NUM_WORKERS=16.
    • The gate runs the full devops ci --check on the squash-merge tree, in a fresh offline venv from the image wheels of perf(k8s): put the dependencies in their own image layers #4550.
    • A run deadline of 1,200 s inside a Workflow deadline of 2,400 s, and a TTL of 1 day.
  3. Add the ConfigMap ci-gate-limits with the semaphore gate: 2.
  4. Take the gate pods out of the podSelector of devops-default-perimeter (the NotIn list, as for crawl4ai and renovate). A NetworkPolicy can only add allowed traffic, so the gate pods cannot stay in the perimeter and refuse some of its ports. Add a NetworkPolicy of their own that allows DNS, public TCP 443 outside the private ranges, and the API server on TCP 6443. uv audit needs OSV.
  5. Add the gate Workflows to the Argo CD orphan glob (follow-up issue in dan-petty/homelab).
  6. Add a structural test of the timeout chain: test < row < run deadline < Workflow deadline. The client queue limit (900 s) and the run deadline fit inside the Workflow deadline.
  7. Add an ADR: the gate is a tool run before a push, not a roadmap unit. It amends ADR 0014.

A transport seam keeps the bundle input replaceable by a Gitea branch later.

Target Subsystem

Kubernetes & Minikube Automation (k8s/devops/, the runner image).

Existing Tool Considered

Argo Workflows (installed) covers the need: WorkflowTemplate, a ConfigMap semaphore, activeDeadlineSeconds and ttlStrategy. Kubernetes NetworkPolicy covers the egress. ArgoCRDService.submit_workflow and await_workflow exist. Rejected: Gitea Actions with the Gitea runner (the gitea-forge spec keeps Actions off, and the runner had 30 releases and 4 major versions in 4 months). Cost (estimate): about 300,000 tokens and 5 hours to build with the spike, about 10,000 tokens a month to keep, about 40,000 tokens to fix.

Acceptance Criteria

  • Spike: p90 wall clock at most 12 min on 16 CPUs.
  • Spike: at least 19 of 20 heads agree with the GitHub required result.
  • Argo CD syncs the template, the ConfigMap and the NetworkPolicy.
  • The timeout-chain test passes, and it fails on a broken chain.
  • A gate pod has no service account token and no Secret.
  • A test proves that a gate pod cannot reach the gateway on TCP 4000 or Valkey on TCP 6379.

Dependencies

Source: #4667

Alternatives check of 2026-11-26: 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-26, maintained.
Reason: Searches found Argo Workflows is a Kubernetes-native workflow engine with WorkflowTemplate, ConfigMap semaphores, deadlines and TTL, covering the whole gate need; the issue already names it as installed and in use.

Covers:

  • WorkflowTemplate with parameterized bundle input
  • ConfigMap semaphore limits concurrency to two
  • activeDeadlineSeconds and ttlStrategy on the Workflow
  • Pod spec with digest image and restricted profile
  • Submit and await through ArgoCRDService

Lacks:

  • NetworkPolicy egress is Kubernetes, not Argo
  • No offline uv environment or wheel handling
  • No structural timeout-chain test
  • No Argo CD orphan glob for gate Workflows

Proposed design

Problem statement

Pull request CI runs often start on heads that are not final, and no cluster job runs the full checks before a push. The change adds the Argo Workflows gate devops-ci-gate under k8s/devops/, the ConfigMap ci-gate-limits, the gate NetworkPolicy, the structural timeout-chain check and the ADR. The gate uses the large node <build-node>, semaphore 2 and 16 CPUs. It runs the full devops ci --check on the squash-merge tree with no service account token and no Secret. The 20-head spike is a separate issue, and the Argo CD orphan glob is follow-up dan-petty/homelab#273.

Acceptance criteria

Requirement: Gate WorkflowTemplate is added

The change SHALL add WorkflowTemplate devops-ci-gate under k8s/devops/.

Scenario: The k8s row accepts the gate WorkflowTemplate

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes and the rendered k8s/devops/ kustomization contains WorkflowTemplate devops-ci-gate.

Requirement: Runner image is pinned

The gate main container MUST use the runner image by digest.

Scenario: Runner image has a digest

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes and the gate WorkflowTemplate main container image reference contains @sha256:.

Requirement: Gate pod has no credentials

The gate pod MUST run with no service account token and no Secret reference in the main container.

Scenario: Gate pod spec has no credentials

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes and the gate pod spec sets automountServiceAccountToken to false and has no Secret reference in the main container.

Requirement: Gate pod is restricted

The gate pod MUST use the restricted Pod Security profile.

Scenario: Gate pod security context is restricted

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes and the gate pod spec sets runAsNonRoot to true, allowPrivilegeEscalation to false, drops all capabilities and sets seccompProfile to RuntimeDefault.

Requirement: Gate CPU and worker count

The gate main container SHALL request and limit 16 CPUs and set PYTEST_XDIST_AUTO_NUM_WORKERS to 16.

Scenario: Gate resources match 16 CPUs

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes with a CPU request and limit of 16 and PYTEST_XDIST_AUTO_NUM_WORKERS set to 16.

Requirement: Gate check scope

The gate SHALL run the full devops ci --check on the squash-merge tree.

Scenario: Gate runs the full check

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes and the gate main container command runs devops ci --check with no --skip and no --only.

Requirement: Gate uses the uv cache

The gate MUST get its offline Python environment from the uv cache in the runner image (#4814).

Scenario: Gate copies the uv cache

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes and the gate main container copies the runner image uv cache into the pod cache and runs uv sync --locked --offline.

Requirement: Gate semaphore is two

The change SHALL add ConfigMap ci-gate-limits with semaphore gate: 2.

Scenario: Gate semaphore is two

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes and ci-gate-limits has data.gate set to 2.

Requirement: Gate pods leave the default perimeter

The change SHALL exclude the gate pods from the pod selector of NetworkPolicy devops-default-perimeter.

Scenario: Gate pods are outside the default perimeter

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes and the podSelector of devops-default-perimeter has a NotIn match for the gate pod label.

Requirement: Gate egress policy

The gate NetworkPolicy SHALL allow DNS, public TCP 443 outside the private ranges, and the API server on TCP 6443.

Scenario: Gate egress allows DNS, public 443 and the API server

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes and the NetworkPolicy egress allows DNS to kube-system, TCP 443 to 0.0.0.0/0 with 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8 and 169.254.0.0/16 in except, and TCP 6443 to the API server, and no other egress.

Requirement: Gate egress denies private services

The gate NetworkPolicy SHALL deny a gate pod access to the gateway on TCP 4000 and to Valkey on TCP 6379.

Scenario: Gate pod cannot reach private services

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes and the gate NetworkPolicy allows no egress to TCP 4000 or TCP 6379 in the private ranges.

Requirement: Gate deadline and TTL

The gate Workflow SHALL set a run deadline of 1,200 s inside a Workflow deadline of 2,400 s and a TTL of 1 day.

Scenario: Gate deadlines and TTL are set

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes with a run deadline of 1,200 s, a Workflow deadline of 2,400 s and a ttlStrategy that removes the Workflow after 86,400 s.

Requirement: Timeout chain check

The change SHALL add a structural check that holds test < row < run deadline < Workflow deadline, with the client queue limit of 900 s and the run deadline inside the Workflow deadline.

Scenario: Broken timeout chain fails

  • WHEN uv run devops ci --check --only k8s runs with a fixture that sets the Workflow deadline below the run deadline.
  • THEN The check fails with a message that names the broken timeout chain.

Requirement: Gate bundle input is replaceable

The gate WorkflowTemplate MUST take the bundle input as a Workflow parameter or artifact.

Scenario: Gate bundle input is a parameter

  • WHEN uv run devops ci --check --only k8s runs.
  • THEN The check passes and the WorkflowTemplate takes the bundle input from a Workflow parameter or artifact.

Requirement: Gate ADR

The change SHALL add an ADR that records the gate as a pre-push tool, not a roadmap unit, and amends ADR 0043.

Scenario: ADR records the gate decision

  • WHEN uv run devops ci --check --only docs runs.
  • THEN The check passes and the ADR has status: accepted, names the gate as a pre-push tool, and records that it amends ADR 0043.

Requirement: Pending a person after the merge

After the merge, a person SHALL confirm that the Argo CD Application devops is Synced.

Scenario: Argo CD syncs the gate manifests

  • WHEN kubectl get application devops -A -o jsonpath='{.items[0].status.sync.status}' runs after the merge.
  • THEN The command prints Synced.

Existing Tool Considered

Use Argo Workflows (argoproj/argo-workflows); the alternatives check in the issue body gives verdict in-use, and the repository already uses the tool. The check records what the tool covers and lacks. The proposal adds the Kubernetes NetworkPolicy egress, the uv-cache offline environment from #4814, and the structural timeout-chain check in the k8s row. The Argo CD orphan glob is follow-up dan-petty/homelab#273. The ADR records the gate decision and amends ADR 0043.

Key questions

  • Which lane runs the iteration gate?: Use the Argo cluster gate for the iteration lane, with no Gitea for now. The issue records owner decision OD1 a. (best practice) [sources: docs/adr/0008-argo-workflows-run-the-roadmap-jobs-after-a-measured-go.md]
    • Chosen: Argo cluster gate. Argo Workflows is installed and ADR 0008 records it as the engine; the issue records OD1 a.
    • Rejected: Gitea Actions with the Gitea runner. The owner decision OD1 a keeps Gitea off for now, and the runner changed often.
  • Which node, concurrency and CPU does the gate use?: Use the large node <build-node>, semaphore 2 and 16 CPUs. The issue records owner decision OD2. (best practice) [sources: k8s/devops/cronjob-runner.yaml, docs/CLUSTER.md]
    • Chosen: Large node, semaphore 2, 16 CPUs. The issue records OD2, and the runner template ties the worker count to the CPU limit.
    • Rejected: Default runner size of 2 CPUs. 2 CPUs cannot meet the 12 min p90 target.
  • How does the gate get an offline Python environment?: Copy the uv cache from the runner image (perf(k8s): seed the uv cache of a runner pod from the image #4814) into the pod cache, then run uv sync --locked --offline. (best practice) [sources: openspec/changes/archive/2026-11-11-4550-put-the-dependencies-in-their-own/design.md, openspec/changes/archive/2026-11-11-4550-put-the-dependencies-in-their-own/proposal.md, k8s/devops/cronjob-runner.yaml]
  • What timeout chain does the gate use?: Use a test bound of 600 s, a row bound of 900 s, a client queue limit of 900 s, a run deadline of 1,200 s, a Workflow deadline of 2,400 s and a TTL of 1 day. (best practice) [sources: pyproject.toml, docs/TESTING.md, src/devops_cli/argo/crd.py, src/devops_cli/config/defaults.py, src/devops_cli/config/constants.py, docs/guidelines/kubernetes.md]
    • Chosen: 600 s test, 900 s row, 900 s client queue, 1,200 s run, 2,400 s Workflow, 1-day TTL. The chain holds 600 < 900 < 1,200 < 2,400, and the client queue limit stays below the run deadline.
    • Rejected: One 2,400 s deadline only. It cannot fail the run before the Workflow ends and leaves no bound inside the Workflow.
  • What egress does the gate NetworkPolicy allow?: Allow DNS, public TCP 443 outside the private ranges, and the API server on TCP 6443. Add no other egress. (best practice) [sources: k8s/devops/networkpolicy.yaml, tests/gate/k8s_checks/network_policies.py]
    • Chosen: DNS, public 443 with private ranges excepted, and API server 6443. The gate needs DNS, OSV and the API server, and it must not reach private services.
    • Rejected: Allow all egress. It is broader than the gate needs and lets a gate pod reach the private network.
  • Which rows of devops ci --check can the gate run?: Run the full devops ci --check. The k8s row runs offline checks of the manifests and needs no service account token. (best practice) [sources: docs/TESTING.md, src/devops_cli/commands/ci.py, tests/gate/k8s_checks/network_policies.py]
    • Chosen: Run the full devops ci --check. The issue requires the full check, and the k8s row is offline static checks.
    • Rejected: Skip the k8s row. The k8s row runs offline checks of the manifests, so the gate can run it without a token.
    • Rejected: Add a service account token to run k8s. The issue requires no service account token in the gate pod.
  • How does the gate keep its bundle input replaceable by Gitea?: Use a Workflow parameter or artifact for the bundle input. Do not hard-code a Gitea branch. (best practice) [sources: src/devops_cli/argo/crd.py]
    • Chosen: Workflow parameter or artifact. Argo Workflows passes spec.arguments.parameters to the template, so the input changes without a template rewrite.
    • Rejected: Hard-coded Gitea branch. It couples the gate to Gitea now.
  • Which ADR does the gate decision amend?: Add an ADR under docs/adr/ that records the gate as a pre-push tool, not a roadmap unit, and amends ADR 0043. ADR 0014 is superseded by ADR 0043, so it is not the current decision record. (best practice) [sources: docs/adr/0014-required-checks-gate-the-merge-and-the-pre-push-hook-runs-the-fast-static-checks.md]
    • Chosen: New ADR that amends 0043. ADR 0014 has status: superseded and superseded-by 0043, so 0043 is the decision in force.
    • Rejected: New ADR that amends 0014. ADR 0014 is superseded by ADR 0043.
    • Rejected: No ADR. It leaves the gate status and the amendment unrecorded.
  • Does this repository hold the Argo CD orphan glob for gate Workflows?: No. The Argo CD project is in dan-petty/homelab, and the orphan glob is follow-up dan-petty/homelab#273. [sources: docs/CLUSTER.md, docs/adr/0008-argo-workflows-run-the-roadmap-jobs-after-a-measured-go.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4814, #4566

Moved to new items

#8009

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/k8s
    status/new
    value/high
    effort/high
    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. The owner made a decision and the problem wastes over half of CI runs, but it is a planned feature with a dependency on #4550.
    • Value: High. It stops 630 of 1,211 wasted CI runs and cuts median queue time from 4.6 minutes.
    • Effort: High. The body lists a spike, template, ConfigMap, NetworkPolicy, Argo CD glob, timeout test, and ADR, estimated at about 5 hours.
    • Related: feat(k8s): let Argo Workflows run roadmap pods in devops #4566, which asks for a different change. Both use Argo Workflows in k8s/argo-workflows/, but #4566 fixes roadmap pod scheduling while the candidate adds a new CI gate template.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    The "fresh offline venv from the image wheels of #4550" cannot come from a wheel directory: uv sync --locked --offline does not read UV_FIND_LINKS for a locked package (evidence in #4550). #4814 now holds that need: a uv cache in the runner image that the pod copies into its writable cache (measured: copy 9 s, offline sync 2 s).

  6. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches turned up no other open tool for running a full pre-push CI gate in the cluster, and the issue itself already names Argo Workflows (installed) as the tool that covers the need. The repository facts confirm it is open, Apache-2.0 and maintained, and its WorkflowTemplate, semaphore synchronization, activeDeadlineSeconds and ttlStrategy are exactly the primitives the gate design asks for; only project-specific glue (runner image, wheel/uv cache from #4814, NetworkPolicy, Argo CD glob, timeout-chain test) is left to build.

    The repository already uses this tool.

    Tool: argoproj/argo-workflows (https://github.com/argoproj/argo-workflows)

    • License: Apache-2.0
    • Last activity: 2026-11-14
    • Maintained: yes

    Covers:

    • WorkflowTemplate for a reusable gate definition synced by Argo CD
    • Synchronization semaphore (gate: 2) read from a ConfigMap to limit concurrent gate runs
    • Workflow- and template-level deadlines (activeDeadlineSeconds) plus ttlStrategy for the 1-day TTL
    • Workflow submission and waiting through the existing ArgoCRDService.submit_workflow and await_workflow
    • Pod-level podSpec (image by digest, no token/Secret, restricted security profile, 16 CPUs request=limit) inside the template

    Lacks:

    Tools considered:

    Searches run:

    • Argo Workflows CI gate run full checks before push Kubernetes, results: 5
    • Argo Workflows WorkflowTemplate activeDeadlineSeconds ttlStrategy semaphore ConfigMap, results: 5
    • argoproj argo-workflows documentation synchronization semaphore, results: 5
    • argo worklfows NetworkPolicy egress kubernetes workflow pod, results: 5
    • argo-workflows.readthedocs.io synchronization semaphore workflow template, results: 5
    • "argo" workflows semaphore "synchronization" docs example yaml gate concurrency limit, results: 5
    • argoproj/argo-workflows GitHub Kubernetes-native workflow engine CNCF, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  7. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 46c62f3 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.

  8. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  9. added
    status/ready
    and removed
    status/new
    on Dec 1, 2026
  10. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

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/highpriority/p2-mediumscope/k8ssource/agentstatus/readytype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions