CCloudSuccessTechworld with Randy
Field Guides / Securing AI Agents in Your Cluster
Field Guide · Intermediate to Advanced · 10-12 hours with labs

Securing 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.

Page previewPage previewPage previewPage preview
75
pages
12
hands-on labs
25
interview Q&As
15
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

  1. The mental modelp. 4
  2. Build a toy agent, then break itp. 12
  3. Tools, MCP and the agent supply chainp. 21
  4. Least privilege: giving the agent its own identityp. 28
  5. Sandboxing: containing code and shell executionp. 33
  6. Cutting the network leg: egress policyp. 38
  7. The hardened agent: guardrails in codep. 42
  8. Audit, tracing and detectionp. 47
  9. Red-teaming: making the testing a routinep. 50
  10. Incident response and governancep. 53
  11. Troubleshooting playbookp. 57
  12. Production checklist and design decisionsp. 59
  13. Interview questionsp. 62
  14. Cheat sheetp. 70
  15. 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.