How it works
This guide sets up an EKS Auto Mode cluster where each agent runs in its own Nitro Sandbox and can only connect to the proxy: Your orchestrator is a program that starts each agent run, such as a script or a CI job. For each agent run, it does the following:- Creates a session for the run
- Starts the agent’s pod with the session token
- Revokes the session and deletes the pod when the agent finishes
Prerequisites
- The Admin role in an Agent Vault project
- An access bundle with a service for each key the agent uses, including its model provider’s key, such as Anthropic for Claude Code (see the quickstart)
- An AWS account on a paid plan where you can create EKS clusters (on the free plan, AWS only launches instance types that can’t run Nitro Sandboxes)
- The AWS CLI,
eksctl,kubectl, andjq curlandopensslon the machine where you run the script in Step 7, if you use the Bash version
Step 1: Create the cluster
Create an EKS Auto Mode cluster
Nitro Sandboxes need EKS Auto Mode and Kubernetes 1.36 or later. Create a cluster witheksctl, replacing <cluster-name> and <region>:
--version, because eksctl creates an older Kubernetes version by default. To use a cluster you already have, check that it runs Auto Mode and Kubernetes 1.36 or later.
Turn on network policies
EKS accepts network policies without enforcing them until you turn on its network policy controller. Save this manifest asenable-network-policy.yaml and apply it to your cluster:
Create a node pool for agents
A node loads a new pod’s network policies a moment after the pod starts. Auto Mode’s nodes allow all traffic until then, so an agent’s first requests can skip the proxy. To close that gap, run agent pods on their own nodes, which deny all traffic until the policies load. Create a NodeClass namedagents that copies the cluster’s default NodeClass and sets networkPolicy to DefaultDeny:
agents-nodepool.yaml and apply it to your cluster. It launches nodes for agent pods from the agents NodeClass:
Find the cluster’s DNS address
Auto Mode runs a DNS server on each node at a fixed address. The network policies in Steps 3 and 4 allow DNS lookups only to that address. To find it, get the cluster’s service address range:.10 address in that range. For example, if the range is 10.100.0.0/16, the DNS address is 10.100.0.10. Later steps call this address <dns-ip>.
Step 2: Set up Agent Vault
Create a proxy
1
In the Agent Vault project that holds your access bundle, go to Proxies and select Create Proxy. An agent can only use a proxy in the same project as its session.
2
Enter a Name, such as
sandboxes.3
Select Create, then copy the proxy token from the Proxy Token dialog. Infisical shows the token only once.
Create a machine identity for your code
Your code creates a session for each run as a machine identity. Give the machine identity the Member role and access to only your access bundle.1
In your Agent Vault project, go to Access Control > Machine Identities and select Add Machine Identity.
2
On the Create New tab, enter a Name, choose Member in Role, then select Create. Infisical creates the machine identity with Universal Auth and opens its page.

