kubernetes-sigs/agent-sandbox and declarative telemetry using GKE MCP Server with Gemini 3.7.
⚡ 1. The Agentic Security Paradox
The evolution from passive conversational interfaces to execution-capable agentic systems has fundamentally transformed infrastructure architecture. To resolve complex production challenges—such as exploratory data analysis, log triage, or automated infrastructure remediation—Large Language Model (LLM)-based agents require real-time arbitrary code execution capabilities (Python, Bash, binary scripts).
Here lies the Agentic Security Paradox: the more computational autonomy you delegate to an agent, the broader the attack surface exposed across your cluster. Untrusted code execution driven by probabilistic models introduces critical threat vectors that perimeter defenses cannot mitigate:
- Indirect Prompt Injection: Unstructured data ingested by the agent (such as malicious logs, HTTP payloads, or commit histories) can hijack the LLM control flow and trigger destructive script execution.
- Container Breakout: Standard Linux containers share the underlying host kernel. An agent executing arbitrary code can exploit kernel syscall vulnerabilities (host CVEs) to compromise the node.
- Resource Starvation & Data Exfiltration: Unbounded processes can saturate CPU/memory resources or attempt lateral network traversal toward internal metadata endpoints and private VPCs.
Enabling true enterprise autonomy without compromising infrastructure demands a strict separation between the reasoning plane and the execution plane via disposable, kernel-isolated runtime environments.
🛠️ 2. Architecture of kubernetes-sigs/agent-sandbox
To standardize sandbox lifecycle management without relying on ad-hoc Pod or Job scripting, the Kubernetes community under SIG Apps developed kubernetes-sigs/agent-sandbox. This declarative, Custom Resource Definition (CRD)-driven operator is designed specifically for agentic workloads, stateful singletons, and code interpreter runtimes.
Unlike traditional controllers like Deployments (designed for stateless microservices) or StatefulSets (built for static database topologies), agent-sandbox introduces primitives tailored for dynamic, short-lived lifecycles:
Sandbox: The atomic execution unit. Represents an isolated environment with stable network identity, dedicated persistent storage support (PVCs), and rigorous lifecycle management.SandboxTemplate: Declarative blueprint specifying base pod configurations, container images, resource boundaries, and the required security runtime class.SandboxWarmPool: Pod pre-warming mechanism maintaining a pool of pre-provisioned instances, slashing cold-start provisioning latency from ~20s to under 0.5s.SandboxClaim: Declarative binding mechanism through which an agent or service immediately claims an available sandbox from the warm pool for an active execution session.
The operator acts as an orchestrator, delegating low-level kernel isolation via the Kubernetes RuntimeClass standard to specialized runtimes such as gVisor (runsc) or Kata Containers.
Sentry), completely preventing agent-generated code from directly invoking the underlying Linux host kernel.
🔗 3. GKE MCP Server + Gemini: Agentic Control Plane
The Model Context Protocol (MCP) is the open standard that enables models like Gemini to establish structured, bidirectional communication with tools, filesystems, and operational APIs. In Google Cloud, the GKE MCP Server exposes the Kubernetes control plane to Gemini through secure, semantic interfaces.
The server operates in two main modes based on security requirements and operational topology:
- Local MCP Server (stdio): Runs locally on developer workstations or CLI pipelines (e.g.,
gemini-cli), leveraging localkubeconfigcontext for interactive diagnostics and development. - Remote MCP Server (HTTP/SSE): Deployed as a managed service on Cloud Run or within GKE, protected by Cloud IAM, Workload Identity Federation (WIF), and Model Armor policy filters for centralized enterprise auditing.
Through this integration, Gemini goes beyond code generation to perform real-time cluster state inspection, event streaming analysis, container log queries, and declarative remediation orchestration.
🔄 4. End-to-End Workflow: From Intent to Isolated Remediation
Coordinating Gemini, the GKE MCP Server, and agent-sandbox establishes autonomous Site Reliability Engineering (SRE) workflows without operational hazard:
- Detection & Query: An operator or monitoring pipeline flags a service anomaly (e.g.,
CrashLoopBackOffon a core payment service). - MCP Cluster Introspection: Gemini leverages GKE MCP Server tools to execute
get_pod_logs, inspect cluster events, and verify deployment specifications. - Sandbox Claim: Detecting the need to parse memory dumps or run dynamic diagnostic scripts against staging data, the agent submits a
SandboxClaimto theSandboxWarmPool. - Secure Execution under gVisor: The agent injects diagnostic code into the assigned sandbox. Execution is strictly confined under
runscwith restricted network egress. - Synthesis & Declarative Patching: With verified diagnostics, Gemini generates the root-cause report and outputs a validated Kubernetes manifest or Pull Request.
- Garbage Collection (TTL): Upon task completion, the controller automatically tears down the sandbox according to expiration policies (
shutdownTime), releasing resources and preventing data leakage.
📄 5. Technical Manifests & Configuration
The following manifests demonstrate configuring kernel isolation on GKE, establishing pre-warmed sandbox pools, and wiring the GKE MCP Server to Gemini.
A. RuntimeClass and SandboxWarmPool
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
name: gvisor
handler: runsc
---
apiVersion: agents.x-k8s.io/v1alpha1
kind: SandboxTemplate
metadata:
name: python-interpreter-template
namespace: agent-workloads
spec:
podTemplate:
spec:
runtimeClassName: gvisor
containers:
- name: interpreter
image: us-docker.pkg.dev/cloudrun/container/job-runner:python311
resources:
limits:
cpu: "2"
memory: "4Gi"
requests:
cpu: "500m"
memory: "1Gi"
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
runAsNonRoot: true
runAsUser: 10001
---
apiVersion: agents.x-k8s.io/v1alpha1
kind: SandboxWarmPool
metadata:
name: interpreter-warmpool
namespace: agent-workloads
spec:
replicas: 5
templateRef:
name: python-interpreter-template
B. SandboxClaim for Ephemeral Session
apiVersion: agents.x-k8s.io/v1alpha1
kind: SandboxClaim
metadata:
name: sre-session-task-8492
namespace: agent-workloads
spec:
poolRef:
name: interpreter-warmpool
lifecycle:
shutdownTime: "2026-08-27T10:30:00Z"
ttlSecondsAfterFinished: 300
C. GKE MCP Server Configuration for Gemini CLI
{
"mcpServers": {
"gke-cluster-inspector": {
"command": "gke-mcp",
"args": [
"serve",
"--project=rubik-enterprise-prod",
"--location=us-central1-a",
"--cluster=production-core-gke",
"--read-only=true"
],
"env": {
"use_gke_gcloud_auth_plugin": "true"
}
}
}
}
D. Agentic Orchestration Script in Python
import os
from google import genai
from google.genai import types
client = genai.Client()
def run_sre_agent_loop(incident_summary: str):
system_instruction = (
"You are an SRE AI Agent on GKE. "
"Use the GKE MCP Server to inspect cluster state "
"and execute diagnostic scripts exclusively within pods governed by SandboxClaim and gVisor."
)
response = client.models.generate_content(
model="gemini-3.7-flash",
contents=f"Investigate the incident and run sandbox diagnostics: {incident_summary}",
config=types.GenerateContentConfig(
system_instruction=system_instruction,
temperature=0.2,
)
)
return response.text
if __name__ == "__main__":
incident = "Pod checkout-service-7f8d9b-c4x12 reporting CrashLoopBackOff following dependency update."
result = run_sre_agent_loop(incident)
print(result)
🏢 6. Enterprise Vision: Zero-Trust Architecture at Rubik Cloud
In enterprise environments, enabling AI agents is not an algorithmic benchmark, but a governance challenge. Combining kubernetes-sigs/agent-sandbox with GKE MCP Server operationalizes the core Zero-Trust principles we implement at Rubik Cloud:
- Least-Privilege Execution: Every agent session operates in a disposable sandbox isolated from cluster networks and decoupled from the host node.
- Auditable Non-Human Identities: Model interactions with Kubernetes APIs are authenticated via federated machine identities (WIF) with complete audit trails in Cloud Logging.
- Strict Plane Decoupling: The LLM serves exclusively as a reasoning engine, while GKE infrastructure guarantees that hallucinations or prompt injections cannot breach core backend systems.
Scaling autonomous agent workloads requires treating AI-generated code with the same scrutiny as any untrusted payload. With native Kubernetes abstractions, enterprise agent execution moves from an unmanageable risk to a dependable operational asset.