Repository navigation
Description
Problem or Motivation
The roadmap planner reads files and runs no commands. As recorded in ADR 0018 (docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, #3242), a plan can rest on a false premise that only a command run shows. The planner needs a sandboxed environment to run read-only commands without touching cluster secrets, writable volumes, or the network.
Proposed Solution & Architectural Design
Add the Kubernetes manifest and admission policy entries for the planner sandboxed run Job according to ADR 0018:
- Create a suspended CronJob manifest that holds the pod spec with the seven isolation controls:
- A temporary HOME on an
emptyDirvolume with a size limit, plus anemptyDirfor/tmp. - Mount of a ConfigMap created from
devops-cli-configwith credentials stripped, and no secretenvFrom. - Read-only volume mount of the staged commit clone (
readOnly: true). - NetworkPolicy selecting the Job pod that denies all egress traffic, including DNS.
- Resource limits: 1 CPU, 2Gi memory limit, and
activeDeadlineSeconds: 120. - Security context:
runAsNonRoot: true,runAsUser: 1000,runAsGroup: 1000,allowPrivilegeEscalation: false,readOnlyRootFilesystem: true, and drop all capabilities. - Pod spec setting:
automountServiceAccountToken: false.
- A temporary HOME on an
- Grant
getpermission on the CronJob resource to theroadmap-service-jobsRole. - Add the run Job rules and constraints into the ValidatingAdmissionPolicy
roadmap-service-jobsink8s/devops/roadmap-service/admissionpolicy.yamland into the admission gate check.
Depends on: #3242 (ADR 0018).
Target Subsystem
Kubernetes & Minikube Automation
Existing Tool Considered
Kubernetes CronJob templates and native Job controllers cover the pod lifecycle. ValidatingAdmissionPolicy enforces the container constraints natively in Kubernetes without extra admission webhooks. The cost to wire the manifest and admission policy is approximately 12,000 tokens and 0.5 elapsed days.
Source: #3958
Proposed design
Problem statement
The planner runs no command, so a plan can rest on a false premise. ADR 0018 gives the planner a run tool that runs one read-only command in a separate Kubernetes Job. That Job needs its manifest and its admission rows before any code creates it. This issue adds the suspended CronJob, the NetworkPolicy, the Role row, the policy rows and the gate check.
Acceptance criteria
Requirement: Suspended CronJob for the planner run Job
The devops stack SHALL hold a suspended CronJob named devops-cli-planner-run that holds the pod spec of the run Job.
Scenario: The CronJob is read from the stack
- WHEN A test reads
k8s/devops/roadmap-service/cronjob-planner-run.yaml - THEN The CronJob sets
suspend: true, and its Job template setsbackoffLimit: 0,restartPolicy: Never,activeDeadlineSeconds: 120andttlSecondsAfterFinished.
Requirement: The two emptyDir volumes are the only writable paths
The run Job pod SHALL mount the home and tmp emptyDir volumes with a size limit, and SHALL mount the staged commit claim with readOnly: true.
Scenario: A write outside the read-only copy
- WHEN A test renders the Job from the CronJob template with
build_jobofsrc/devops_cli/k8s/cluster_job.py - THEN The pod mounts
emptyDirhomeat/home/devopsandemptyDirtmpat/tmpwith a size limit, the volumerepois a claim mount withreadOnly: true, and no other volume is writable.
Requirement: No credential and no service account token
The run Job container SHALL hold no envFrom of Secret devops-cli and the pod SHALL set automountServiceAccountToken: false.
Scenario: A read of a credential and of the service account token
- WHEN A test renders the Job and reads its container and pod fields
- THEN The container holds no
envFromand novalueFrom, theconfigvolume is the ConfigMapdevops-cli-config-sandbox, andautomountServiceAccountTokenisfalse.
Requirement: The pod runs as UID 1000 with no privilege
The run Job pod SHALL set runAsNonRoot: true, runAsUser: 1000, runAsGroup: 1000, allowPrivilegeEscalation: false, readOnlyRootFilesystem: true, seccompProfile: RuntimeDefault and drop all capabilities.
Scenario: The security context of the pod and of the container
- WHEN A test renders the Job
- THEN The pod sets
runAsNonRoot,runAsUser,runAsGroupandseccompProfile: RuntimeDefault, and the container setsallowPrivilegeEscalation: false,readOnlyRootFilesystem: trueandcapabilities.drop: [ALL].
Requirement: The run Job caps CPU and memory
The run Job container SHALL request and limit 1 CPU and 2Gi of memory.
Scenario: The resources of the run container
- WHEN A test renders the Job
- THEN The container sets
requests.cpu: 1,limits.cpu: 1,requests.memory: 2Giandlimits.memory: 2Gi.
Requirement: The NetworkPolicy denies all egress of the run Job pod
The stack SHALL hold a NetworkPolicy that selects the run Job pod and admits no egress, DNS included.
Scenario: The egress rules of the run Job pod
- WHEN A test reads
k8s/devops/roadmap-service/networkpolicy-planner-run.yaml - THEN The policy selects the pod label
app.kubernetes.io/name: devops-cli-planner-run, setspolicyTypes: [Egress]and holds no egress rule.
Requirement: The Role allows get on the CronJob
The Role roadmap-service-jobs SHALL allow get on cronjobs of the batch group.
Scenario: The rules of Role roadmap-service-jobs
- WHEN A test reads
k8s/devops/roadmap-service/role.yaml - THEN A rule with
apiGroups: [batch],resources: [cronjobs]andverbs: [get]exists.
Requirement: The admission policy admits the run Job shape
The ValidatingAdmissionPolicy roadmap-service-jobs SHALL admit the run Job that the CronJob template makes, and SHALL refuse a run Job that breaks a control.
Scenario: The gate check runs the expressions against the run Job
- WHEN A test runs the expressions of the policy against the Job that
build_jobrenders from the CronJob template - THEN The run Job passes, and a run Job with an extra volume, a writable
repomount or anenvFromof Secretdevops-clifails with the policy message.
Requirement: The kustomization holds the new manifests
The kustomization of the roadmap Service SHALL list the new CronJob and NetworkPolicy files.
Scenario: A read of the kustomization
- WHEN A test reads
k8s/devops/roadmap-service/kustomization.yaml - THEN The resources list holds
cronjob-planner-run.yamlandnetworkpolicy-planner-run.yaml.
Existing Tool Considered
No alternatives check has run on this issue. Kubernetes CronJob, Job, NetworkPolicy and ValidatingAdmissionPolicy cover the need natively, and the cluster already runs them. They lack a kernel boundary around a run: a defect of the host kernel reaches the pod. gVisor or the kubernetes-sigs/agent-sandbox controller would close that gap, and ADR 0018 accepts the risk for now. The manifest, the NetworkPolicy, the Role row, the policy rows and the gate check cost about 12,000 tokens and 0.5 elapsed days, as the body records.
Key questions
- Which files hold the admission policy and the gate check that runs its expressions?: The policy is
k8s/devops/roadmap-service/admissionpolicy.yaml. The gate check istests/gate/k8s_checks/job_admission_policy.py, rowk8sofdevops ci. [sources: k8s/devops/roadmap-service/admissionpolicy.yaml, tests/gate/k8s_checks/job_admission_policy.py, k8s/README.md:682] - Which Role grants the roadmap Service its permissions, and does it hold a rule for CronJobs?: Role
roadmap-service-jobsink8s/devops/roadmap-service/role.yamlallowscreateonjobs,listonpodsandgetonpods/log. It holds no rule forcronjobs, so this issue addsgetoncronjobs. [sources: k8s/devops/roadmap-service/role.yaml, docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md] - Which pod label does the run Job carry?: The run Job pod gets
app.kubernetes.io/name: devops-cli-planner-run. The stack admits DNS, the gateway, the collector and public HTTPS to the labeldevops-cli-job, so the run Job needs a label that no allow policy selects. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml, k8s/README.md:628, k8s/devops/roadmap-service/networkpolicy-egress.yaml]- Rejected: Keep the label devops-cli-job. The egress rules of the stack admit DNS, the gateway, the collector and public HTTPS to that label, so control 4 fails.
- Chosen: Use a new label devops-cli-planner-run. No allow policy selects it, so the deny-all egress policy alone applies to the pod.
- Does the run Job admission go into the existing policy or into a second policy?: Into ValidatingAdmissionPolicy
roadmap-service-jobs, as ADR 0018 records. Each expression that differs by Job shape becomes a disjunction keyed on the pod label. (best practice) [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, k8s/devops/roadmap-service/admissionpolicy.yaml, k8s/README.md:682]- Chosen: Add the rows to the existing policy. ADR 0018 records this choice, and the gate check already runs the expressions of that policy.
- Rejected: Add a second ValidatingAdmissionPolicy. It deviates from the ADR and adds a second binding and a second gate case to keep in sync.
- Rejected: Use a validating webhook. An outage of the webhook blocks the create, and the policy runs in the API server.
- Which volume holds the read-only clone of the staged commit?: The claim that the Service pod mounts (
k8s/devops/roadmap-service/pvc.yaml), mounted read-only as volumerepo. The policy pins the claim name andreadOnly: true. The claim's access mode must admit a second reader, and on the one-node cluster a ReadWriteOnce claim does. (best practice) [sources: k8s/devops/roadmap-service/pvc.yaml, k8s/devops/roadmap-service/deployment.yaml, k8s/devops/roadmap-service/admissionpolicy.yaml, docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]- Chosen: Mount the Service claim read-only. The clone already exists there, and the ADR mounts the clone of the staged commit.
- Rejected: Make a claim for each run. It needs a copy step and code that this issue does not hold.
- Rejected: Clone in an init container. The policy admits one container and no init container.
- Which ConfigMap does the
configvolume mount, and who makes it?:devops-cli-config-sandbox, a copy ofdevops-cli-configwith every key that holds a credential removed. The policy pins that name. A separate issue creates the ConfigMap, because ADR 0018 gives its creation to a person. (best practice) [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, k8s/README.md:628, k8s/devops/roadmap-service/deployment.yaml]- Chosen: A credential-free copy named devops-cli-config-sandbox. Control 2 needs the configuration and no credential, and a distinct name keeps the policy able to pin it.
- Rejected: Reuse devops-cli-config. It holds credentials, and control 2 forbids a credential in the pod.
- Rejected: Mount Secret devops-cli. Control 2 forbids the Secret in the container.
- Which image and ServiceAccount does the run Job use?: Image
ghcr.io/dan-petty/devops-cli/runnerand ServiceAccountdevops-cli, as the implement runner uses. The policy pins both. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml, k8s/README.md:680, docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]- Chosen: The runner image and ServiceAccount devops-cli. The image holds the
devopscommand, and the policy already pins the image and the ServiceAccount. - Rejected: A separate image for the run. It adds a second image to build, scan and keep.
- Chosen: The runner image and ServiceAccount devops-cli. The image holds the
- What size limits do the
homeandtmpemptyDir volumes get?: 512Mi for each volume. (best practice) [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, k8s/README.md:680]- Chosen: 512Mi for each volume. The 120 s deadline and 1 CPU bound what a run writes.
- Rejected: 4Gi for home and 1Gi for tmp. The runner values serve a dependency cache that a run does not use.
- Does the run Job set
PYTEST_XDIST_AUTO_NUM_WORKERS?: No. The resource expression requires the worker count only for the runner shape. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml, src/devops_cli/roadmap/implement/implement_size.py]- Chosen: A disjunction keyed on the pod label. The run Job runs no test, so the worker count does not apply to it.
- Rejected: The env var on both shapes. It states a false setting on the run Job.
- How does the gate check get a run Job to run the expressions against?: It renders the Job from the CronJob template with
build_jobofsrc/devops_cli/k8s/cluster_job.py, as the runner case does. [sources: src/devops_cli/k8s/cluster_job.py, tests/gate/k8s_checks/job_admission_policy.py, k8s/README.md:682] - What does the CronJob template set for the container
args?: A placeholder that the Service replaces for each run, as CronJobdevops-cli-runnerdoes. The allow-list builder of the next follow-up supplies the command. [sources: k8s/README.md:680, docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md] - Is ADR 0018 in force?: Yes. The record is on the default branch at
docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md, and its Status section makes that merge the approval. [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
Alternatives check of 2026-11-09: none.
Tool: none found.
Activity
dan-petty commentedon Nov 7, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(k8s)scope of the title gives the scope.It enables a new capability but depends on the ADR being finalized and is not a security fix.It is the only path to safely run read-only commands for the planner.The body estimates 0.5 elapsed days for the manifest and policy changes.#3242 is the ADR that designs the sandboxed run tool; the candidate implements its K8s manifest and admission policy.devops-cli-service commentedon Nov 8, 2026
Status set to Ready at 1f03ee3 (see proposed design in issue body).
Moved to new items: #4147.
devops-cli-service commentedon Nov 9, 2026
Alternatives check: none
Reason: The issue asks for Kubernetes manifests and admission rows that the repository must write itself. They are a suspended CronJob, a NetworkPolicy, a Role rule, ValidatingAdmissionPolicy expressions and a gate check. The native Kubernetes objects the issue names already cover the need. The only outside tool I found, kubernetes-sigs/agent-sandbox, is active and Apache-2.0. It would replace the pod spec of the run Job with a controller. ADR 0018 defers it to #2695 and keeps the seven controls either way. It would not remove the NetworkPolicy, Role or admission rows this issue adds.
Tool: none found
Covers:
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-09. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 13, 2026
Dependency of the
runtimeClassNamechange: #5434.When this item sets
runtimeClassName: gvisoron the run Job of the planner, it depends on #5434. The measurement of #5434 shows that the CPU and memory limits of a pod hold underrunsc. Its pull request setsoverhead.podFixedof RuntimeClassgvisorto memory16Mi. Set the class only after that pull request merges. Under the policy of #5447, the owner approves the first workload of the class.fix(k8s): keep the planner pod off the control-plane node and update …
test(k8s): cover the planner name label of a run Job (#4003)
devops-cli-service commentedon Nov 14, 2026
Released in v0.145.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.145.0
devops-cli-service commentedon Nov 15, 2026
Live since 2026-11-14 23:53 UTC
feat(k8s): render a credential-free planner ConfigMap (#6723)