Automating Kubernetes Pod Evictions with Chaos Toolkit Chaos Engine
This JSON file defines a Chaos Toolkit experiment declarative specification that replicates traditional Chaos Monkey instance termination behaviors within a Kubernetes environment. The engine parses the experiment, validates steadystate probes against target namespaces, and triggers random pod evictions to verify that deployment replica sets self-heal correctly.
Use this snippet in cloud-native microservice architectures running on EKS, GKE, or self-hosted Kubernetes clusters where container-level termination replaces virtual machine terminations. It is designed to be executed from CI/CD pipelines during staging automated chaos runs.
Executing pod evictions in production without proper PodDisruptionBudgets (PDB) configured can lead to temporary service unavailability. Security teams must enforce strict RBAC roles on the Chaos Toolkit service account, limiting pod delete permissions strictly to non-critical application namespaces.
> System.Execute()
{
"version": "1.0.0",
"title": "Chaos Monkey Pod Termination in Application Namespace",
"description": "Terminates a random application pod and verifies deployment self-healing.",
"steady-state-hypothesis": {
"title": "Services remain healthy",
"probes": [
{
"type": "probe",
"name": "app-health-check",
"provider": {
"type": "http",
"url": "https://checkout.internal.domain/healthz",
"timeout": 3
}
}
]
},
"method": [
{
"type": "action",
"name": "terminate-random-pod",
"provider": {
"type": "python",
"module": "chaosk8s.pod.actions",
"func": "terminate_pods",
"arguments": {
"label_selector": "app=checkout-service",
"rand": true,
"mode": "one",
"ns": "production"
}
},
"pauses": {
"after": 30
}
}
]
}
> Architecture & Security Context
Verified for Valters IT Hub. When deploying this configuration in a production homelab or enterprise environment, ensure that you monitor system resources and implement strict access controls. Administrator privileges are required.
ID: VALTERSIT-AEB23529F1D4