Skip to content

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

TypeScript
5.5 KB
Raw Blame
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  labels:
    clerum.io/managed-by: host-context-controller
    clerum.io/policy-type: default-deny
  name: deny-all-rpc-proxy
  namespace: rpc-proxy
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  labels:
    clerum.io/managed-by: host-context-controller
    clerum.io/policy-type: infrastructure
  name: allow-dns-egress-rpc-proxy
  namespace: rpc-proxy
spec:
  egress:
  - ports:
    - port: 53
      protocol: UDP
    - port: 53
      protocol: TCP
    to:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: kube-system
  podSelector: {}
  policyTypes:
  - Egress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  labels:
    clerum.io/managed-by: host-context-controller
    clerum.io/policy-type: infrastructure
  name: allow-hcc-api-egress-rpc-proxy
  namespace: rpc-proxy
spec:
  egress:
  - ports:
    - port: 8081
      protocol: TCP
    to:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: control-plane
      podSelector:
        matchLabels:
          app: host-context-controller-api-gateway
  podSelector:
    matchLabels:
      app: rpc-proxy
  policyTypes:
  - Egress
---
# NOTE: allow-k8s-api-egress-rpc-proxy is intentionally NOT in base.
# host-context-controller creates an opt-in runtime policy with selector
# clerum.io/k8s-api-egress=true using KUBERNETES_SERVICE_HOST, so rpc-proxy
# pods do not receive Kubernetes API access unless explicitly labeled.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: rpc-proxy
  namespace: rpc-proxy
spec:
  egress:
  - ports:
    - port: 53
      protocol: UDP
    - port: 53
      protocol: TCP
    to:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: kube-system
      podSelector:
        matchLabels:
          k8s-app: kube-dns
  # rpc-proxy -> mcp-server egress is context-scoped and generated by HCC as
  # rpc-egress-<context>-<server>. Do not add a namespace-wide mcp-server lane
  # here; it bypasses the dynamic per-server policy boundary.
  # rpc-proxy -> mcp-host egress is Host-scoped and generated by HCC as
  # rpc-proxy-<host>-egress-mcp-host. Do not add a namespace-wide mcp-host
  # lane here; it lets one compromised rpc-proxy path reach every Host pod.
  - ports:
    - port: 8090
      protocol: TCP
    to:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: control-plane
      podSelector:
        matchLabels:
          app: control-api-rpc-gateway
  # TM-4: external HTTPS only — exclude private and special-use ranges to
  # prevent internal, metadata, link-local, and control-plane probing.
  # Scope is rule-level: HCC, control-api gateway, sandbox-ui, mcp-host, and
  # mcp-server paths are explicit static/generated policies, not this rule.
  - ports:
    - port: 443
      protocol: TCP
    to:
    - ipBlock:
        cidr: 0.0.0.0/0
        except: []
  ingress:
  - from:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: ingress
      podSelector:
        matchLabels:
          app: cloudflared
    ports:
    - port: 8094
      protocol: TCP
  podSelector:
    matchLabels:
      app: rpc-proxy
  policyTypes:
  - Ingress
  - Egress
---
# allow-ingress-rpc-proxy: service-to-service ingress (no ingress-nginx)
# SSE paths:
#   Desktop App  → external-rest-api (profiles)      → rpc-proxy:8094 → mcp-host
#   Control UI   → control-api      (control-plane)  → rpc-proxy:8094 → mcp-host
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-ingress-rpc-proxy
  namespace: rpc-proxy
  labels:
    clerum.io/managed-by: host-context-controller
    clerum.io/policy-type: infrastructure
spec:
  podSelector:
    matchLabels:
      app: rpc-proxy
  policyTypes:
    - Ingress
  ingress:
    - ports:
        - port: 8094
          protocol: TCP
      from:
        - namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: profiles
          podSelector:
            matchLabels:
              app: external-rest-api
        - namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: control-plane
          podSelector:
            matchLabels:
              app: control-api
---
# allow-sandbox-ui-egress-rpc-proxy: rpc-proxy → sandbox-ui workload pods on port 8080.
# Symmetric to allow-rpc-proxy-ingress-sandbox-ui in deploy/base/sandbox-ui/networkpolicies.yaml.
# Without this stanza, deny-all-rpc-proxy drops the SYN before it leaves rpc-proxy and the
# sandbox-ui iframe times out (502 from /sandbox-ui/view → ETIMEDOUT to the workload Service).
# Port is fixed at 8080: every sandbox-ui workload must expose its UI on 8080.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-sandbox-ui-egress-rpc-proxy
  namespace: rpc-proxy
  labels:
    # Static base manifest, not reconciled by HCC — keep this off the
    # `host-context-controller`/`wrc` managed-by values so the cluster-wide
    # admission policy lets CI's `kubectl apply -k` create it.
    clerum.io/managed-by: sandbox-ui
    clerum.io/policy-type: sandbox-ui-egress
spec:
  podSelector:
    matchLabels:
      app: rpc-proxy
  policyTypes:
    - Egress
  egress:
    - ports:
        - port: 8080
          protocol: TCP
      to:
        - namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: sandbox-ui
          podSelector:
            matchLabels:
              clerum.io/sandbox-ui: "true"