OpsCanary
kubernetessecurityPractitioner

Mastering Isolation and Security in Kubernetes: Scale with Confidence

5 min read CNCF BlogOct 26, 2026Reviewed for accuracy
Share
Practitioner — Hands-on experience recommended

In the world of Kubernetes, ensuring isolation and security is paramount. As applications scale, the risk of untrusted code compromising your infrastructure increases. This is where effective agent sandboxing comes into play. It ensures that untrusted agent code cannot escape into the host environment, protecting your underlying infrastructure from potential threats.

Kubernetes achieves this through a combination of software-level and hardware-level isolation. Software-level isolation uses gVisor, which runs isolated workloads in user space with a dedicated app kernel called Sentry. This kernel intercepts and handles system calls, providing a secure environment for your applications. On the other hand, microVMs offer hardware-level isolation by running guest OS/VMs directly on physical CPU cores using virtualization extensions. This dual approach allows you to run agents securely within Pods, leveraging the Agent Substrate, which is essentially a pool of Workers that host these agents.

In production, you need to be aware of the configuration parameters that can impact your deployment. For instance, the substrateWorkerPool.create setting in the Helm Chart is crucial for creating a WorkerPool, with a default value of true. When deploying your agents, you can use the provided YAML snippet to set up your Harness and AgentTemplate efficiently. Remember, while Kubernetes provides strong isolation mechanisms, always consider the specific needs of your application and the potential overhead introduced by these security measures.

Key takeaways

  • →Utilize gVisor for software-level isolation to enhance security.
  • →Leverage microVMs for hardware-level isolation when necessary.
  • →Configure the `substrateWorkerPool.create` parameter to manage WorkerPool creation.
  • →Deploy agents using the provided YAML snippet for streamlined setup.
  • →Ensure agent sandboxing to prevent untrusted code from affecting the host environment.

Why it matters

In production, the ability to run untrusted code securely can prevent costly breaches and downtime. Effective isolation mechanisms allow you to scale confidently while maintaining a strong security posture.

Code examples

YAML
1kubectl apply -f - <<EOF
2apiVersion: kagent.dev/v1alpha3
3kind: Harness
4metadata:
5  name: kagent
6  namespace: kagent
7spec:
8  kagent: {}
9  workload:
10    image: PATH_TO_YOUR_AGENT_IMAGE
11  substrate:
12    workerPoolRef:
13      name: kagent-default
14    snapshotPolicy:
15      location: gs://ate-snapshots-PATH_TO_YOUR_SNAPSHOTS
16  allowedAgentTemplates:
17    selector:
18      matchLabels:
19        kagent.dev/harness: kagent
20---
21apiVersion: kagent.dev/v1alpha3
22kind: AgentTemplate
23metadata:
24  name: assistant
25  namespace: kagent
26  labels:
27    kagent.dev/harness: kagent
28spec:
29  modelConfig:
30    name: default-model-config
31  description: A substrate-backed assistant used to verify this main build.
32  systemPrompt: You are a helpful assistant running on kagent.
33EOF

When NOT to use this

The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →
Linux FoundationSponsor

Industry-standard certifications built by the people behind Linux and Kubernetes. Earn the CKA — the gold standard Kubernetes administrator cert. OpsCanary readers get 30% off year-round with code OPSCANARY3.

Get CKA certified →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.