Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript
5.0 KB
Raw Blame
# ─── L0: Default deny all traffic ─────────────────────────────────────────────
# The existing 'mcp-host' policy below only covers pods with
# clerum.io/managed-by=host-context-controller. This deny-all ensures ANY
# pod deployed in this namespace is restricted by default.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: deny-all-mcp-host
  namespace: mcp-host
  labels:
    clerum.io/policy-type: default-deny
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress
---
# ─── L1: DNS egress (HCC-managed mcp-host pods) ───────────────────────────────
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-dns-egress-mcp-host
  namespace: mcp-host
  labels:
    clerum.io/policy-type: infrastructure
spec:
  podSelector:
    matchLabels:
      clerum.io/managed-by: host-context-controller
  policyTypes:
  - Egress
  egress:
  - ports:
    - port: 53
      protocol: UDP
    - port: 53
      protocol: TCP
    to:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: kube-system
---
# ─── L2 (existing): chatllm managed pod rules ────────────────────────────────
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: mcp-host
  namespace: mcp-host
spec:
  podSelector:
    matchLabels:
      clerum.io/managed-by: host-context-controller
  policyTypes:
  - Ingress
  - Egress
  # mcp-host ingress is per-Host. HCC generates
  # `mcp-host-<host>-ingress-rpc-proxy` and
  # `mcp-host-<host>-ingress-channel-reader` so rpc-proxy and channel-reader
  # can only reach the selected Host pod. Do not add namespace-wide ingress
  # from rpc-proxy here.
  ingress: []
  egress:
  - ports:
    - port: 8081
      protocol: TCP
    to:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: control-plane
      podSelector:
        matchLabels:
          app: host-context-controller-api-gateway
  # mcp-host reaches control-api only through the workflow-approval-gateway on
  # :8092 for runtime approval, usage, budget, and governed tracing traffic.
  # Direct mcp-host → control-api:8090 stays DENY by omission.
  - ports:
    - port: 8092
      protocol: TCP
    to:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: control-plane
      podSelector:
        matchLabels:
          app: nginx-workflow-approval-gateway
  # Context-specific mcp-host -> MCP server egress is generated by HCC as
  # per-(context, server) NetworkPolicies. Do not add a namespace-wide
  # mcp-server egress lane here; a compromised 1st-party mcp-host must only
  # reach MCP servers already granted by its Context.
  - ports:
    - port: 53
      protocol: UDP
    - port: 53
      protocol: TCP
    to:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: kube-system
      podSelector:
        matchLabels:
          k8s-app: kube-dns
  # LLM API + http_request tool: external HTTPS. Keep this as public internet
  # only; internal, metadata, carrier NAT, documentation, benchmarking, and
  # multicast/reserved ranges require explicit policy instead.
  # Scope is rule-level: HCC API, approval gateway, DNS, K8s API, and per-Context
  # MCP-server egress remain separate static/generated policies.
  - ports:
    - port: 443
      protocol: TCP
    to:
    - ipBlock:
        cidr: 0.0.0.0/0
        # N12: filled at deploy time by the kustomize `replacements` in
        # deploy/base/kustomization.yaml from the canonical PublicEgressExceptionSet
        # (deploy/base/public-egress-exceptions.yaml) — single source of truth,
        # shared with mcp-server public-web egress. Keep empty here.
        except: []
  # http_request tool: external HTTP with the same public-only boundary.
  - ports:
    - port: 80
      protocol: TCP
    to:
    - ipBlock:
        cidr: 0.0.0.0/0
        # N12: filled at deploy time by the kustomize `replacements` in
        # deploy/base/kustomization.yaml from the canonical PublicEgressExceptionSet
        # (deploy/base/public-egress-exceptions.yaml) — single source of truth,
        # shared with mcp-server public-web egress. Keep empty here.
        except: []
---
# ─── L1: K8s API server egress (HCC-managed mcp-host pods) ────────────────────
# Required for getHost() and other K8s API calls in production mode.
# The CIDR is environment-specific — overlays MUST patch this with the real IP.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-k8s-api-egress-mcp-host
  namespace: mcp-host
  labels:
    clerum.io/policy-type: infrastructure
spec:
  podSelector:
    matchLabels:
      clerum.io/managed-by: host-context-controller
  policyTypes:
  - Egress
  egress:
  - to:
    - ipBlock:
        cidr: 10.109.0.1/32
    ports:
    - port: 443
      protocol: TCP
    - port: 8443
      protocol: TCP