Skip to content

AgentPolicy

One AgentPolicy per group of agent pods. It sets their egress, models, token budget, MCP tools and kill switch. Short name: agp.

apiVersion: leash.simplyzee.dev/v1alpha1
kind: AgentPolicy
metadata:
name: claude-agent
namespace: agents
spec:
agentSelector:
matchLabels:
app: claude-agent
egress:
fqdns:
- matchName: api.github.com
ports: [443]
- matchPattern: "*.githubusercontent.com"
endpoints:
- namespace: vault
selector:
matchLabels:
app.kubernetes.io/name: vault
ports: [8200]
models:
allow: ["claude-sonnet-*"]
dailyTokenBudget: 2000000
mcp:
approvalTimeout: 2m
servers:
- name: github
denyTools: ["delete_*"]
requireApproval: ["merge_pull_request"]
frozen: false
onFreeze:
scaleToZero: true

Spec

Field What it does
agentSelector Labels of the agent pods. Required and can’t be empty, so a typo can’t select a whole namespace.
egress.fqdns[] Domain names, by matchName or matchPattern, with optional ports. Needs Cilium.
egress.endpoints[] In-cluster pods, by namespace and selector, with ports.
egress.cidrs[] IP ranges, by cidr, with except and ports.
egress.dns Which DNS server the pods may use, by namespace and matchLabels.
models.allow Model names the agents may call. * globs are allowed.
models.dailyTokenBudget Input plus output tokens per UTC day, shared by every pod the policy selects.
mcp.servers[] Per MCP server: name, and allowTools, denyTools and requireApproval, each accepting globs. denyTools wins, then requireApproval, then allowTools.
mcp.approvalTimeout How long a held call waits for a human, from 30s to 1h. Default 5m.
frozen The kill switch.
onFreeze.scaleToZero Also scale the agents’ Deployments and StatefulSets to zero while frozen.

Status

Field What it shows
phase Enforced, Frozen or Error.
backend cilium or kubernetes.
networkPolicy The name of the policy Leash generated.
usage Today’s tokens (day, inputTokens, outputTokens, totalTokens) and whether the budget is exhausted.
scaledDown Workloads the kill switch scaled to zero, with the replicas to restore.
frozenAt When the kill switch was last engaged.
conditions Ready, Degraded and EgressWidened. See Metrics and conditions.

Each agent pod must be selected by exactly one AgentPolicy. If two select the same pod, the gateway refuses its calls until you split the selectors.