Skip to content

fix(k8s): network policy peers name only namespaces that exist, starting with portkey-perimeter's devops-cli peer #1656

Closed

Description

@dan-petty

Friction

Two NetworkPolicies admit traffic from namespaces that do not exist, so they state an intent they do not enforce. portkey-perimeter admits port 8787 from namespace devops-cli, but the stack namespace is devops; the otel perimeter admits a namespace named ingress, but Traefik runs in kube-system. The Portkey peer is a leftover: v0.2.23 removed the same block from the gateway policy and missed this copy. No traffic is blocked today, because nothing in devops calls Portkey and its egress forbids 8787 anyway, but a future reader trusts the stated peers.

Evidence

Live, read-only, 2026-10-17:

  • NetworkPolicy llm/portkey-perimeter: an ingress peer namespaceSelector kubernetes.io/metadata.name=devops-cli on TCP 8787, and podSelector part-of=devops-cli-stack with no namespaceSelector, which matches only pods in llm. It is the only policy selecting the Portkey pods (llm-default-perimeter excludes portkey). Application llm Synced at 3dd7fa6.
  • Namespaces: argocd, cloudflared, default, devops, kube-node-lease, kube-public, kube-system, llm, local-path-storage, logging, monitoring, otel, registry. No devops-cli, no ingress.
  • Deployment llm/portkey 1/1, Service ClusterIP 8787.

Repo:

  • k8s/llm/portkey/networkpolicy.yaml:19-26 (the namespaceSelector at :21-23, comment at :19); k8s/otel/networkpolicy.yaml:22-24 (kubernetes.io/metadata.name: ingress); k8s/namespaces.yaml declares devops.
  • k8s/devops/networkpolicy.yaml:25-33 lets devops pods reach llm on TCP 4000 only.
  • DEFAULT_PORTKEY_GATEWAY_CLUSTER_URL (src/devops_cli/config/defaults.py:90) is referenced nowhere else.
  • History: 838c0d7 (v0.2.21) copied the three-peer block into both the gateway and Portkey policies; ea49d6e (v0.2.23) removed it from k8s/llm/gateway/networkpolicy.yaml only.

Remedy

  1. Test first: every kubernetes.io/metadata.name value in a namespaceSelector under k8s/ names a namespace declared in k8s/namespaces.yaml or a built-in one (kube-system, default); it fails today on both files.
  2. Delete the devops-cli peer from k8s/llm/portkey/networkpolicy.yaml:21-23 and correct the comment at :19, as v0.2.23 did for the gateway. Only if a devops Job is meant to call Portkey does the peer become devops, with a matching llm:8787 egress rule in k8s/devops/networkpolicy.yaml; otherwise remove the unused DEFAULT_PORTKEY_GATEWAY_CLUSTER_URL.
  3. Drop the ingress peer from k8s/otel/networkpolicy.yaml:22-24; the next peer already admits Traefik in kube-system.

Priority: P3. Severity low: policy accuracy, no exposure or outage.

Activity

  1. added
    source/agent
    type/bug
    on Oct 18, 2026
  2. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Type: type/bug. The candidate fixes incorrect network policy peers that do not enforce their stated intent.
    • Priority: P3-Low. Low severity: policy accuracy, no exposure or outage.
    • Value: Medium. Improves correctness of network policies, which is valuable for security and maintainability.
    • Effort: Low. Simple removal of incorrect peer entries and correction of comments.
  3. added a commit that references this issue on Oct 26, 2026
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

    source/agenttype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions