Skip to content

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

Closed

Description

@dan-petty

Problem Description

The two NetworkPolicies of the MCP server select the client pods by the label app.kubernetes.io/name: devops-cli-runner. A runner Job that the Service or devops k8s run-job makes does not carry that label. So the policies would block the Job pods when roadmap.implement.mcp is on.

Reproduction Steps

  1. Read build_job in src/devops_cli/k8s/cluster_job.py. It sets app.kubernetes.io/name: devops-cli-job on the pod template of every Job it makes, and this replaces the label of the CronJob template.
  2. Read k8s/devops/roadmap-service/admissionpolicy.yaml. It requires the pod label devops-cli-job for a Job of the Service.
  3. Read k8s/devops/mcp-server/networkpolicy.yaml (ingress) and networkpolicy-client.yaml (egress). They name roadmap-service and devops-cli-runner, and not devops-cli-job.

Expected vs Actual Behavior

Expected: a runner Job that calls /implementation/mcp can reach TCP 8001 of the server, and no other pod can.

Actual: only the pods of the runner CronJob (label devops-cli-runner) match. A Job of the Service (label devops-cli-job) matches neither policy, so its connection is dropped. Issue #3600 asked for ingress from devops-cli-job.

Environment Diagnostics

devops-cli 0.107.0, k8s stack devops. Both client switches are off today, so no call fails yet. The fix needs a decision: allow the label devops-cli-job, which also covers the generic Jobs, or give the runner Jobs of the Service a second label for the policy.

Logs, Traces, or Terminal Output

None. This is read from the manifests and the code.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Proposed design

Problem statement

The two NetworkPolicies of the MCP server select client pods by the label app.kubernetes.io/name: devops-cli-runner. A runner Job that the Service or devops k8s run-job makes carries the label devops-cli-job instead, because build_job replaces the CronJob label. So the policies would drop the connection of every runner Job to TCP 8001 of the MCP server when roadmap.implement.mcp is on.

Acceptance criteria

Requirement: Runner Job pods carry the MCP client label

The function build_job SHALL set the label devops-cli/mcp-client: "true" on the pod template and the Job when the template is the runner template, and SHALL keep the label app.kubernetes.io/name: devops-cli-job.

Scenario: Runner template

  • WHEN build_job runs with RUNNER_TEMPLATE on a runner CronJob fixture
  • THEN The pod template labels hold devops-cli/mcp-client with the value true and app.kubernetes.io/name with the value devops-cli-job.

Requirement: Generic Job pods get no MCP client label

The function build_job MUST NOT set the label devops-cli/mcp-client when the template is the default template.

Scenario: Default template

  • WHEN build_job runs with DEFAULT_TEMPLATE on a CronJob fixture
  • THEN The pod template labels hold no key devops-cli/mcp-client.

Requirement: Ingress policy admits the runner Job label

The NetworkPolicy mcp-server-ingress SHALL admit TCP 8001 from pods that carry the label devops-cli/mcp-client: "true" and from the roadmap Service pods only.

Scenario: Ingress selectors

  • WHEN A test renders k8s/devops/mcp-server/networkpolicy.yaml
  • THEN The from list selects the label devops-cli/mcp-client and app.kubernetes.io/name: roadmap-service, and the only port is TCP 8001.

Requirement: Egress policy admits the runner Job label

The egress NetworkPolicy in k8s/devops/mcp-server/networkpolicy-client.yaml SHALL select the pods that carry the label devops-cli/mcp-client: "true" and allow TCP 8001 to the MCP server.

Scenario: Egress selector

  • WHEN A test renders k8s/devops/mcp-server/networkpolicy-client.yaml
  • THEN The pod selector matches the label devops-cli/mcp-client, and the egress rule allows TCP 8001 to the pods app.kubernetes.io/name: mcp-server.

Requirement: The Job still passes the admission policy

A runner Job with the new label SHALL pass the ValidatingAdmissionPolicy roadmap-service-jobs.

Scenario: Admission with the extra label

  • WHEN The test in tests/gate/k8s_checks/job_admission_policy.py evaluates the policy on the Job that build_job makes from the runner CronJob
  • THEN Every validation passes.

Existing Tool Considered

Kubernetes NetworkPolicy and ValidatingAdmissionPolicy already cover the need. The change adds one label to build_job and edits two manifests. No other open tool or library is needed. Building it costs a small change of about 40 lines with tests, and about one hour.

Key questions

  • Which label do the MCP server policies use to select the runner Job pods?: Use a second label, devops-cli/mcp-client: "true". build_job sets it for the runner template only. The two policies select it. The name label devops-cli-job stays as it is. (best practice) [sources: src/devops_cli/k8s/cluster_job.py, k8s/devops/roadmap-service/admissionpolicy.yaml, k8s/devops/mcp-server/networkpolicy.yaml]
    • Rejected: Select app.kubernetes.io/name: devops-cli-job. It also admits the generic Jobs of devops k8s run-job, which have no need of the MCP server. The issue asks that no other pod can reach the server.
    • Chosen: Add a second label for runner Jobs only. It keeps the name label that the admission policy and the egress policies require. It admits only the runner Jobs. build_job already accepts extra labels, and the admission policy does not forbid them.
  • Does the admission policy refuse a Job pod with an extra label?: No. The policy checks only that app.kubernetes.io/name equals devops-cli-job. A test still evaluates it on the new Job. [sources: k8s/devops/roadmap-service/admissionpolicy.yaml, tests/gate/k8s_checks/job_admission_policy.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/k8s
    status/new
    value/medium
    effort/low
    on Nov 10, 2026
  2. dan-petty commented on Nov 10, 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/bug. The fix prefix of the title gives the type.
    • Scope: scope/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. The defect is latent because both client switches are off today, but it will block Service runner Jobs from reaching the MCP server when enabled.
    • Value: Medium. Without the fix, Service runner Jobs cannot reach the MCP server once the feature is turned on.
    • Effort: Low. The change adds one label to two YAML podSelectors or adds a second label to the Job pod template.
    • Related: feat(k8s): deploy MCP server manifests when entrypoint exists #3600, which asks for a different change. Both concern the MCP server NetworkPolicies in k8s/devops/mcp-server/, but #3600 creates them and the candidate fixes a missing devops-cli-job label in the podSelector.
  3. added
    priority/p2-medium
    on Nov 10, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 10, 2026
  5. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 273e4c9 (see proposed design in issue body).

  6. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 10, 2026
  7. dan-petty commented on Nov 10, 2026

    @dan-petty
    OwnerAuthor

    Decision (owner, 2026-11-10): devops-cli-job pods may reach and use the MCP server. Draft PR #4367 selects devops-cli-job in both policies (no second label), keeps TCP 8001 to the server pods only, and adds a test that holds the admitted label equal to the label that build_job sets. Path analysis and the person steps are in the PR comments.

  8. added
    status/in-review
    and removed
    status/in-progress
    on Nov 10, 2026
  9. removed
    status/in-review
    owner/agent
    on Nov 10, 2026
  10. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor
  11. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-10 13:56 UTC

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/lowpriority/p2-mediumscope/k8ssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions