Field Guides / Securing AI Agents in Your Cluster
Field Guide · Intermediate to Advanced · 10-12 hours with labsSecuring AI Agents in Your Cluster
Harden a tool-using Kubernetes agent against prompt injection with least privilege, sandboxing, egress lockdown, audit and a containment drill.




75
pages
pages
12
hands-on labs
hands-on labs
25
interview Q&As
interview Q&As
15
chapters
chapters
This is for you if
- You have to approve or secure an AI agent that touches your cluster
- You built an agent and want to pass the security review
- You run Kubernetes and know RBAC, NetworkPolicy and kubectl
- You are interviewing for platform, SRE or AI-infrastructure roles
What's inside
- A toy Python agent on Ollama you attack and then harden, layer by layer
- The lethal trifecta and the OWASP LLM 2025 and Agentic 2026 threat models
- Direct and indirect prompt injection demos against your own lab agent
- A tool allowlist, a lockfile that diffs definitions, and per-tool credentials
- A least-privilege ServiceAccount proven with a kubectl auth can-i matrix
- Hardened pods enforced by a ValidatingAdmissionPolicy, plus gVisor
- Default-deny egress that blocks the cloud metadata endpoint
- Guardrails in code: argument validation, redaction, approval gates, budgets
- A tool-call audit trail correlated with the Kubernetes audit log
- A red-team harness that measures attack success rate, and a 60-second kill switch
After this guide you can
- Threat-model an agent with the trifecta and the OWASP agentic top ten
- Scope an agent's identity, tools and network so a fooled model does little
- Enforce isolation and egress with admission policy and NetworkPolicy
- Build guardrails, budgets and an audit trail that survive a compromise
- Measure your defenses with a red-team harness and drill incident containment
- Answer the agent-security questions now standard in platform interviews
Contents
- The mental modelp. 4
- Build a toy agent, then break itp. 12
- Tools, MCP and the agent supply chainp. 21
- Least privilege: giving the agent its own identityp. 28
- Sandboxing: containing code and shell executionp. 33
- Cutting the network leg: egress policyp. 38
- The hardened agent: guardrails in codep. 42
- Audit, tracing and detectionp. 47
- Red-teaming: making the testing a routinep. 50
- Incident response and governancep. 53
- Troubleshooting playbookp. 57
- Production checklist and design decisionsp. 59
- Interview questionsp. 62
- Cheat sheetp. 70
- 30-day practice planp. 73
Written by Randy, a Senior Platform Engineer & SRE who runs production platforms on AWS, GCP and Azure. Companion to the Techworld with Randy episode Securing AI Agents in Your Cluster.