Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

address review bot feedback on network policy ports, DNS, exec permissions, and Agent Sandbox

Jake Hulbergaeef5a9a33de
diff --git a/docs/documentation/platform/agent-vault/guides/kubernetes-setup.mdx b/docs/documentation/platform/agent-vault/guides/kubernetes-setup.mdx
index 112cc5eaa5..7024b3f855 100644
--- a/docs/documentation/platform/agent-vault/guides/kubernetes-setup.mdx
+++ b/docs/documentation/platform/agent-vault/guides/kubernetes-setup.mdx
@@ -147,7 +147,12 @@ spec:
- port: 80
```
-If you self-host Infisical on a private address, or an API the agent calls is on a private address, add an egress rule for that address to the network policy.
+The proxy's network policy allows only ports 443 and 80 on public addresses. Add an egress rule for any other host or port the proxy has to reach:
+
+- **Private addresses:** if you self-host Infisical on a private address, or an API the agent calls is on one, add that address
+- **Other ports:** if a service or exception uses a port other than 443 or 80, such as `api.example.com:8443`, add that port
+
+Both network policies in this guide allow DNS only to pods labeled `k8s-app: kube-dns` in `kube-system`. If your cluster's DNS runs elsewhere, such as a node-local DNS cache at `169.254.20.10` or the `openshift-dns` namespace on OpenShift, change the DNS rule in both policies to match it.
Store the proxy token in a Secret named `agent-vault-proxy` in the `agent-vault` namespace, under the key `INFISICAL_AGENT_VAULT_PROXY_TOKEN`. Create it with the tool you already use to manage Kubernetes secrets, such as the [Infisical Kubernetes Operator](/integrations/platforms/kubernetes/overview). The proxy's pods start once the Secret exists.
@@ -157,7 +162,7 @@ On the **Proxies** page in Agent Vault, the proxy's status changes to **Healthy*
Save this manifest as `agents-namespace.yaml` 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:
-```yaml
+```yaml expandable
apiVersion: v1
kind: Namespace
metadata:
@@ -258,6 +263,7 @@ spec:
activeDeadlineSeconds: 1800
securityContext:
runAsNonRoot: true
+ # Match the user ID that your agent's image runs as.
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
@@ -353,7 +359,7 @@ The script calls [the endpoint that creates a session](/api-reference/endpoints/
## Step 6: Verify it works
-While an agent pod runs, check that its requests go through the proxy and that no other traffic leaves the pod. These commands need `curl` in the agent's image. Replace `<run-id>` with the run ID that the script printed, and `<api-host>` with a host that a service in the access bundle covers:
+While an agent pod runs, check that its requests go through the proxy and that no other traffic leaves the pod. These commands need `curl` in the agent's image, and `kubectl exec` needs the `create` permission on `pods/exec`, which the role in Step 4 doesn't grant, so run them as a cluster admin. Replace `<run-id>` with the run ID that the script printed, and `<api-host>` with a host that a service in the access bundle covers:
```bash
# Through the proxy: returns the API's own status code, such as 200 or 401
@@ -386,6 +392,12 @@ In Agent Vault, go to **Sessions** and select **All Sessions**. Find the session
## Troubleshooting
<AccordionGroup>
+ <Accordion title="Agent or proxy pods can't resolve hostnames">
+ The network policies allow DNS only to pods labeled `k8s-app: kube-dns` in `kube-system`. If your cluster's DNS runs elsewhere, such as a node-local DNS cache or OpenShift's `openshift-dns`, change the DNS rule in both network policies to match it. Until then, the proxy never becomes ready, and `infisical agent-vault run` can't find the proxy.
+ </Accordion>
+ <Accordion title="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 for a private address or another port, as [Step 2](#step-2-deploy-the-proxy) describes.
+ </Accordion>
<Accordion title="The agent reaches the internet without going through the proxy">
Your cluster's network plugin doesn't enforce network policies, so Kubernetes accepts the policies but nothing applies them. Flannel, the default network plugin in k3s, is one example. Install a network plugin that enforces policies, such as Cilium or Calico.
</Accordion>
diff --git a/docs/documentation/platform/agent-vault/guides/kubernetes.mdx b/docs/documentation/platform/agent-vault/guides/kubernetes.mdx
index 4a2874281b..e165f4a153 100644
--- a/docs/documentation/platform/agent-vault/guides/kubernetes.mdx
+++ b/docs/documentation/platform/agent-vault/guides/kubernetes.mdx
@@ -60,7 +60,10 @@ For each agent run, your orchestrator does the following:
The machine identity can create sessions for any access bundle it has access to. gVisor and Kata isolate a pod from the node, not one container from another, so even a separate container in the agent's pod could expose it. An agent pod gets only a session token, which you can revoke and which expires.
</Accordion>
<Accordion title="Can I use Agent Sandbox instead of writing pod manifests?">
- Yes. [Agent Sandbox](https://github.com/kubernetes-sigs/agent-sandbox) is an official Kubernetes project with custom resources for agent sandboxes, such as `SandboxTemplate`, `SandboxClaim`, and `SandboxWarmPool`. Its sandboxes are pods, so the same setup applies: put the agent pod settings from the [setup guide](/documentation/platform/agent-vault/guides/kubernetes-setup#define-the-agents-pod) in a `SandboxTemplate` in the agents namespace, and the namespace's network policy limits each sandbox to the proxy. Your orchestrator still creates a session for each sandbox and gives it the session token.
+ Yes. [Agent Sandbox](https://github.com/kubernetes-sigs/agent-sandbox) is an official Kubernetes project with custom resources for agent sandboxes, such as `SandboxTemplate`, `SandboxClaim`, and `SandboxWarmPool`. Its sandboxes are pods, so the proxy and the agents namespace work the same way, with these differences:
+
+ - **Session tokens:** each sandbox still needs its own session, but a `SandboxTemplate` serves every claim, so it can't name a per-run Secret. Your orchestrator has to deliver each sandbox's session token after the claim binds. Pods in a `SandboxWarmPool` start before any session exists.
+ - **Network policies:** if the Agent Sandbox controller creates its own network policy for a template, that policy can allow traffic that the agents namespace's policy blocks. Turn it off or limit it to the proxy, then check that a sandbox can't reach the internet directly (see [Verify it works](/documentation/platform/agent-vault/guides/kubernetes-setup#step-6-verify-it-works)).
</Accordion>
</AccordionGroup>