Skip to content

fix(k8s): Keep the default perimeter off the planner run pod #6065

Closed

Description

@dan-petty

Problem

ADR 0018 says that the planner run Job reaches no network. k8s/devops/roadmap-service/networkpolicy-planner-run.yaml selects the pod (label app.kubernetes.io/name: devops-cli-planner-run) and has no egress rule, and its comment says "this policy alone selects it".

That is not true. devops-default-perimeter (k8s/devops/networkpolicy.yaml) selects every pod of the namespace whose app.kubernetes.io/name is not crawl4ai, searxng or renovate. The planner label is not in that list. NetworkPolicies add their rules, so the planner pod gets the egress rules of the default perimeter: DNS, the gateway, Valkey, Qdrant, the OpenTelemetry collector and public HTTPS. The check check_the_planner_template_has_the_controls_of_adr_0018 (tests/gate/k8s_checks/job_admission_policy.py) reads only the planner policy, so it does not see the second policy.

Expected behavior

  • The default perimeter does not select the planner run pod, so the pod reaches no network, DNS included, as ADR 0018 says.
  • A live check from one planner pod shows that a DNS lookup and a connection to the gateway fail (feat(k8s): a command that probes a network policy path #4407 adds a command for such a probe).
  • The comments of both policies say what is true.

Related

Proposed design

Problem statement

The planner run pod is selected by both its no-egress policy and devops-default-perimeter. NetworkPolicies add their rules, so the default perimeter gives the pod DNS, gateway, Valkey, Qdrant, OpenTelemetry collector and public HTTPS egress. The gate check reads only the planner policy, so it does not see the second selector, and the comments of both policies claim that the planner policy alone selects the pod. ADR 0018 requires the planner run Job to reach no network, DNS included.

Acceptance criteria

Requirement: Default perimeter excludes planner run pod

The devops-default-perimeter NetworkPolicy SHALL not select a pod labeled app.kubernetes.io/name: devops-cli-planner-run.

Scenario: Planner label is outside the default perimeter

  • WHEN the devops-default-perimeter pod selector is evaluated with the label app.kubernetes.io/name=devops-cli-planner-run
  • THEN the selector does not match the pod.

Requirement: Planner policy denies all egress

The devops-cli-planner-run NetworkPolicy SHALL select the planner run pod and specify policyTypes: [Egress] with no egress rules.

Scenario: Planner policy is the sole selector

  • WHEN the planner policy is evaluated with the label app.kubernetes.io/name=devops-cli-planner-run
  • THEN the policy matches the pod, its policyTypes is [Egress], and it has no egress rules.

Requirement: Gate check covers both policies

The gate check check_the_planner_template_has_the_controls_of_adr_0018 SHALL fail when devops-default-perimeter selects the planner run pod.

Scenario: Default perimeter selects the planner label

  • WHEN the default perimeter selector matches the label app.kubernetes.io/name=devops-cli-planner-run
  • THEN the gate check fails with a message that names devops-default-perimeter.

Requirement: Policy comments state the planner exclusion

The comments of devops-default-perimeter and devops-cli-planner-run SHALL state that the default perimeter does not select the planner run pod.

Scenario: Policy comments name the planner exclusion

  • WHEN a test reads the text of k8s/devops/networkpolicy.yaml and k8s/devops/roadmap-service/networkpolicy-planner-run.yaml
  • THEN the default perimeter comment names devops-cli-planner-run as an excluded label and the planner policy comment says the default perimeter does not select the pod.

Existing Tool Considered

np-guard/netpol-analyzer (https://github.com/np-guard/netpol-analyzer, fetched 2026-11-17) is the open-source analyzer for NetworkPolicy connectivity, but it lacks this repository's gate wiring, a workload manifest for a pod that exists only in a suspended CronJob template, and the comment assertion. The change instead extends the existing Python gate check (tests/gate/k8s_checks/job_admission_policy.py:812) and its two selector tests: about 20 lines, roughly 2,000 tokens to build, keep and fix, and under an hour of elapsed work.

Key questions

  • Which label identifies the planner run pod?: The pod label is app.kubernetes.io/name: devops-cli-planner-run; the CronJob pod template and the planner policy both use it. [sources: k8s/devops/roadmap-service/cronjob-planner-run.yaml:28, k8s/devops/roadmap-service/networkpolicy-planner-run.yaml:15]
  • What network behavior does ADR 0018 require of the planner run pod?: ADR 0018 requires no network: the planner run pod's NetworkPolicy admits no egress, DNS included. [sources: docs/adr/0018-a-sandboxed-read-only-run-tool-for-the-planner.md:35, k8s/devops/roadmap-service/networkpolicy-planner-run.yaml:16]
  • How should devops-default-perimeter stop selecting the planner run pod?: Add devops-cli-planner-run to the NotIn values of the app.kubernetes.io/name match expression in devops-default-perimeter, and update its comment to list the planner label. The planner policy stays the only policy that selects the pod. (best practice) [sources: k8s/devops/networkpolicy.yaml:14, k8s/devops/networkpolicy.yaml:17, k8s/devops/roadmap-service/networkpolicy-planner-run.yaml:1]
    • Chosen: Add the planner label to the default perimeter NotIn list. It follows the existing exclusion pattern for crawl4ai, searxng and renovate and makes the planner policy the only selector.
    • Rejected: Use a positive allowlist in the default perimeter. It changes which pods the default perimeter serves and is broader than this defect.
    • Rejected: Add a second deny-all NetworkPolicy. NetworkPolicies add rules, so a second policy cannot remove the default perimeter egress.
    • Rejected: Relabel the planner pod to an excluded label. It changes pod identity and conflicts with the planner policy selector and the ADR 0018 check.
  • Where should the regression check for the second selector live?: Extend check_the_planner_template_has_the_controls_of_adr_0018 to evaluate devops-default-perimeter's pod selector against the planner label and fail with a message that names the policy, and update the two tests that pin the selector's NotIn values (tests/commands/k8s/test_k8s_network_policies.py:675 and tests/config/test_k8s_devops_runtime.py:449) to expect devops-cli-planner-run. The gate check is the cross-policy regression; the two unit tests pin the manifest. (best practice) [sources: tests/gate/k8s_checks/job_admission_policy.py:812, tests/gate/k8s_checks/network_policies.py:137, tests/commands/k8s/test_k8s_network_policies.py:675, tests/config/test_k8s_devops_runtime.py:449, tests/gate/runner.py:45]
    • Chosen: Extend the ADR 0018 gate check and update the two selector tests. The gate check asserts the behavior across policies, and the two tests already pin the default perimeter's values, so they must change with the manifest.
    • Rejected: Add a separate gate check module. It duplicates policy loading and leaves the named ADR 0018 check incomplete.
    • Rejected: Update only the two unit tests. They pin the YAML values but do not assert that the default perimeter's selector does not match the planner pod.
    • Rejected: Change only the comments. No test would catch the default perimeter selecting the planner pod again.
  • How should the policy comments be kept true?: Add a raw-text test that reads both policy files and asserts the default perimeter comment lists devops-cli-planner-run and the planner comment names the default perimeter, following the existing comment test at tests/config/test_k8s_devops_runtime.py:430. (best practice) [sources: tests/config/test_k8s_devops_runtime.py:430, k8s/devops/networkpolicy.yaml:10, k8s/devops/roadmap-service/networkpolicy-planner-run.yaml:1]
    • Chosen: Raw-text comment test. The repository already tests a manifest comment this way, and a false comment is part of this defect.
    • Rejected: No test; review only. The false comment is part of the defect, so a review-only rule lets it return.
    • Rejected: Move the explanation to docs/CLUSTER.md only. The issue asks the policy comments to say what is true, and a reader of the manifest sees the comment.
  • Does this change wait for feat(k8s): a command that probes a network policy path #4407 to add a live planner network probe?: No. The policy defect and its offline gate are fixed in this change; the live probe is a post-merge verification that uses the command feat(k8s): a command that probes a network policy path #4407 adds, so it is deferred as a follow-up issue and does not block the policy fix. (best practice) [sources: docs/CLUSTER.md:94, src/devops_cli/k8s/cluster_job.py:68, tests/gate/k8s_checks/job_admission_policy.py:812]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    on Nov 16, 2026
  2. dan-petty commented on Nov 16, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. A security boundary stated in ADR 0018 is violated: the planner pod has network egress it should not have.
    • Related: feat(k8s): manifest and admission policy for planner sandboxed run job #4003, which asks for a different change. Both concern the planner run Job NetworkPolicy; #4003 created the manifest and policy, the candidate fixes the default perimeter that still selects the planner pod.
  3. added
    scope/k8s
    source/agent
    status/new
    effort/low
    value/high
    priority/p1-high
    status/in-progress
    and removed
    status/new
    on Nov 16, 2026
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  5. added
    status/in-review
    and removed
    status/in-progress
    on Nov 17, 2026
  6. removed
    status/in-review
    on Nov 17, 2026
  7. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor
  8. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-17 03:03 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/p1-highscope/k8ssource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions