Repository navigation
Description
Problem
The runner Job template loads the whole devops-cli Secret into the container environment with envFrom (k8s/devops/cronjob-runner.yaml:61-63). That gives every implement and fix-checks pod the GitHub App private key, the gateway key and every other key of the Secret (for example the Valkey, MCP, Mattermost and Qdrant tokens), although a Job needs only some of them. The stage Job already names single keys with secretKeyRef (k8s/devops/cronjob-stage.yaml:103-110).
The next experiment gives the Job agents a real shell (owner, 2026-11-20). Each key in the pod environment is then one command away from the agent, so a Job must hold only the keys it needs.
Change
cronjob-runner.yaml: replaceenvFrom: secretRef devops-cliwith onesecretKeyReffor each key that the implement and fix-checks Jobs read. Find the readers in src (settings of the runner path) and name each key and its reader in the PR.- Keep the keys that the Job needs; drop the rest. No new Secret and no new key name in this item, so nothing must be pushed to the cluster before the merge.
- Follow-ups, not in this item: a per-Job gateway key with a spend limit (needs a key the owner creates), and the split of the agent container from the step that holds the App key (feat(roadmap): run the implement agent shell in a real sandbox #2695).
Proof
kubectl kustomizeof the tree renders the runner Job with only the named keys.- An implement Job and a fix-checks Job run green on the cluster after the merge (Argo CD sync), with the result lines as evidence.
Proposed design
Problem statement
Each implement and fix-checks pod gets every key of Secret devops-cli through envFrom (k8s/devops/cronjob-runner.yaml:61-63). The pod then holds the App private key, the gateway key and tokens that it does not read. The change gives the runner Job only the keys that it reads, each with secretKeyRef, as k8s/devops/cronjob-stage.yaml:103-110 does. The same pull request changes policy roadmap-service-jobs, which refuses a runner Job with valueFrom in env. It updates docs/CLUSTER.md lines 5, 69 and 71.
Acceptance criteria
Requirement: Runner Job names each Secret key
The runner CronJob SHALL give each Secret key of Secret devops-cli to the container with secretKeyRef, each in the variable of the key name, and SHALL NOT use envFrom.
Scenario: The rendered runner Job holds no envFrom
- WHEN
uv run devops ci --check --only k8sruns the gate check of the runner Job onk8s/devops/cronjob-runner.yaml - THEN the check passes, and the rendered runner Job has no
envFromand onesecretKeyRefentry for each key of the runner key constant
Requirement: One constant holds the runner keys
The runner Secret keys SHALL come from one constant in the code, as the stage Job keys do, so that the manifest and the policy read one list.
Scenario: A key outside the constant fails the check
- WHEN the rendered runner Job names a
secretKeyRefkey that the runner key constant does not hold - THEN the gate check of the runner Job reports the key, and
uv run devops ci --check --only k8sfails
Requirement: The policy admits only the runner keys
Policy roadmap-service-jobs SHALL admit a runner Job that names only the runner keys in secretKeyRef and SHALL refuse a runner Job with envFrom or with another key.
Scenario: The policy refuses an extra key
- WHEN
uv run devops ci --check --only k8srunstests/gate/k8s_checks/job_admission_policy.pyagainst the Job that CronJobdevops-cli-runnermakes - THEN the policy admits the Job, and refuses a copy with
envFromor with a key outside the runner key constant
Requirement: Each runner key is in the Secret generator table
Each key that the runner Job names SHALL be a key that devops k8s push-secrets writes to Secret devops-cli.
Scenario: A key outside the generator table fails the check
- WHEN
uv run devops ci --check --only k8sruns the key-reference check oftests/k8s/test_cluster_secret_key_refs.py - THEN the check passes, and it fails when the runner Job names a key that the generator table of
src/devops_cli/k8s/cluster_secrets.pydoes not hold
Requirement: An implement Job and a fix-checks Job run green
An implement Job and a fix-checks Job MUST run green after Argo CD syncs the changed manifests.
Scenario: The next runner Jobs of each kind finish
- WHEN the next implement Job and the next fix-checks Job run on the cluster after the merge and the Argo CD sync
- THEN each Job ends green with its result line, and no pod stops at
CreateContainerConfigErroror at a policy refusal
Existing Tool Considered
No alternatives check has run. Kubernetes covers the need with secretKeyRef, and the open, maintained kubectl kustomize renders the Job. The project builds no code: the change edits k8s/devops/cronjob-runner.yaml, the policy and one constant. uv run devops ci --check --only k8s proves the manifest and the policy, and the API server enforces the policy.
Key questions
- Which keys of Secret
devops-clidoes a runner Job read?:DEVOPS_CLI_SERVICE_GITHUB_APP_PRIVATE_KEYmints the installation token andDEVOPS_CLI_AI_API_KEYpays the gateway; the stage Job takes both. The PR names the reader of each key insrc. Every other key goes, such as the Valkey, Mattermost and Qdrant tokens. [sources: k8s/devops/cronjob-stage.yaml, docs/CLUSTER.md:83, src/devops_cli/k8s/cluster_secrets.py] - Does the runner Job keep
DEVOPS_CLI_MCP_IMPLEMENT_TOKEN?: It keeps the key only when the implement MCP client is on. The stage Job leaves its MCP key out becauseroadmap.stage.mcpis off, and the change that turns a client on adds its key. (best practice) [sources: SECURITY.md:64, docs/CLUSTER.md:83, k8s/devops/cronjob-stage.yaml]- Chosen: Keep the key only with the MCP client on. The pod then holds no token that its settings do not read.
- Rejected: Always keep the key. An unused token stays one command away from the agent.
- Rejected: Always drop the key. The MCP client of the implement job then fails on a missing token.
- How does each key reach the container?: With one
secretKeyRefentry inenvfor each key, in the variable that has the name of the key, and with noenvFrom. The stage Job uses this shape. (best practice) [sources: k8s/devops/cronjob-stage.yaml, docs/CLUSTER.md:83, k8s/devops/cronjob-runner.yaml]- Chosen: One
secretKeyReffor each key, in the variable of the key name. The stage Job does this, and the policy already admits this shape for a stage Job. - Rejected: Keep
envFromand add the keys.envFromstill gives the agent every other key of the Secret. - Rejected: Mount the Secret as a volume. The policy admits only the volumes
tmp,homeandconfig, and the agent can read a mounted file.
- Chosen: One
- Where does the runner key list live?: In one constant in the code, as
CONST_ROADMAP_STAGE_JOB_SECRET_KEYSdoes for the stage Job. A gate check holds the rendered Job and the policy to that constant. (best practice) [sources: docs/CLUSTER.md:83, docs/CLUSTER.md:90, tests/gate/k8s_checks/job_admission_policy.py]- Chosen: One constant in the code, read by the manifest check and the policy check. The stage Job keeps its keys in
CONST_ROADMAP_STAGE_JOB_SECRET_KEYS, and a check holds the manifest and the policy to it. - Rejected: The key names in the manifest only. The policy check and the manifest can then disagree.
- Rejected: The key names in the policy only. The same drift, and the manifest holds no single list.
- Chosen: One constant in the code, read by the manifest check and the policy check. The stage Job keeps its keys in
- Must the admission policy change in the same pull request?: Yes. Policy
roadmap-service-jobsrefuses a runner Job that has avalueFrominenv, withfailurePolicy: Fail, so the Job never starts. The pull request admits the named keys insecretKeyRef, refusesenvFrom, and keeps the other pins, such as the worker count. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml, docs/CLUSTER.md:71, tests/gate/k8s_checks/job_admission_policy.py]- Chosen: Update the policy and its gate check in this pull request. The policy refuses a runner Job with
valueFrominenv, so the Job would not start. - Rejected: Change the template only. The Service cannot create the Job, and the implement job stops.
- Rejected: Admit any
secretKeyRefin the policy. This drops the pin, and a Job could then name any key.
- Chosen: Update the policy and its gate check in this pull request. The policy refuses a runner Job with
- Which documents state the
envFromthat this change replaces?:docs/CLUSTER.mdline 5 (each Job reads its credentials throughenvFrom), line 69 (the runner template uses Secretdevops-clithroughenvFrom) and line 71 (the policy admits onlyenvFromand novalueFrom). The pull request updates all three. [sources: docs/CLUSTER.md:5, docs/CLUSTER.md:69, docs/CLUSTER.md:71]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 20, 2026
Both reduce the keys each Job receives, but the candidate changes the YAML template while #5498 adds a code-level permission table and a template test.devops-cli-service commentedon Nov 20, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
fix(k8s): admit runner envFrom only in an UPDATE and check the planne…
fix(k8s): load only the needed Secret keys in runner Jobs
docs(openspec): archive 6518-runner-secret-keys
fix(k8s): admit runner envFrom only in an UPDATE and check the planne…
fix(k8s): keep the whole envFrom message and check each envFrom guard
fix(k8s): load only the needed Secret keys in runner Jobs
docs(openspec): archive 6518-runner-secret-keys
fix(k8s): admit runner envFrom only in an UPDATE and check the planne…
fix(k8s): keep the whole envFrom message and check each envFrom guard
docs(security): name the rag-ingest exception to the read-only Qdrant…
chore(main): release 0.183.1 (#6531)
devops-cli-service commentedon Nov 20, 2026
Released in v0.183.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.183.1
devops-cli-service commentedon Nov 20, 2026
Live since 2026-11-20 17:44 UTC
fix(k8s): give the runner Jobs the credentials of the cache Valkey (#…