Creating a CPU attack against a Kubernetes worker

Gremlin can generate various infrastructure attacks that impact cores, workers, and memory.

Let's perform the following steps to attack the CPU:

  1. Deploy a sample application:
$ kubectl apply -f ./src/chapter4/gremlin/nginx.yaml
  1. List the pods and confirm they are running:
$ kubectl get pods |grep nginx
nginx-deployment-5c689d88bb-24n4m 1/1 Running 0 4m31s
nginx-deployment-5c689d88bb-rwtk9 1/1 Running 0 4m31s
  1. Get the node name for one of the pods:
$ kubectl get pod nginx-deployment-5c689d88bb-rwtk9 -o jsonpath="{.spec.nodeName}"
ip-172-20-50-43.ec2.internal
  1. Watch the pods status:
$ watch kubectl get pods
  1. Log in to your Gremlin account at https://app.gremlin.com/.
  2. From the Attacks menu, click on Infrastructure.
  3. Click on the New Attack button:

  1. Under the Choose Hosts to target tab, pick the node's local hostname from step 3:

  1. Under the Choose a Gremlin tab, click on Resource, select CPU attack, set CPU Capacity to 90, and consume all CPU cores:

  1. Click on Unleash Gremlin to run the attack:

Now, the actions you triggered on your Gremlin account will be executed on your cluster through the agent.