Skip to content

fix(k8s): network policies, proxy bypass and root kustomization break the ingress and llm stack #667

Closed

Description

@dan-petty

Summary

Found in the release/v0.2.23 review (line numbers at 7fdaa9d).

  1. Ingress routes are blocked by the stack's own network policies. Traefik runs in kube-system (CONST_CLOUDFLARE_DEFAULT_SERVICE, src/devops_cli/config/constants.py:236), but neither policy admits it:

    • k8s/llm/networkpolicy.yaml:9-31 admits only same-namespace and monitoring traffic, and covers open-webui, ollama and qdrant.
    • k8s/otel/networkpolicy.yaml:17-28 admits only monitoring, ingress and same-namespace traffic.

    On enforcing CNIs such as k3s, the chat., ollama., qdrant. and jaeger. routes return 504.

  2. Every deploy applies an unrendered template. The root kustomization includes ingress, which is an unrendered *.example.com template, and cloudflared (k8s/kustomization.yaml:8-9). deploy-stack applies it unrendered on every run (src/devops_cli/commands/k8s/stack_lifecycle.py:660-662), including automatically at container start through DEVOPS_K8S_AUTO_DEPLOY=true (.devcontainer/devcontainer.json:44).

    • After devops k8s apply k8s/ingress --template, the next deploy resets all Ingress hosts to example.com.
    • Setups without Cloudflare get cloudflared pods stuck in CreateContainerConfigError, because the cloudflared-token secret is required.
  3. The gateway cannot reach the volta Ollama deployment. The gateway's egress policy allows only pods labelled ollama, vllm, vllm-single, lightllm or valkey (k8s/llm/gateway/networkpolicy.yaml:25-61). The volta pods are labelled ollama-volta-1, although k8s/llm/gateway/configmap.yaml:90-98 routes devops-review traffic to them. tests/test_k8s_llm_gateway.py:583-612 only checks vllm-single.

  4. Ollama hosts are missing from NO_PROXY (unconfirmed that LiteLLM honours the proxy variables). The gateway's NO_PROXY lacks *.ollama-nodes.llm.svc.cluster.local and ollama-volta-1.llm.svc.cluster.local (k8s/llm/gateway/deployment.yaml:64-69). Calls to those hosts go through squid, which the llm perimeter blocks, so Ollama-backed models return 503/504.

  5. The cloudflared egress policy is both too broad and too narrow.

    • The "to ingress controller" rule has no to:, so ports 80/443/8000/8443 are open to any destination (k8s/cloudflared/networkpolicy.yaml:42-51).
    • Only UDP 7844 is allowed, which blocks the TCP 7844 fallback (:38-41).
    • The ingress rule admits every stack namespace, not just monitoring (:17-26).
  6. Squid lets pods bypass their egress policies. It forwards to cluster-internal destinations: plain HTTP to 80/443/1025-65535, and CONNECT to 443/8443/8080/11434 (k8s/squid/configmap.yaml:75, :88-92; open egress at k8s/squid/networkpolicy.yaml:60-62). Pods whose policies allow only DNS and squid can still reach Prometheus, ArgoCD, the collector and the registry through it. This predates the release, but the new gateway comments rely on it being closed.

  7. The OTel collector accepts writes from the LAN. The collector Service moved from ClusterIP to NodePort (k8s/otel/values.yaml:108-109), which exposes the unauthenticated OTLP write path on every node IP.

Remediation Plan

  1. Admit Traefik in the llm and otel policies: a kube-system namespaceSelector with app.kubernetes.io/name: traefik.
  2. Move ingress and cloudflared out of the root kustomization into an opt-in overlay that only devops k8s apply --template renders.
  3. Allow the gateway's egress to ollama-volta-1, and extend the gateway test to cover every backend in the configmap.
  4. Add the Ollama hosts to NO_PROXY.
  5. Restrict cloudflared egress to Traefik and allow TCP 7844. Narrow its ingress rule to monitoring.
  6. Deny cluster-internal destinations in squid.
  7. Return the collector to ClusterIP, or document why a NodePort is needed.

Activity

  1. added this to the v0.2.23 milestone on Sep 28, 2026
  2. added
    type/bug
    scope/k8s
    priority/p1-high
    on Sep 28, 2026
  3. dan-petty commented on Sep 28, 2026

    @dan-petty
    OwnerAuthor

    Closed by #676, merged into release/v0.2.23.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

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

    priority/p1-highscope/k8stype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions