agentic-os/platform/security/network-policies.yaml

140 lines
4.0 KiB
YAML

# NetworkPolicies for the agentic-os platform.
# Default-deny all ingress/egress per namespace, then explicitly allow required flows.
# Apply via platform/security kustomization.
---
# ─── ai-core namespace ────────────────────────────────────────────────────────
# Allow ingress from agents and interface namespaces, deny everything else.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: ai-core-ingress
namespace: ai-core
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
ingress:
- from:
- namespaceSelector:
matchLabels:
agentic-os.io/ai-agent-namespace: "true"
- namespaceSelector:
matchLabels:
agentic-os.io/layer: "interface"
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: "argocd"
egress:
# Allow DNS
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
# Allow outbound to platform-data (Postgres, Redis, etc.)
- to:
- namespaceSelector:
matchLabels:
agentic-os.io/layer: "data"
# Allow outbound to tools-mcp
- to:
- namespaceSelector:
matchLabels:
agentic-os.io/layer: "mcp"
# Allow outbound to observability (metrics push)
- to:
- namespaceSelector:
matchLabels:
agentic-os.io/layer: "observability"
---
# ─── platform-data namespace ──────────────────────────────────────────────────
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: platform-data-ingress
namespace: platform-data
spec:
podSelector: {}
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
agentic-os.io/layer: "ai-core"
- namespaceSelector:
matchLabels:
agentic-os.io/ai-agent-namespace: "true"
- namespaceSelector:
matchLabels:
agentic-os.io/layer: "security"
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: "cnpg-system"
---
# ─── ai-agents-gumbo namespace ────────────────────────────────────────────────
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: gumbo-egress
namespace: ai-agents-gumbo
spec:
podSelector: {}
policyTypes:
- Egress
egress:
# DNS
- ports:
- port: 53
protocol: UDP
- port: 53
protocol: TCP
# LiteLLM in ai-core
- to:
- namespaceSelector:
matchLabels:
agentic-os.io/layer: "ai-core"
ports:
- port: 4000
# MCP filesystem
- to:
- namespaceSelector:
matchLabels:
agentic-os.io/layer: "mcp"
ports:
- port: 8080
# Postgres checkpoint DB in platform-data
- to:
- namespaceSelector:
matchLabels:
agentic-os.io/layer: "data"
ports:
- port: 5432
# Temporal frontend
- to:
- namespaceSelector:
matchLabels:
agentic-os.io/layer: "ai-core"
ports:
- port: 7233
---
# ─── tools-mcp namespace ──────────────────────────────────────────────────────
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: tools-mcp-ingress
namespace: tools-mcp
spec:
podSelector: {}
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
agentic-os.io/ai-agent-namespace: "true"
- namespaceSelector:
matchLabels:
agentic-os.io/layer: "interface"