3
On the machine identity’s page, select Universal Auth under Authentication. Copy the Client ID, then select Add Client Secret and copy the client secret.
4
Go to Access Bundles and open the access bundle the agent uses. Select Options > Manage Access. Under No Access, select Grant Access next to the machine identity.
Step 3: Deploy the proxy
Save this manifest asagent-vault-proxy.yaml, replace <dns-ip> with the address from Step 1, and apply it to your cluster. It creates the agent-vault namespace and runs the proxy in it:
- Instance URL: if you use EU Cloud or self-host Infisical, replace
https://app.infisical.comwithhttps://eu.infisical.comor the URL of your self-hosted instance - Egress: the proxy can only reach public addresses on ports 443 and 80, so add an egress rule for anything else, such as a self-hosted Infisical instance in your VPC or a service at
api.example.com:8443
Store the proxy token
Store the proxy token in a Secret namedagent-vault-proxy in the agent-vault namespace, replacing <proxy-token>:
Step 4: Create the agents namespace
Save this manifest asagents-namespace.yaml, replace <dns-ip>, and apply it to your cluster. It creates the agents namespace and blocks all traffic to and from its pods, except DNS lookups and connections to the proxy:
The
restricted label on the namespace turns on Kubernetes’ strictest Pod Security Standard, so Kubernetes rejects any pod in the namespace that runs as root, keeps Linux capabilities, or allows privilege escalation. The agent pod in Step 7 passes these checks. If you change its securityContext, keep those settings, or Kubernetes won’t create the pod.Step 5: Set up your orchestrator
Your orchestrator starts each agent run. It can be a script, a CI pipeline, a job runner, or a Kubernetes controller. Run it outside theagents namespace, so agent pods can’t reach it.
Give your orchestrator the machine identity’s credentials
Set the client ID and client secret of the machine identity from Step 2 in the environment where your orchestrator runs:Allow the orchestrator to start agent pods
Save this manifest asagent-orchestrator-role.yaml and apply it to your cluster, then bind the role to the service account or user that your orchestrator runs as. The role only applies in the agents namespace:
Step 6: Build the agent’s image
Build an image from this Dockerfile and push it to a registry your cluster can pull from, such as Amazon ECR:- The
nodeuser: therestrictedPod Security Standard refuses pods that run as root, and Claude Code won’t skip its permission prompts as root, so the agent runs as the image’snodeuser - The entrypoint:
infisical agent-vault runfetches the proxy’s certificate, sets the proxy and certificate trust variables, and starts the agent’s command after-- curl: the checks in Step 8 run it in the agent’s pod
Step 7: Run an agent
Define the agent’s pod
Save this manifest asagent-pod.yaml. The script in the next step starts a pod from it for each run. The runtimeClassName field runs the pod in its own Nitro Sandbox:
agent-vault, as this pod does for Claude Code’s ANTHROPIC_API_KEY.
Start the agent with a new session
Each of these scripts is a minimal orchestrator that runs one agent with its own session. Run it in the folder withagent-pod.yaml. Replace <project-id> with the ID of your Agent Vault project (find the project ID), <access-bundle-name> with your access bundle’s name, and https://app.infisical.com with your instance’s URL if you don’t use US Cloud:
- Bash
- Python
- TypeScript
Save this script as
run-agent.sh and run it with bash run-agent.sh:- Log in with the Universal Auth Login endpoint
- Create a session with the Create session endpoint
- Store the session token in a Secret, and start the agent’s pod from
agent-pod.yaml - When the agent exits, or if the script fails or is canceled, revoke the session with the Revoke session endpoint
- Delete the pod and its Secret
Step 8: Verify it works
A short task can finish before you can check its pod, so start a test run whose pod waits for 10 minutes instead of running the agent:- In
agent-pod.yaml, replace theargslist with["sleep", "600"]. The image’s entrypoint still starts the command withinfisical agent-vault run, so the pod gets its session the same way an agent does. - Run your script from Step 7.
<run-id> with the run ID the script printed, and <api-host> with a host in your access bundle:
2. A pod without a sandbox sees every CPU on its node:
eks run <run-id>. It’s Active while the pod runs. View the session’s logs to see the requests from your checks.
When you’re done, press Ctrl+C in the script’s terminal. The script revokes the session and deletes the pod, and the session changes to Revoked. Then put the agent’s args back in agent-pod.yaml.
Your agents now run in Nitro Sandboxes that contain only a session token, can only connect to the proxy, and lose access when the session is revoked.
Security considerations
- Hosts through the proxy: agent pods can only connect to the proxy and DNS, but under the default traffic policy, Any host, the proxy forwards their requests to any host its network policy allows (to allow only the hosts that services in the session’s access bundle cover, set the traffic policy to Service hosts only and add any other hosts the agents need to the proxy’s exceptions)
- DNS: agent pods still need DNS to find the proxy, and DNS lookups can carry data out of the pod, so a network policy doesn’t close every channel
- The node: in isolated mode, the node can read the agent pod’s files and its traffic to the proxy, so limit who can access your nodes
- APIs that echo requests: if an endpoint returns the request’s headers in its response, such as an echo or debug endpoint, the response exposes the credential that the proxy attached, so limit each service to the methods and paths the agent needs
- Revoking a session: the proxy stops attaching credentials for a revoked session within one poll interval
- Several teams: a proxy’s traffic policy and exceptions apply to every agent that uses it, so give each team or customer its own proxy and agents namespace if they need different access
- Unsupported connections: WebSocket connections and clients that only speak HTTP/2, such as gRPC clients, fail through the proxy (see Supported connections)
FAQ
Why isolated-sandbox and not confidential-sandbox?
Why isolated-sandbox and not confidential-sandbox?
A confidential sandbox only starts a pod that matches a policy you generate from the pod spec in advance. That policy includes the container’s arguments. The agent’s prompt is an argument and changes on every run, so you’d need a new policy for every run. A confidential sandbox also refuses
kubectl exec, which the checks in Step 8 use.Confidential mode protects a pod’s data from the node that runs it. If you need that protection, see Run a pod in confidential mode.Can I use managed node groups instead of Auto Mode?
Can I use managed node groups instead of Auto Mode?
Yes, but you prepare the nodes yourself. The nodes need:
- An AMI with the Nitro Sandbox runtime (create a Nitro Sandbox AMI)
- An instance type that supports Nitro Sandboxes
- Nitro Enclaves turned on in the node group’s launch template
k8s-app: kube-dns in kube-system. Allow DNS to those pods in both network policies instead of to <dns-ip>.Node groups don’t use the agents NodeClass and NodePool, so remove nodeSelector and tolerations from the agent pod. The RuntimeClass already schedules the pod only on nodes that can run Nitro Sandboxes. To block agent pods’ traffic until their policies load, set the VPC CNI’s network policy mode to strict. Strict mode applies to every pod in the cluster, so every pod then needs a network policy, including CoreDNS.Why does the proxy run in its own namespace?
Why does the proxy run in its own namespace?
A network policy applies to a whole pod, and every container in a pod shares the pod’s Nitro Sandbox. A proxy in the agent’s pod would need a route to the internet that the agent could also use, and its proxy token would sit beside the agent.
Troubleshooting
Agent pods stay Pending
Agent pods stay Pending
Auto Mode can’t launch a node for a Nitro Sandbox in these cases:
- The
agentsNodeClass or NodePool from Step 1 doesn’t exist - The cluster runs a Kubernetes version older than 1.36
- The NodePool’s NodeClass uses FIPS AMIs
- The NodePool only allows GPU or Neuron instance types
The agent reaches the internet without going through the proxy
The agent reaches the internet without going through the proxy
The network policy controller is off, so EKS accepts the network policies but nothing enforces them. Apply the ConfigMap in Turn on network policies.
Agent or proxy pods can't resolve hostnames
Agent or proxy pods can't resolve hostnames
The network policies allow DNS only to
<dns-ip>. Check that <dns-ip> is the .10 address of your cluster’s service address range (find the cluster’s DNS address). Until DNS works, the proxy never becomes ready, and infisical agent-vault run can’t find the proxy.Requests through the proxy time out
Requests through the proxy time out
The proxy’s network policy blocks the host or port. It allows only ports 443 and 80 on public addresses, so add an egress rule to the policy in Step 3 for a private address or another port.
Requests fail with a certificate error
Requests fail with a certificate error
The agent’s HTTP client doesn’t trust the proxy’s certificate. Check that the agent starts through
infisical agent-vault run, as the image’s entrypoint does, and that its HTTP client reads one of the certificate trust variables.The proxy returns 403 with "host blocked by policy"
The proxy returns 403 with "host blocked by policy"
The proxy’s traffic policy blocks hosts that no service in the access bundle covers. Add a service for the host, or add the host to the proxy’s exceptions.
Next steps
Session logs
Record every request an agent makes during a session.
Proxies
Change the proxy’s traffic policy, exceptions, and poll interval.