Skip to content

Leash your first agent

1. Label the agent’s pods

An AgentPolicy selects pods by label. Give your agent’s Deployment a label of its own, for example app: claude-agent. Each agent pod must be selected by exactly one AgentPolicy.

2. Send model calls through the gateway

Set the SDK’s base URL to the gateway, and give it a placeholder key. SDKs insist on having one; the gateway replaces it with the real key.

Terminal window
ANTHROPIC_BASE_URL=http://leash-gateway.leash-system.svc:8080/anthropic
ANTHROPIC_API_KEY=placeholder
Upstream Agent setting
Anthropic ANTHROPIC_BASE_URL=http://leash-gateway.leash-system.svc:8080/anthropic
OpenAI OPENAI_BASE_URL=http://leash-gateway.leash-system.svc:8080/openai/v1
MCP server github http://leash-gateway.leash-system.svc:8080/mcp/github (Streamable HTTP)

3. Write the policy

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]
models:
allow: ["claude-sonnet-*", "claude-haiku-*"]
dailyTokenBudget: 2000000
mcp:
approvalTimeout: 2m
servers:
- name: github
denyTools: ["delete_*"]
requireApproval: ["merge_pull_request"]

Egress to the gateway is added for you whenever a policy sets models or mcp. You only list what the agent reaches directly.

4. Check it

Terminal window
kubectl -n agents get agentpolicy claude-agent
kubectl leash status -n agents

PHASE should say Enforced. If it says Error, kubectl describe agentpolicy claude-agent shows the Ready condition with the reason.

Next