Running AI agents on Kubernetes logopeterindia.net
Knowledge Hub

Running AI Agents on Kubernetes

How to deploy, secure and scale AI agents on Kubernetes: containerizing the agent, secrets and workload identity, resource limits and health checks, autoscaling, network egress control, sandboxing, GitOps delivery and observability. For Kubernetes-native agent runtimes such as kagent, see AI Agents on Kubernetes Clusters. Grouped by purpose, not ranked.

64 topics•8 categories•Updated November 2026

1. Start Here: From Laptop Script to Running Pod

4 entries

The path an agent takes from a script on a laptop to a supervised workload in a cluster. The usual order is: containerize the agent, keep its API key in a Secret, write a Deployment with health probes and resource limits, expose it with a Service, then restrict its network egress.

2. Containerize the Agent

7 entries

Turn the agent into a small, versioned, scanned image. Run as a non-root user, keep keys out of the image, and tag releases with a version or digest so you can say what is running and roll back.

3. Agent Frameworks and How They Deploy

7 entries

Most frameworks wrap an agent in a web server you can containerize. Pick a framework for your language and team, then follow its own deployment guide or package the server yourself.

4. Secrets, Configuration and Identity

12 entries

Keep keys out of images and give each agent only the identity it needs. Secrets are encoded, not encrypted, by default. Turn on encryption at rest, limit who can read them with RBAC, and prefer short-lived cloud identities over long-lived keys.

5. Resources, Health Checks, Scaling and Batch Agents

7 entries

Agents can fail in loops, so cap them and check them. Set requests and limits, add readiness and liveness probes, and scale on load or queue depth. Run scheduled or one-off agents as Jobs.

6. Networking and Egress Control

4 entries

The usual end of a prompt-injection attack is sending data somewhere it should not go. Start with default-deny egress and an allowlist. Plain NetworkPolicy works on IPs and ports, so naming allowed destinations needs a DNS-aware policy engine or an egress gateway.

7. Isolation, Sandboxing and Policy

10 entries

Assume the agent can be talked into misbehaving and limit what it can do. Layer controls: a restricted security context, a stronger runtime for untrusted code, admission policy, and runtime detection.

8. Delivery, Observability and Operations

7 entries

Ship agents through version control and watch what they do. Describe everything in reviewed manifests, deploy with GitOps, and collect logs, metrics and traces, because an agent's own log is not an audit trail.

9. Related Pages on This Site

6 entries

Where to go next after your first agent is running. Directories for Kubernetes-native agent runtimes, self-hosted models and wider agentic AI.

Frequently Asked Questions

Why run AI agents on Kubernetes?

An agent is a long-running workload that needs supervision. Kubernetes restarts it when it fails, caps its CPU and memory, injects credentials at runtime instead of baking them into code, and describes the setup in reviewable manifests. It also lets you control the agent's network access and identity from outside the agent, where a prompt cannot change the rules.

How is deploying an agent different from deploying a web service?

The mechanics are the same: an agent is usually a process that serves HTTP. The difference is risk. A service follows its code, while an agent follows a model whose next action depends on whatever is in its context, and it often holds credentials and can act. Steps that are optional hardening for a normal service, such as secrets handling, resource limits and egress control, are essential for agents.

What are the basic steps to deploy an agent?

Containerize the agent, create a Kubernetes Secret for its API key, write a Deployment with resource requests and limits and health probes, expose it with a Service, and add a default-deny NetworkPolicy with only the egress it needs. You can practise all of this on a local kind cluster.

Where should I store an agent's API keys?

Not in the image or the repository. Use a Kubernetes Secret at minimum, with encryption at rest and RBAC limiting who can read it. For production, sync secrets from a store using External Secrets Operator, Vault Secrets Operator or a cloud secret manager, and prefer workload identity so pods get short-lived credentials instead of long-lived keys.

How do I stop an agent from sending data to the wrong place?

Use a default-deny egress NetworkPolicy and allow only what the agent needs, such as DNS and HTTPS. Plain NetworkPolicy matches IPs and ports, so it cannot name allowed domains. For that, use a DNS-aware policy engine such as Calico or Cilium, or route agent traffic through an egress gateway.

Do I need a GPU to run an agent on Kubernetes?

No. An agent is usually orchestration code that calls a model over an API, so ordinary nodes are enough. You only need GPU nodes if you host the model yourself, which is a separate project covered by model-serving tools.

How do I scale AI agents?

Set CPU and memory requests so the scheduler can place pods, then use the Horizontal Pod Autoscaler on resource or custom metrics, or KEDA to scale on queue length or events. Run scheduled or one-off agent tasks as Jobs or CronJobs, and put limits on each pod so a looping agent cannot starve a node.

How do I run untrusted agent code safely?

Combine controls: run as non-root with a restricted security context, apply Pod Security Standards, add admission policy with Kyverno or OPA Gatekeeper, and run code the agent generates in an isolated sandbox such as the Kubernetes Agent Sandbox project, gVisor or Kata Containers. Turn off automatic service account token mounting when the agent does not call the Kubernetes API.

How is this page different from the page on AI agents on Kubernetes clusters?

This page is about deploying and securing your own agent as a workload. AI Agents on Kubernetes Clusters covers Kubernetes-native agent runtimes such as kagent, agents that operate the cluster, Kubernetes MCP servers and model serving.

Where does this guide come from?

It was inspired by Tigera's beginner guide to AI agents on Kubernetes, published in September 2026, and by the official Kubernetes, security and framework documentation linked here. Links were checked in November 2026, and sites that block automated checks may need a manual click. This is a resource list, not engineering advice.