Skip to content

fix(k8s): let Job pods reach the MCP server - #4367

Merged
dan-petty merged 3 commits into
mainfrom
fix/4355-job-pods-reach-the-mcp-server
Nov 10, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/4355-job-pods-reach-the-mcp-server

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The NetworkPolicies of the MCP server selected the label devops-cli-runner. A Job pod carries devops-cli-job, which build_job sets, so no Job could reach TCP 8001. Both policies now select devops-cli-job, and a test holds the label equal to the one that build_job sets. Nothing else opens: one rule, TCP 8001, the server pods only.

Closes #4355

Change: openspec/changes/archive/2026-11-10-4355-mcp-server-policies-miss-the-service/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/k8s Kubernetes commands, Helm charts, pods, services, and policies labels Nov 10, 2026
The policies of the MCP server selected the label devops-cli-runner. A Job pod
carries devops-cli-job, which build_job sets. A test holds the two equal.

Refs #4355
@dan-petty
dan-petty force-pushed the fix/4355-job-pods-reach-the-mcp-server branch from e5dc184 to 74cc6c2 Compare November 10, 2026 13:26
@dan-petty

Copy link
Copy Markdown
Owner Author

Test and check record

  • fail-to-pass (devops ci fail-to-pass --base origin/main): 2 of 7 tests of tests/invariants/test_k8s_mcp_server_policies.py fail on the base (test_the_policies_admit_the_label_of_a_job_pod, test_the_policies_admit_the_service_and_the_label_that_build_job_sets_and_no_other) and pass on this branch.
  • kubectl apply --dry-run=server of the two policy files: both accepted. Nothing was applied.
  • The full local devops ci was not run (the queue is long). The GitHub checks are the gate.

Path analysis (read from the manifests and the live objects, read only)

  • Label: live Job pods carry app.kubernetes.io/name=devops-cli-job (build_job sets it). No pod carries devops-cli-runner: both CronJobs are suspended.
  • Ingress: devops-default-perimeter denies all ingress. mcp-server-ingress now admits TCP 8001 from roadmap-service and devops-cli-job.
  • Egress: the perimeter admits DNS, namespace llm (4000, 6379), namespace otel (4318) and public HTTPS. Pods of namespace devops are on none of them. mcp-server-clients now lets roadmap-service and devops-cli-job pods reach TCP 8001 of the server pods, and nothing else.
  • Credential: a Job pod loads Secret devops-cli with envFrom (the only source that the admission policy allows). The live Secret holds the key names DEVOPS_CLI_MCP_STAGE_TOKEN and DEVOPS_CLI_MCP_IMPLEMENT_TOKEN (fix(k8s): push-secrets writes the MCP server bearer token #4354). Checked by name only; no value was read.
  • Not done here: the live ConfigMap devops-cli-config has no roadmap.mcp key yet. See the person step below.

Person step 1: after the merge and the Argo CD sync, check the policies

kubectl -n devops get networkpolicy mcp-server-ingress mcp-server-clients -o yaml | grep -n "devops-cli-"

Expect devops-cli-job in both, and no devops-cli-runner.

Person step 2: prove the path (no token is used or printed)

A pod with the label is reached (HTTP 401 means the server answered and refused the missing token):

kubectl -n devops run mcp-probe-allowed --restart=Never --rm -i --labels=app.kubernetes.io/name=devops-cli-job \
  --image=curlimages/curl:8.11.1 \
  --overrides='{"spec":{"automountServiceAccountToken":false,"securityContext":{"runAsNonRoot":true,"runAsUser":1000,"seccompProfile":{"type":"RuntimeDefault"}},"containers":[{"name":"mcp-probe-allowed","image":"curlimages/curl:8.11.1","args":["-s","-o","/dev/null","-w","%{http_code}\\n","--max-time","10","http://mcp-server.devops.svc.cluster.local:8001/implementation/mcp"],"securityContext":{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]}}}]}}'

Expect 401.

A pod without the label is blocked (a timeout):

kubectl -n devops run mcp-probe-blocked --restart=Never --rm -i --labels=app.kubernetes.io/name=mcp-probe-blocked \
  --image=curlimages/curl:8.11.1 \
  --overrides='{"spec":{"automountServiceAccountToken":false,"securityContext":{"runAsNonRoot":true,"runAsUser":1000,"seccompProfile":{"type":"RuntimeDefault"}},"containers":[{"name":"mcp-probe-blocked","image":"curlimages/curl:8.11.1","args":["-s","-o","/dev/null","-w","%{http_code}\\n","--max-time","10","http://mcp-server.devops.svc.cluster.local:8001/implementation/mcp"],"securityContext":{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]}}}]}}'

Expect the curl exit code 28 (the pod phase is Error) and 000 or no output. Clean up: kubectl -n devops delete pod mcp-probe-allowed mcp-probe-blocked --ignore-not-found.

The image curlimages/curl is pulled over public HTTPS by the node. If the registry is blocked there, use an image that the cluster already holds.

Person step 3: the live ConfigMap, before a client switch

Order matters: apply the ConfigMap with roadmap.mcp.url first, then turn a switch on.

  1. In config.yaml set roadmap.mcp.url: http://mcp-server.devops.svc.cluster.local:8001 (it is in k8s/devops/configmap.example.yaml). Keep roadmap.stage.mcp and roadmap.implement.mcp off.
  2. devops k8s deploy-stack --stack devops (renders and applies ConfigMap devops-cli-config).
  3. Make sure Secret devops/mcp-server and the two client keys of devops/devops-cli hold the token: devops k8s push-secrets --only devops/mcp-server --only devops/devops-cli (fix(k8s): push-secrets writes the MCP server bearer token #4354).
  4. Run step 2 and see the 401.
  5. Set roadmap.implement.mcp: true (and later roadmap.stage.mcp: true) in config.yaml, then run deploy-stack --stack devops again.

The LiteLLM route (a separate decision) can add a second path later. These policies stay valid until a change removes them.

@dan-petty
dan-petty marked this pull request as ready for review November 10, 2026 13:37
@dan-petty
dan-petty merged commit f795fb8 into main Nov 10, 2026
25 checks passed
@dan-petty
dan-petty deleted the fix/4355-job-pods-reach-the-mcp-server branch November 10, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/k8s Kubernetes commands, Helm charts, pods, services, and policies type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(k8s): MCP server policies miss the Service runner Jobs

1 participant