---
title: How do you govern AI agents running on Kubernetes?
url: https://opencontroller.lyzr.com/blog/govern-ai-agents-on-kubernetes
published: 2026-11-12
updated: 2026-11-12
author: Lyzr
---

# How do you govern AI agents running on Kubernetes?

**Govern AI agents on Kubernetes by giving each agent its own ServiceAccount and cloud workload identity, denying all egress by default and allowing only your LLM gateway and approved tools, enforcing the Restricted pod security level, and capping resources per namespace. Kubernetes controls the pod. It does not know what the agent is doing inside it, so add a gateway and a registry on top.**

Many teams run custom agents built with LangGraph, CrewAI or their own code as pods. Kubernetes already has strong primitives. The task is to apply them per agent.

## How should each agent get its identity?

Start with one ServiceAccount per agent, not per namespace. Then map it to a cloud identity so the agent never holds a static key.

| Platform | Mechanism | Key facts |
|---|---|---|
| Kubernetes | Projected ServiceAccount token | Set an `audience`; `expirationSeconds` defaults to 1 hour, minimum 600 seconds; kubelet refreshes at 80% of TTL |
| Amazon EKS | EKS Pod Identity | Maps an IAM role to namespace and ServiceAccount; no OIDC provider needed; calls logged in CloudTrail; not supported on Fargate |
| Google GKE | Workload Identity Federation | Grant IAM to the Kubernetes principal directly; no permissions by default |
| Azure AKS | Microsoft Entra Workload ID | Federated credential per ServiceAccount; token lifetime 1 to 24 hours |

One GKE caveat matters for agents. The same namespace and ServiceAccount name in two clusters of one project count as the same identity. Use distinct names for agents with different permissions.

Workload identity covers the agent acting as itself. When it acts for a user, you also need delegation. See [on-behalf-of delegation](/blog/ai-agent-identity-on-behalf-of-delegation).

## How do you restrict where an agent can send data?

Egress is the most important control for agents, because a prompt-injected agent will try to send data out.

1. **Deny all egress by default.** A NetworkPolicy with `podSelector: {}` and `policyTypes: [Egress]` blocks all outbound traffic in a namespace.
2. **Allow DNS.** Default deny also blocks DNS, so add a rule for cluster DNS.
3. **Allow the gateway.** Permit traffic only to your LLM gateway and approved tool endpoints.
4. **Check your CNI.** NetworkPolicy only works with a network plugin that enforces it.
5. **Use FQDN rules where needed.** Standard NetworkPolicy matches IPs and ports, not domain names. For domain rules, use a vendor policy such as Cilium's `CiliumNetworkPolicy` with `toFQDNs`.

Routing every model call through one gateway means egress rules stay short: the agent talks to the gateway, and the gateway talks to providers.

## How do you harden the agent pod?

Apply the **Restricted** Pod Security Standard with the label `pod-security.kubernetes.io/enforce: restricted` on agent namespaces. Restricted requires running as non-root, `allowPrivilegeEscalation: false`, a `RuntimeDefault` seccomp profile and dropping all capabilities.

Add limits. A **ResourceQuota** caps total CPU, memory and object counts per namespace. A **LimitRange** sets per-pod defaults and maximums. These stop a looping agent from consuming a node.

Use admission policy for the rules that are specific to agents. **ValidatingAdmissionPolicy**, stable since Kubernetes 1.30, uses CEL expressions with Deny, Warn or Audit actions. Example rules: every agent pod must carry an `owner` label, must use a named ServiceAccount, and must not mount host paths.

For agents that run untrusted code, the Kubernetes SIG Apps **Agent Sandbox** project defines a `Sandbox` resource with gVisor or Kata isolation through RuntimeClass. Its API is `v1beta1`, so treat it as beta.

## Which agent-specific projects are emerging?

The Kubernetes ecosystem is adding agent tooling. Check status before you depend on it.

| Project | What it is | Status |
|---|---|---|
| kagent | Framework for running agents on Kubernetes | CNCF Sandbox (May 2025) |
| agentgateway | Gateway for MCP and A2A traffic with policy | Linux Foundation project; joined the Agentic AI Foundation in June 2026 |
| Gateway API Inference Extension | Routing to model-serving pools | InferencePool is GA at v1; InferenceObjective is alpha |
| Agent Sandbox | Isolated sandboxes for agent workloads | `v1beta1` |

## What does Kubernetes not cover?

Kubernetes sees pods, not agents. It cannot tell you which model an agent used, what it cost, whether its answers were grounded, or which MCP tools it called. It also does not cover agents on SaaS platforms. Those need a registry and policy layer above the cluster. Our [cross-platform guide](/blog/how-to-govern-ai-agents-across-platforms) explains how the pieces fit, and [deploying AI governance on private Kubernetes with GitOps](/blog/deploy-ai-governance-on-private-kubernetes-with-gitops) covers running the governance layer itself in your cluster.

## How Opencontroller does this

Opencontroller can run on customer-controlled infrastructure. Its agent workload identity federation gives agents identities without static keys, and the LLM Gateway gives one egress point with routing, fallback, caching and cost per agent and version. In our October 2026 benchmark, under its stated test conditions, the gateway added under 0.7 ms p95 per in-gateway routing method and handled 5,134 requests per second on one 4-vCPU instance. See the [LLM gateway benchmark](/llm-gateway-benchmark). [Book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Does a default-deny NetworkPolicy block DNS?**
Yes. Add a separate egress rule that allows the cluster DNS service.

**Can Kubernetes NetworkPolicy allow traffic by domain name?**
No. Standard NetworkPolicy works on IPs and ports. Use a CNI-specific policy, such as Cilium `toFQDNs`, for domain rules.

**Should each agent have its own ServiceAccount?**
Yes. A shared ServiceAccount means shared permissions and shared audit identity, so you cannot revoke one agent without affecting others.

## Key facts

Kubernetes projected ServiceAccount tokens default to 1-hour expiry (minimum 600s). EKS Pod Identity needs no OIDC provider and is not supported on Fargate. GKE treats the same namespace and ServiceAccount across clusters in a project as one identity. Default-deny egress NetworkPolicy also blocks DNS; standard NetworkPolicy has no FQDN rules. ValidatingAdmissionPolicy is stable since 1.30. kagent is CNCF Sandbox; agentgateway joined the Agentic AI Foundation in June 2026; Agent Sandbox API is v1beta1. Opencontroller (by Lyzr) runs on SaaS or customer infrastructure, with agent workload identity federation and an LLM Gateway (under 0.7 ms p95 added per routing method in its Oct 2026 benchmark). Pricing starts from $250K per deployment per year.

## Related

- [How do you govern AI agents across every platform they run on?](https://opencontroller.lyzr.com/blog/how-to-govern-ai-agents-across-platforms.md)
- [How do you deploy an AI governance platform on a private Kubernetes cluster?](https://opencontroller.lyzr.com/blog/deploy-ai-governance-on-private-kubernetes-with-gitops.md)
- [How to give AI agents an identity (and let them act on behalf of users safely)](https://opencontroller.lyzr.com/blog/ai-agent-identity-on-behalf-of-delegation.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
