How To Break Minecraft with Gremlin Scenarios — Chaos Engineering
Introduction
Gremlin Scenarios make it simple to simulate real-world incidents, this tutorial will simulate a flaky network while playing a video game (Minecraft). Scenarios allow you to link attacks together, growing both the blast radius and magnitude over time. Once created, these Scenarios become a shareable resource for your team, complete with a name, description, hypothesis, and a place to record your notes and observations. Andre also recently shared his experiences practicing Chaos Engineering on Minecraft with Gremlin.
This tutorial will provide a walkthrough of the following:
- How to install Docker
- How to install Gremlin in a Docker container
- How to spin up a Minecraft demo to run the Flaky Network Gremlin Scenario
- How to run the Flaky Network Gremlin Scenario
Prerequisites
Before you begin this tutorial, you’ll need the following:
- Docker For Mac (installation guide is here)
- A Gremlin account (sign up here for free)
- Minecraft for the demo (download here)
Step 1 — Installing Gremlin in a Docker container
After you have created your Gremlin account (sign up here) you will need to find your Gremlin Daemon credentials. Login to the Gremlin App using your Company name and sign-on credentials. These were emailed to you when you signed up to start using Gremlin.
Navigate to Team Settings and click on your Team.
On your mac, store your Gremlin client credentials as environment variables. Replace the values below with your own Gremlin Team ID and Gremlin Team Secret:
export GREMLIN_TEAM_ID=c64b1717-bf2a-57b9-b5ad-98d6bbc661a6
export GREMLIN_TEAM_SECRET=73ea7915–5149–4bf5-aa79–155149abf5ba
Next, on your Mac, run the Gremlin Daemon in a Container.
Use docker run to pull the official Gremlin Docker image and run the Gremlin daemon:
docker run -d — net=host \
— cap-add=NET_ADMIN — cap-add=SYS_BOOT — cap-add=SYS_TIME \
— cap-add=KILL \
-v $PWD/var/lib/gremlin:/var/lib/gremlin \
-v $PWD/var/log/gremlin:/var/log/gremlin \
-v /var/run/docker.sock:/var/run/docker.sock \
-e GREMLIN_TEAM_ID=”$GREMLIN_TEAM_ID” \
-e GREMLIN_TEAM_SECRET=”$GREMLIN_TEAM_SECRET” \
gremlin/gremlin daemon
Use docker ps to see all running Docker containers:
sudo docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1e7678716c91 gremlin/gremlin “/entrypoint.sh daem…” 5 seconds ago Up 4 seconds determined_vaughan
Step 3 — How to spin up a demo to run the Flaky Network Gremlin Scenario
In this step, we will be spinning up a demo using Minecraft. If you don’t already have Minecraft installed, you can download it from the Minecraft website.
Download and open Minecraft.dmg. Drag Minecraft to your Applications folder to install it. Then run the game just like you would any other application.
Click +New to create a new Minecraft installation, we’re going to use version 1.9:
Enter the name chaos and select release 1.9 as the version. Then click save:
In terminal on your Mac, create a Minecraft server using Docker. This Minecraft server will visualise our running containers:
docker run -t -i -d -p 25565:25565 -v /var/run/docker.sock:/var/run/docker.sock — name dockercraft — label type=dockercraft gaetan/dockercraftdocker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES58e29db62a0a gaetan/dockercraft “/srv/Server/start.sh” 5 seconds ago Up 4 seconds 0.0.0.0:25565->25565/tcp dockercraft8777f684344d gremlin/gremlin “/entrypoint.sh daem…” 3 minutes ago Up 3 minutes zealous_fermi
Back in the Minecraft Launcher, start Minecraft with version 1.9 by clicking play:
When you get to the Minecraft menu, select multiplayer:
You will see the Minecraft Docker server in the menu, select it and click Join Server:
When you successfully join the Minecraft Server you will land in a world featuring your running Docker containers, each container resembles a little building. You can see I am running 2 containers, a Minecraft server called Dockercraft and Gremlin.
Now we are ready to run the Flaky Network Gremlin Scenario.
Step 5 — How to run the Flaky Network Gremlin Scenario
Navigate to Scenarios and create a Flaky Network Gremlin Scenario, enter the information below, click add targets and run, next you will add the Minecraft container as the target.
Name: Flaky Network
Description: When your user encounters a flaky network, how does their experience change? Are users able to continue to use your application? Does your application fail gracefully?
Next, add 3 x Blackhole attacks on the target Docker container:
Attack 1: Blackhole attack, 10 seconds, Minecraft container
Delay: 10 seconds
Attack 2: Blackhole attack, 20 seconds, Minecraft container
Delay: 5 seconds
Attack 3: Blackhole attack, 30 seconds, Minecraft container
Unleash the Flaky Network Scenario
You are now ready to run the Scenario, you should see results similar to below:
Blast Radius & Magnitude
The practice of Chaos Engineering is all about injecting failure, starting with a small blast radius, a low number of hosts, and with limited magnitude, such as a minimal CPU load. Scenarios allow you to create many attacks and link them together, growing both the blast radius and magnitude over time.
Conclusion
You’ve used the Flaky Network Gremlin Scenario to determine what occurs when specific containers are no longer available. In this tutorial, we installed Minecraft, loaded up the Dockercraft demo, and were able to see our visible containers. We then used the Flaky Network Gremlin Scenario to demonstrate what happens when a dependency is temporarily unavailable.
Contact the Gremlin Team about upgrading your account to unlock all the available attacks and increase the number of hosts/containers you can attack.