How to implement Chaos Engineering using Kube Invaders

Reading Time: 3 minutes

Chaos Engineering is the practice of performing random experiments to disturb the equilibrium of the deployment environment. Thus, this aims to check if an application is fault tolerant and highly available. The important reason behind Chaos engineering is to create highly available applications. Engineers use chaos engineering to cause chaos, random destructive operations in the deployment environment. This helps the engineers to reproduce many real-time problems which occur in production environment. Thus, the engineers can work to build a highly resilient application keeping the limitations in mind. Kube Invaders is one of such tool.

Similarly, for workloads running on Kubernetes there are different tools to implement Chaos Engineering. Experiments in chaos engineering is the practice of performing destructive actions on the environment to build HA applications. For a Kubernetes cluster, some of the chaos experiments include pod deletion, load testing of pod to test auto scaling, node restart etc. Thus in this blog, I will be using kubeinvaders to implement Chaos Engineering. So, Kube Invader is a very simple tool which can only implement random pod deletion experiments.


  • Kubernetes Cluster
  • Helm CLI

Installation of Kube Invader

Install an Ingress Controller

Firstly, we will need to deploy an ingress controller to expose the kube invaders UI. So, I will be using nginx ingress. You can use any ingress controller of your choice. So, to deploy nginx ingress,

helm upgrade --install ingress-nginx ingress-nginx \
 --repo \
 --namespace ingress-nginx --create-namespace --atomic
Install Kube Invader

We will create a file named values-2.yaml file to hold all the custom values for the kube invaders helm chart. In the below file, replace the place holders for target_namespace and hostName. We can provide multiple namespaces as target namspaces. The namespaces are separated by comma.

target_namespace: "<namespace-1>,<namespace-2>"
  enabled: true
  annotations: nginx  #Change to the ingress class you are using
  hostName: "<hostname>"

Now we will deploy the helm chart using the command:

helm repo add kubeinvaders

helm upgrade --install kubeinvaders kubeinvaders/kubeinvaders -f values-2.yaml -n kubeinvaders --create-namespace --atomic

This will deploy the Kube Invaders helm chart. We can verify it by running the command:

kubectl get deploy,po,ing,svc -n kubeinvaders

Testing the Kube Invaders

Dummy Nginx Deployment

To create a dummy nginx deployment, execute:

kubectl create deploy nginx --image=nginx --replicas=30 -n <namespace>

Change the namespace placeholder to the namespace value which kubeinvaders monitors.

Testing the Chaos Experiment

We can then go to the Ingress hostname of the Kube Invader on browser. There we will see an UI like:

We are seeing an UI, with some important fields:

  • Enable Shuffle: The position of pods which the alien emoji depicts will be shuffled.
  • Enabled Auto NS Switch: If we configure more than one namespaces, KubeInvaders will switch between namespaces and kill the pods.
  • Hide Pods Name: If we enable this, the name of the pods will be hidden.
  • Random Factor: It denotes the rate of killing of pods. We can use the scale to change this value.

Other than that, the UI shows the number of deleted pods, the recent killed pod, chaos jobs total etc. The chaos job is job running in the namespace which we configure for chaos experiment. We can verify this if we execute:

watch kubectl get po -n <namespace>

We will see the pods are terminating and recreated as it is a deployment.We will also see job’s pods being created and completed. These pods kill the other pods in the namespace.


In this blog we looked into simple implementation of Chaos Engineering using KubeInvaders. This tools is a simple toll to start the journey on chaos engineering.


Written by 

Dipayan Pramanik is a DevOps Software Consultant at Knoldus Inc. He is passionate about coding, DevOps tools, automating tasks and is always ready to take up challenges. His hobbies include music and gaming.