How Leash works
Leash is two components and four resources. The operator turns policies into network rules and Vault roles. The gateway checks every model and MCP call.
The operator
- Turns each
AgentPolicyinto a CiliumNetworkPolicy, or a standard NetworkPolicy where Cilium isn’t installed. - Creates a Vault policy, Kubernetes auth role and entity for each
AgentIdentity. - Runs the kill switch: denies egress, disables Vault entities, and optionally scales agents to zero and revokes their dynamic credentials.
- Completes each agent pod’s
AgentRunwhen the pod goes, and deletes it later. - Flags other network policies that widen an agent’s egress, and pods that use an identity without its guardrails.
The gateway
- Identifies the caller by its pod IP and the one AgentPolicy that selects it.
- Checks the model against the allowlist and the day’s token budget, then forwards the call with the real provider key.
- Filters MCP tool lists, refuses denied tools and holds the ones that need a
human, as
ToolApprovals. - Meters tokens, and writes AgentRuns, audit lines and Prometheus metrics.
- Runs two replicas by default. Budgets and AgentRuns are shared through the API server, so any replica can serve any agent.
The operator locks agent egress down to the gateway and whatever the policy lists, so the gateway is the only way to a model provider. See The gateway for why it’s central rather than a sidecar.
The resources
| Resource | What it is | Written by |
|---|---|---|
AgentPolicy |
What a group of agent pods may reach, use and call | You |
AgentIdentity |
Vault access for an agent’s ServiceAccount | You |
ToolApproval |
A held tool call waiting for a human | The gateway |
AgentRun |
What one agent pod did | The gateway, completed by the operator |
Network backends
The operator uses Cilium when its CRDs are installed, and standard
NetworkPolicy otherwise. Force one with --network-backend (auto, cilium or
kubernetes), or controller.networkBackend in the chart. Each policy’s
status.backend shows which one is in use.
| Cilium | NetworkPolicy fallback | |
|---|---|---|
Rules by domain name (fqdns) |
Yes, with DNS limited to the allowed names | No: left out, so they fail closed, and the policy reports Degraded |
| Endpoints and CIDRs | Yes | Yes |
| Kill switch overrides other policies | Yes (egressDeny) |
No: other policies that allow egress still apply |