This is a demo that can be used to show how resilient services running on Kubernetes can be. Main app shows a giant sign that flashes in various random colors. Those colors come a Kubernetes powered microservice. If the service goes down, the sign turns red. Your goal is to try and knock the service down by killing the Kubernetes pods that run the service. You can do that by whacking the pods wich are respresented as moles.
There is also a less busy verison of the game available at /next.html. This version has an advanced mode that allows someone to do a more visual explanation of the mechanics.
The advanced version allows you to track the pod that is serving the color service and to simulate creating and destroying nodes.
The current directions assume you are using Google Cloud Platform to take advantage of Container Engine to build a manage your Kubernetes cluster. There is nothing preventing this app from running on a Kubernetes cluster hosted elsewhere, but the directions for setup assume Container Engine. If there is significant interest in these directions, I'll be happy to publish them (or better yet, accept a pull request.)
- Create Project in Cloud Console
- Navigate to Compute Engine (to activate Compute Engine service)
- Navigate to the API Library and activate Container Builder API
- Make a copy of
/Samples.properties
, renamed to/Makefile.properties
- Alter value for
PROJECT
to your project id - Alter
ZONE
andREGION
if you want to run this demo in a particular area. - Alter
CLUSTER
if you want to call your cluster something other thanwhack-a-pod
. - Set
GAMEHOST
,ADMINHOST
, andAPIHOST
if you have static host names for your cluster.
- Open a terminal in
/infrastructure/
. - Run
make build
.make build
will do the following:- Create Kubernetes Cluster
- Create 3 static ip addresses for use in the app
If you get the error
ResponseError: code=503, message=Project projectname is not fully initialized with the default service accounts. Please try again later.
You need to navigfate to Compute Engine in Google Cloud console to activate Compute Engine service.
- Open a terminal in
/
. - Run
make config
this will create all your kubernetes yaml files and a few other things for you. - This should create the following files:
- /apps/admin/kubernetes/admin-deployment.yaml
- /apps/admin/kubernetes/admin-service.yaml
- /apps/game/containers/default/assets/js/config.js
- /apps/game/kubernetes/game-deployment.yaml
- /apps/game/kubernetes/game-service.yaml
- /apps/api/kubernetes/api-deployment.yaml
- /apps/api/kubernetes/api-service.yaml
- Open a terminal in root of whack_a_pod location.
- Run
make build
- Run
make deploy
- When process finishes Browse to the the value of
GAMEHOST
.
There are two skins to the game.
- Carnival version:
- http://[gamehost]/
- Google Cloud Next branded version:
- http://[gamehost]/next.html
- http://[gamehost]/advanced.html
The advanced version of the game is a great demo for teaching some of the fundamentals of Kubernetes. It allows you to cordon and uncordon nodes of the Kubernetes cluster to simulate Node failure. In addition it shows which Pod of the Replica Set is actually answering calls for the service.
- Open a terminal in
/
. - Run
make clean
- Open a terminal in
/infrastructure/
. - Run
make clean
There are three Kubernetes services that make up the whole application:
- Game Game contains all of the front end clients for the game, both the carnival version and the Google Cloud Next version.
- Admin Admin contains all of the logic for managing the whole application. This is the application the front end calls to get a list of the pods running the color api, it also has calls to create and delete deployments, delete pods, and drain and uncordon nodes.
- Api Api contains two service calls: color and color-complete. Color is a random hexidecimal RGB color value. Color-complete is the same as color, but also sends the pod name of the pod that answered the service call.
"This is not an official Google Project."