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.
ANTHROPIC_BASE_URL=http://leash-gateway.leash-system.svc:8080/anthropicANTHROPIC_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/v1alpha1kind: AgentPolicymetadata: name: claude-agent namespace: agentsspec: 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
kubectl -n agents get agentpolicy claude-agentkubectl leash status -n agentsPHASE should say Enforced. If it says Error, kubectl describe agentpolicy claude-agent shows the Ready condition with the reason.
Next
- Give the agent Vault credentials with an AgentIdentity.
- Try the kill switch.
- Send approvals to Slack.