Vault credentials
An AgentIdentity gives agents short-lived Vault tokens, scoped to the secrets they
need, that the AgentPolicy kill switch can cut off instantly.
For each identity Leash manages three Vault objects, all named
leash.<namespace>.<identity>:
| Object | Purpose |
|---|---|
| ACL policy | read on each path in spec.vault.secretPaths |
| Kubernetes auth role | Bound to the agent ServiceAccount and namespace. Tokens last spec.vault.ttl (default 15m) and can’t be renewed past it |
| Identity entity and alias | The entity the agents’ tokens belong to. Disabled while the linked AgentPolicy is frozen |
Disabling an entity makes Vault reject that entity’s tokens on their next request, so there’s no wait for TTLs to run out. Together with the network kill switch, freezing an agent cuts off both where it can connect and what it can authenticate as.
1. Set up the Kubernetes auth method
If you don’t already have one:
vault auth enable kubernetesvault write auth/kubernetes/config kubernetes_host=https://kubernetes.default.svc2. Give Leash its own Vault role
Leash logs in with its ServiceAccount (leash-controller-manager in leash-system)
and needs this policy:
# Manage Leash's own policies and rolespath "sys/policies/acl/leash.*" { capabilities = ["create", "read", "update", "delete"] }path "auth/kubernetes/role/leash.*" { capabilities = ["create", "read", "update", "delete"] }
# Find the auth mount accessor (needed to create entity aliases)path "sys/auth" { capabilities = ["read", "sudo"] }
# Entities: create, look up, enable/disable, deletepath "identity/lookup/entity" { capabilities = ["update"] }path "identity/entity" { capabilities = ["create", "update"] }path "identity/entity/name/leash.*" { capabilities = ["read"] }path "identity/entity/id/*" { capabilities = ["read", "update", "delete"] }path "identity/entity-alias" { capabilities = ["create", "update"] }vault policy write leash leash-operator.hclvault write auth/kubernetes/role/leash \ bound_service_account_names=leash-controller-manager \ bound_service_account_namespaces=leash-system \ token_policies=leash \ token_ttl=1hIf your agents use a different auth mount, change auth/kubernetes/ above to match.
Trust boundary. Leash can grant agents read access to any path except
sys/,auth/andidentity/, and can disable any entity. WithrevokeOnFreeze, it can also revoke leases under the prefixes you grant it. Treat whoever can createAgentIdentityobjects, and Leash itself, as Vault administrators for those paths. RestrictAgentIdentitycreation with RBAC.
3. Start Leash with Vault
args:- --vault-addr=https://vault.vault.svc:8200- --vault-role=leashTLS, namespaces and so on use the standard VAULT_CACERT, VAULT_NAMESPACE, etc.
environment variables. For local development, VAULT_TOKEN skips the login.
4. Create an identity
apiVersion: leash.simplyzee.dev/v1alpha1kind: AgentIdentitymetadata: name: claude-agent namespace: agentsspec: serviceAccountName: claude-agent policyRef: name: claude-agent vault: ttl: 15m secretPaths: - secret/data/agents/claude/github-token$ kubectl get aid -n agentsNAME PHASE SERVICEACCOUNT VAULT ROLE AGEclaude-agent Active claude-agent leash.agents.claude-agent 1m5. Log in from the agent
Run the agent pods as the ServiceAccount, then log in with the role from
status.vault.role:
vault write auth/kubernetes/login \ role=leash.agents.claude-agent \ jwt=@/var/run/secrets/kubernetes.io/serviceaccount/tokenVault Agent, the Vault CSI provider and Vault Secrets Operator all work with the
same role. If the agent’s egress is restricted by an AgentPolicy, allow Vault in
it, for example:
egress: endpoints: - namespace: vault selector: matchLabels: app.kubernetes.io/name: vault ports: [8200]Kill switch
kubectl -n agents patch agp claude-agent --type merge -p '{"spec":{"frozen":true}}'The AgentPolicy denies all egress, and every AgentIdentity that references it
disables its Vault entity. Both report Frozen. Unfreeze to restore both.
Revoking dynamic credentials
A disabled entity stops the agents’ Vault tokens at once. But dynamic
credentials the agents were already issued (a database password from
database/creds/..., cloud keys from aws/creds/...) live outside Vault and
stay valid until their lease expires. To kill those too, list their lease
prefixes:
spec: vault: secretPaths: - database/creds/claude-agent revokeOnFreeze: - database/creds/claude-agentOn freeze, Leash revokes every lease under each prefix (once per freeze;
status.leasesRevokedAt says when), and Vault deletes the database user or cloud
key behind each one. Until revocation succeeds the identity reports
Ready=False with reason RevokeFailed, and Leash retries.
-
Use roles dedicated to the agent. Revocation hits every lease under the prefix, whoever holds it.
-
Each prefix must be one of
secretPathsor under one, so an identity can only revoke credentials its own agents can read. Otherwise the identity reportsInvalidIdentityand Leash doesn’t touch Vault for it. -
Leash needs extra Vault rights, and
sudois involved, so grant only the prefixes you use:path "sys/leases/revoke-prefix/database/creds/claude-agent" { capabilities = ["update", "sudo"] }
Notes
- Existing entities. If an agent logged in before the identity existed, Vault
already made an entity for it. Leash adopts it (
status.vault.entityManaged: false) and, on deletion, re-enables it rather than deleting it. - Changing the ServiceAccount or auth mount removes the old role and entity and creates new ones.
- Leash without Vault. Identities with
spec.vaultreportReady=Falsewith reasonVaultNotConfigured. ServiceAccounts are still managed.