Repository navigation
Description
Problem
To prove that the MCP server policies work (#4355), a throwaway pod had to be made by hand with kubectl run --overrides, a restricted security context, a label, and a sleep. The first attempt failed because kube-router programs the policy of a new pod a few seconds after the pod starts (the connection was refused at once, curl exit 7). After a 20 second wait, the allowed pod got HTTP 401 (reached) and the blocked pod got exit 7 (blocked). The steps are easy to get wrong, and the project prefers a devops k8s command over hand-made pods for cluster checks.
What to build
A command, for example devops k8s probe, that runs one throwaway pod with a given label in a given namespace, waits for the policy to be programmed, requests a URL (method, path, no token printed), prints the HTTP status or the curl exit code, and always deletes the pod. It uses a restricted security context that passes Pod Security, a pinned image from the project's allowed registries, and a timeout. --dry-run makes no request. A test uses a fake kubectl edge.
Done when
devops k8s probe --label app.kubernetes.io/name=devops-cli-job --url http://mcp-server.devops.svc.cluster.local:8001/implementation/mcp prints 401, and the same with another label prints a blocked result.
Proposed design
Problem statement
The project checks a network policy with a hand-made pod. An operator runs kubectl run --overrides with a restricted security context, a label and a sleep. The first attempt fails because kube-router programs the policy of a new pod a few seconds after the pod starts. The manual steps are easy to get wrong and slow to repeat.
The repository already holds that throwaway pod: src/devops_cli/k8s/service_probe.py starts one labeled pod, runs a bounded probe with kubectl exec and deletes the pod, also after a failure.
This change adds devops k8s probe. The command runs one throwaway pod with a given label in a given namespace. It retries until the policy is programmed, requests one URL, and prints the HTTP status or the curl exit code. It always deletes the pod, and --dry-run prints the request plan and touches no cluster.
Acceptance criteria
Requirement: One labeled probe pod
The command SHALL create exactly one pod in the given namespace with the given label and SHALL send each attempt with kubectl exec into that pod.
Scenario: One pod for the whole probe
- WHEN The operator runs
devops k8s probe --namespace devops --label app.kubernetes.io/name=devops-cli-job --url http://mcp-server.devops.svc.cluster.local:8001/implementation/mcpwith the process fake. - THEN The fake records one
kubectl runcall that carries namespacedevopsand labelapp.kubernetes.io/name=devops-cli-job, and no secondruncall.
Requirement: Restricted security context
The probe pod MUST set the security context of the shared throwaway pod, so that it passes the restricted Pod Security Standard.
Scenario: Pod spec passes restricted Pod Security
- WHEN The command builds the pod spec.
- THEN The spec sets
runAsNonRoot: true, a non-zerorunAsUser,allowPrivilegeEscalation: false,capabilities.drop: [ALL],seccompProfile.type: RuntimeDefault,readOnlyRootFilesystem: trueandautomountServiceAccountToken: false.
Requirement: Wait for the policy
The command MUST retry the request while the pod's curl exits 7, until the --wait deadline of 20 seconds, before it makes the measured request.
Scenario: A refused connection is retried
- WHEN The process fake answers the first two
execcalls with exit code 7 and the third with standard output401. - THEN The command makes three
execcalls and printsstatus=401.
Requirement: Blocked result
The command SHALL print the curl exit code when no HTTP response arrives.
Scenario: A blocked path prints the exit code
- WHEN The process fake answers every
execcall with exit code 7 until the wait deadline. - THEN The command prints
curl_exit=7and exits 0.
Requirement: Credential off the command line
The command MUST send each header value to curl on standard input and MUST NOT hold it in any command line or in the output.
Scenario: A secret header stays off every argv and out of the output
- WHEN The operator passes
--header 'Authorization: Bearer s3cr3t'and the process fake answers the measured request with status 200. - THEN No recorded argv holds
s3cr3t, theexeccall's standard input holds it, and the standard output and the standard error hold nos3cr3t.
Requirement: Pod deletion
The command MUST delete the probe pod before it exits, including after an error or a timeout.
Scenario: Pod deleted after a failed probe
- WHEN The process fake fails the first
execcall with exit code 2. - THEN The fake records one
delete pod --ignore-not-foundcall for the generated pod name, and the command exits non-zero.
Requirement: Probe deadline
The command MUST stop the probe when the overall --timeout deadline of 60 seconds elapses and report a timeout.
Scenario: Deadline stops a slow probe
- WHEN The process fake does not answer the
execcall before the--timeoutdeadline. - THEN The command prints a timeout message, records the pod deletion and exits non-zero.
Requirement: Dry run
The command SHALL create no pod and send no request with --dry-run.
Scenario: Dry run prints the plan only
- WHEN The operator runs the command with
--dry-run. - THEN The fake records no
run, noexecand nodeletecall, and the output holds thekubectl run, thecurlcommand line and the URL.
Requirement: Pinned image
The probe pod MUST use an image pinned by digest.
Scenario: The image names a digest
- WHEN The command builds the pod spec with the default image and with
--image. - THEN Each image reference holds
@sha256:, and a--imagevalue that holds no digest is refused before anykubectlcall.
Existing Tool Considered
No alternatives check has run. kubectl is the open, maintained tool that covers the need in part (https://kubernetes.io/docs/reference/kubectl/generated/kubectl_run/). kubectl run, kubectl exec and kubectl delete create the labeled pod, send the request and remove the pod. kubectl lacks a wait for kube-router to program the policy, a restricted security context by default, a printed HTTP status or curl exit code, and guaranteed deletion on a timeout. curlimages/curl is the open, maintained image that supplies curl and its exit codes (https://hub.docker.com/r/curlimages/curl). The project already holds the throwaway pod in src/devops_cli/k8s/service_probe.py:267, so the change extends it with one HTTP attempt and a probe command instead of a second pod path. The written cost is about 25k tokens to build the attempt, the command and their tests, about 5k tokens a year to keep and fix, and half a day of elapsed time.
Key questions
- Which code runs the probe pod?: The existing module
src/devops_cli/k8s/service_probe.py.probe_from_podstarts one labeled pod withkubectl run, runs onekubectl execper target and deletes the pod, also after a failure. The change adds an HTTP attempt beside_connectsand reuses_pod_overrides,_start_pod,_delete_podandplan_probe_from_pod. It adds no second pod implementation, as the crawl4ai-check spec already requires of the shared probe code. [sources: src/devops_cli/k8s/service_probe.py:267, src/devops_cli/k8s/service_probe.py:306, src/devops_cli/k8s/searxng_check.py:32, openspec/specs/k8s-crawl4ai-check/spec.md:66] - Does the command exec into one sleeping pod, or run a new pod for each request?: One pod. The module starts it once with
kubectl runandsleep, sends every attempt withkubectl exec, and deletes it once in afinally-shaped block. The label and the pod identity stay constant across the retries, so the policy of one pod is measured. [sources: src/devops_cli/k8s/service_probe.py:282, src/devops_cli/k8s/service_probe.py:298, tests/k8s/test_service_probe.py:39] - How does the command wait for kube-router to program the policy?: Retry the request while the pod's
curlexits 7 (failed to connect) until--waitelapses, default 20 seconds. Then make one measured request with--max-time. The loop lives in the command, so the command enforces--timeoutand eachkubectlcall stays under the module's 30 second subprocess timeout. Do not use a fixed sleep. (best practice) [sources: src/devops_cli/k8s/service_probe.py:65, src/devops_cli/k8s/service_probe.py:194, https://tmuxai.dev/exit-code/curl-7/]- Chosen: Retry on curl exit 7 until a deadline. The retry ends as soon as the path works, it bounds the wait, and it reuses the exit-code parsing that the module already has.
- Rejected: Fixed sleep of 20 seconds. It wastes 20 seconds when the path is ready at once, and it fails when programming takes longer.
- Rejected: curl --retry-connrefused inside one exec. The command could not bound each kubectl call under the 30 second subprocess timeout, and it could not report the attempts.
- Which image does the probe pod run?:
curlimages/curl, pinned by digest, with the tag before the digest asPROBE_IMAGErecords busybox. The image is a parameter of the shared pod spec, so the busybox pod of the service checks keeps its image. It gives curl's status output and exit codes, and the pod spec sets the non-root user, so the user of the image does not matter.--imageallows another image only with a digest. Check once against the pinned digest thatsleepandcurlrun there, as the module records for the busybox applet. (best practice) [sources: https://hub.docker.com/r/curlimages/curl, src/devops_cli/k8s/service_probe.py:62, src/devops_cli/k8s/service_probe.py:144]- Chosen: curlimages/curl pinned by digest. It is the official curl image, maintained by the curl docker team, and it gives the HTTP status and the curl exit code that the issue asks for.
- Rejected: busybox with nc, the current PROBE_IMAGE. It has no curl and no HTTP status, so a blocked path and a refused connection give the same result.
- Rejected: registry.k8s.io/e2e-test-images/agnhost. It reports reachability, but it gives no curl exit code.
- Rejected: The devops-cli image. It is large, and its tools are not the subject of the probe.
- What does
--dry-rundo?: Render the request plan and stop: thekubectl runwith a placeholder for the restricted pod spec, thekubectl execwith the curl command line and the URL, and thekubectl delete. It creates no pod and sends no request. This is the dry-run shape that every k8s command uses, andplan_probe_from_podalready renders the pod part of it. (best practice) [sources: src/devops_cli/k8s/service_probe.py:306, src/devops_cli/commands/k8s/searxng_check.py:101, openspec/specs/k8s-crawl4ai-check/spec.md:9]- Chosen: Render the request plan and stop. The operator sees the exact pod and request, nothing touches the cluster, and the command matches the dry-run of the other k8s checks.
- Rejected: Create the pod and skip the request. It leaves a pod behind for a check that was meant to be safe.
- How does a header value reach curl without being printed or passed on a command line?: Write the headers as curl config lines (
header = "...") to the standard input ofkubectl exec -i, withcurl -K -.run_subprocesstakesinput=, and the process fake recordsstdin, so the test can assert that no argv holds the value. The project already forbids a token on a command line. (best practice) [sources: openspec/specs/k8s-crawl4ai-check/spec.md:41, src/devops_cli/core/process.py:903, tests/support/fakes/process.py:39]- Chosen: curl config on standard input. The value stays out of every command line and out of the output, and the process seam records it for the test.
- Rejected: The value in the exec argv. It puts the token in the process list of the pod and in the kubectl call, which the crawl4ai-check spec forbids.
- Rejected: An environment variable on the pod. The value lands in the pod object, where anyone with get pods in the namespace reads it.
- What does the command print, and what exit status does it use?: Print
status=<code>when a response arrives, andcurl_exit=<code>when the connection fails, with no response body. Exit 0 when the probe measured a result, including a blocked path. Exit non-zero whenkubectlfails, the pod does not start, or the overall deadline passes. (best practice) [sources: src/devops_cli/k8s/service_probe.py:80, src/devops_cli/commands/k8s/searxng_check.py:135]- Chosen: Print the result and exit 0 on a measurement. A blocked path is a valid result for a policy check, so a script reads the printed value.
- Rejected: Exit non-zero on a blocked path. The caller cannot tell a blocked path from a broken command.
- How does the test avoid a cluster?: The test installs the process fake through the process seam and asserts on the recorded argv, standard input and answers. No test starts a pod, calls
curlor reaches a host, as the test decision requires of every test ofsrc/. [sources: tests/support/fakes/process.py:28, tests/k8s/test_service_probe.py:19, docs/adr/0007-tests-double-only-process-edges.md:3] - Where does the command live?: A
probesubcommand of the existingk8sgroup: the modulesrc/devops_cli/commands/k8s/probe.py, registered withapp.command("probe")insrc/devops_cli/commands/k8s/__init__.py, next tosearxng-check. Its test istests/k8s/test_k8s_probe.py, next to the other k8s tests. [sources: src/devops_cli/commands/k8s/init.py:60, src/devops_cli/commands/k8s/searxng_check.py:101, tests/k8s/test_searxng_check.py:1]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-21: in-use.
The repository already uses this tool.
Tool: kubernetes/kubectl (https://github.com/kubernetes/kubectl), Apache-2.0, last activity 2026-11-19, maintained.
Reason: Web searches found no dedicated network-policy probe command, only kubectl and a debugging image. kubectl already creates the labeled pod, execs the request and deletes it, but lacks the retry, restricted spec, printed result and cleanup on timeout.
Covers:
- Creates one labeled pod in a namespace with an inline JSON override
- Runs a command inside the pod with exec
- Deletes the pod, with ignore-not-found and a wait option
- Accepts a pinned image, a restart policy and timeouts
Lacks:
- No retry until kube-router programs the policy
- No restricted security context by default
- No printed HTTP status or curl exit code
- No guaranteed pod deletion when the overall deadline passes
Activity
dan-petty commentedon Nov 10, 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 is a developer diagnostic tool, not a production fix, but it reduces manual error in verifying security policies.It replaces a fragile manual procedure with a repeatable command for checking network policy paths.It needs a new subcommand, pod lifecycle handling, a security context, timeout, dry-run flag, and a test with a fake kubectl.Both concern MCP server network policies, but #4355 fixes the policy labels while the candidate builds a diagnostic command to verify those policies.devops-cli-service commentedon Nov 10, 2026
Status set to Ready at efe3884 (see proposed design in issue body).
devops-cli-service commentedon Nov 11, 2026
Alternatives check: in-use
Reason: Searches found no maintained tool that performs the whole probe: the only results were the kubectl primitives the project already uses and the netshoot troubleshooting image, which just supplies curl and other network tools. kubectl covers the pod lifecycle and the in-pod request (run, exec, delete), but not the policy wait, the restricted context, the printed status/exit code or the guaranteed cleanup, so the command still has to be built on top of it.
The item already names this tool.
Tool: kubernetes/kubernetes (https://github.com/kubernetes/kubernetes)
Covers:
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-11. A person decides what this means for the item. The check changes no label and closes no issue.
fix(k8s): Run kube-linter on the Argo CD builds in CI (#6112)
devops-cli-service commentedon Nov 21, 2026
The result in the alternatives block of the issue body changed. Before this check:
in-use, tool https://github.com/kubernetes/kubernetes. A person decides what the new result means for the item.Searches (10)
Tools considered:
Searches run:
Sources:
19 remaining items
devops-cli-service commentedon Nov 23, 2026
The draft pull request #6894 holds the final title and body. In mode
onofroadmap.fix_checks.mode, the watch row marks it ready when its checks pass, and a fix-checks Job repairs a failed check whose name gives the class test, lint or types. In each other case the watch row stops the item: another failed check, a cancelled check, a conflict, a fix-checks Job that ended with no repair, or another mode.Spend: 198 model requests, 22217138 input tokens, 88498 output tokens.
feat(k8s): a command that probes a network policy path (#4407)
docs(openspec): archive the change (#4407)
devops-cli-service commentedon Nov 23, 2026
Released in v0.203.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.203.0
devops-cli-service commentedon Nov 23, 2026
Live since 2026-11-23 18:26 UTC