• Stars
    star
    135
  • Rank 263,766 (Top 6 %)
  • Language
    JavaScript
  • License
    Other
  • Created about 7 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A demo application that turns a Kubernetes cluster into a Whack a Mole game, where the moles are pods.

Whack-a-pod

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.

Whack-a-pod Screenshot

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.

Next Screenshot

The advanced version allows you to track the pod that is serving the color service and to simulate creating and destroying nodes.

Advanced Screenshot

Getting Started

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 and configure GCP project

  1. Create Project in Cloud Console
  2. Navigate to Compute Engine (to activate Compute Engine service)
  3. Navigate to the API Library and activate Container Builder API

Create Configs

  1. Make a copy of /Samples.properties, renamed to /Makefile.properties
  2. Alter value for PROJECT to your project id
  3. Alter ZONE and REGION if you want to run this demo in a particular area.
  4. Alter CLUSTER if you want to call your cluster something other than whack-a-pod.
  5. Set INGRESSNAME if you need to use something other than the default.
  6. Set DOCKERREPO if you need to use something other Google Container Registry.
  7. Open a terminal in /.
  8. Run make config to create your ingress file.
  9. This should create the following file:
    1. /apps/ingress/ingress.yaml

I use this application to show off Google Cloud Platform, so I tend set it up multiple times, once per region or datacenter. Therefore, I rename the INGRESSNAME and CLUSTER a bunch. If you only have one cluster, you don't have to fiddle with these.

Build Infrastructure

  1. Open a terminal in /infrastructure/.
  2. Run make build. make build will do the following:
    1. Create Kubernetes Cluster
    2. Create 1 static ip addresse 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.

Build Application

  1. Open a terminal in root of whack_a_pod location.
  2. Run make build
  3. Run make deploy
  4. When process finishes Browse to the the IP address value for the ingress.
  5. To get that address: gcloud compute addresses describe #INGRESSNAME# --global

Run demo

There are two skins to the game.

  1. Carnival version:
    • http://[gamehost]/
  2. 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.

Clean Up

  1. Open a terminal in /.
  2. Run make clean
  3. Open a terminal in /infrastructure/.
  4. Run make clean

Minikube

Whack a Pod can run on Minikube. Its performance isn't stellar, but the game versions of it run just as well a it does on a flaky conference wifi.

Prerequisite

  • Install minikube
    Directions
  • Enable ingress
    minikube addons enable ingress
  • Install xhyve driver (Mac OS])
    Directions

Docker Repository

You can use the Container Registry based commands in the Makefiles to build and host your Docker images.

  1. Open a terminal in root of whack_a_pod location.
  2. Run make build
  3. Make images publicly available by following these directions

This still requires a Google Cloud Platform Project. If you would like to build them some other way, you can, nothing restricts you from doing so. Just make sure you set $(DOCKERREPO) to the right value in Makefile.properties.

Docker Repository with DockerHub

Alternatively, to host your images on DockerHub,

  1. Create an account on DockerHub
  2. Create an image repository on DockerHub
  3. In the Makefile.properties, change the value of PROJECT so that it equals your image repository slug
  4. In the Makefile.properties, change the value of DOCKERREPO so that it looks like yourusername/$(PROJECT)
  5. Run make build.dockerhub

Your repository should have three new images with the tags:

  • admin
  • api
  • game

For example, if your username is username and your repository name is wap, your images will be pushed to:

  • username/wap:admin
  • username/wap:api
  • username/wap:game

Running on Minikube

  1. Open a terminal in root of whack_a_pod location.
  2. Run minikube start --vm-driver=xhyve
  3. Run make deploy.minikube
  4. Run minikube ip to get the IP address of the Minikube deployment.
  5. Create an entry in /etc/hosts pointing IP address to minikube.wap.

Running on Minikube with DockerHub

  1. Open a terminal in root of whack_a_pod location.
  2. Run minikube start
  3. Run make deploy.minikube.dockerhub
  4. The last line of the previous command should contain an IP address beside a "minikube.wap" string
  5. Run sudo vim /etc/hosts, append the last line to the /etc/hosts and save the file.
  6. Wait for the ingress to obtain an IP address (run kubectl get ing --watch and wait till the ADDRESS column has a value)
  7. Visit http://minikube.wap in the browser

Clean Minikube

  1. Run make clean.minikube
  2. Run minikube stop

Running on any Kubernetes (generic)

This method is for generic usage and can be run on any Kubernetes installation. There are few differences:

  • It will push built images to repo DOCKERREPO defined in Makefile.properties
  • It's agnostic of any loadbalancer in front of ingress so you can use NodePort type for ingress service
  • It works with RBAC model - proper serviceaccount and role bindings are created
  • It will deploy all objects in current namespace
  1. Open a terminal in root of whack_a_pod location.
  2. Build application with make build.generic OR skip building by setting DOCKERREPO to cloudowski and use prebuilt images availabe on dockerhub
  3. Run make deploy.generic
  4. Define name whackapod.example.com in your /etc/hosts pointing to IP address of your load balancer in front of ingress controller or one of nodes IP (when using NodePort)
  5. Open your browser at http://whackapod.example.com/

Clean generic deployment

  1. Run make clean.generic

Architecture

There are three Kubernetes services that make up the whole application:

  1. Game Game contains all of the front end clients for the game, both the carnival version and the Google Cloud Next version.
  2. 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.
  3. 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."

More Repositories

1

CSS-Slide-Transition

A little project that replaces default link behavior with a slide transition.
JavaScript
28
star
2

Apptacular

ColdFusion Builder Extension for scaffolding applications straight from the database
ColdFusion
17
star
3

whichElement

A project to crowdsource a reference for semantic element advice.
JavaScript
16
star
4

Finicky

Finicky is a mobile app designed to track hard to find local items for travelers. Made with Flex and AIR.
ActionScript
14
star
5

Brackets-Reflow-Cleaner

An extension for Brackets that will clean the content from Reflow into something to help with hand coding.
JavaScript
9
star
6

Reveal.js-with-Edge-Animate

JavaScript
6
star
7

Brackets-Apache

Syntax highlighting for Apache config files.
JavaScript
6
star
8

SharedCode

Code that I am sharing in various forms.
Go
6
star
9

GoogleTranslationAPICFC

A ColdFusion implementation of the Google Translation API
ColdFusion
6
star
10

PhoneGap-Build-1Click

Shell
6
star
11

brackets-phonegapbuild

Brackets Extension for interacting with PhoneGap Build
JavaScript
4
star
12

CFConsole

Console Project for ColdFusion
ColdFusion
4
star
13

SkinExample

Finished version of RIAUnleashed Skinning Class
ActionScript
3
star
14

hammer_strike

An App Engine demo that drives a lot of load and App Engine and allows you to see what happens when you.
CSS
3
star
15

BuilderStats

A ColdFusion Builder Extension for getting statistics about lines of code from your applications.
ColdFusion
3
star
16

PhoneGap-CSS-Compass-

A mobile compass application using PhoneGap entirely written in HTML CSS JS.
3
star
17

PhoneGap-Build-Watcher

An application for watching PhoneGap Build apps during development. To take a few clicks out of the development process.
JavaScript
3
star
18

Builder-Extension-Test-Creator

Allows you to capture the results of a CF Builder Extension action to a file. This makes it easier to get started developing an extension and debug extensions in general.
ColdFusion
3
star
19

GCPQuest-Companion

Go
2
star
20

ActionBarExample

Example of hiding the actionBar in a Flex Mobile Application.
2
star
21

mlauth

Go
2
star
22

NCDevconSchedule

ActionScript
2
star
23

Modern-HTML-Demo-

Starting to Build a set of HTML5, CSS3 and JavaScript Demos
2
star
24

CreateTheWebTourPresos

Presentations for Create the Web Tour
JavaScript
2
star
25

Evangelists-API

ColdFusion
2
star
26

Max2013---Practical-CSS

Code and presos for my Max presentation on practical CSS.
JavaScript
2
star
27

HTMLToast

2
star
28

TRORM

Terry Ryan's ORM Jumpstart Extension for ColdFusion Builder
ColdFusion
2
star
29

SkinExampleExercise

The completed version of the RIAUnleashed Skin
ActionScript
2
star
30

SkinExampleStarted

This is the starting point for the RIAUnleashed Skinning Class
ActionScript
2
star
31

ETE

Flex for Mobile Scheduler for Philly ETE Conference
ActionScript
2
star
32

AirTivoRemote

A Tivo Remote Application written in Adobe AIR for mobile devices.
ActionScript
2
star
33

AirTivoRemoteQNX

An AIR Tivo remote written in AIR for QNX for the BlackBerry Tablet OS
ActionScript
2
star
34

SeatingChart

A seating chart/ attendance demo app for showing Flex Mobile on Tablets
2
star
35

Toddler-Timeout

ActionScript
2
star
36

shades

A small library of color tools for creating shades of a color family.
Go
2
star
37

Hoytstaff_cf

ColdFusion Portion of CFAIR synchronization code.
ColdFusion
1
star
38

Codeworks-Basic

Codeworks mobile app done with no framework.
1
star
39

GeoTests

FlexUnitTests for Distance Calculator
ActionScript
1
star
40

Adobe-Day-Schedule

Responsive Example of a schedule for Adobe Day Amsterdam
1
star
41

Max2013---Programming-CSS

A Max 2013 session on various ways og getting more productivity out of CSS.
JavaScript
1
star
42

HighRiseCFC

ColdFusion CFC's for interacting with 37Signals Highrise
ColdFusion
1
star
43

Detagger

Extension that will convert CFML code to CFScript
ColdFusion
1
star
44

Personal-Website

Current code for terrenceryan.com
PHP
1
star
45

AndroidBBQ

Mobile Scheduler for Android BBQ
1
star
46

MonsterBook

CSS experiments in the form of a children's book
1
star
47

Tripit-Calculator-

This project takes my airline miles, adds data from Tripit and computes how many miles I'll do this year.
JavaScript
1
star
48

RevealTemplate

Attempt at
JavaScript
1
star
49

NewTerrenceRyan.com

My personal website's code base.
CSS
1
star
50

Edge-Animate---CSS-Filter-Studio

An Exploration of combining Edge and CSS Filter Studio
JavaScript
1
star
51

Atlassian-Connect-Add-On-Starter-Kit-for-App-Engine

A leg up for writing Atlassian Connect Add On using App Engine.
Java
1
star
52

FinickyHTML

HTML version of Finicky for eventual use with Phonegap.
JavaScript
1
star
53

terrenceryan-redesign

1
star
54

Hoytstaff_network_only

Network only (no caching) Flex portion of Hoytstaff code samples.
1
star
55

DevCon-5-Mobile-Schedule

A Mobile Schedule for DevCon 5
1
star
56

HTML-Presentation-Template

Template for my ImpressJS presos.
1
star
57

TivoRemoteAS

Pure AS Tivo Remote
ActionScript
1
star
58

D2WC-Mobile-app

A demo app for the conference D2WC, not an official app for it.
JavaScript
1
star
59

BuilderStatsFlex

The Flex front end for Builder Stats
ActionScript
1
star
60

Hoytstaff_readonly_db

Read only caching Flex portion of Hoytstaff code samples.
ActionScript
1
star
61

Edge-Presentations

Presentations about Edge Tools and Services.
JavaScript
1
star
62

Codeworks-jQuery-Mobile

Codeworks mobile app done with jQuery Mobile
JavaScript
1
star
63

Hoytstaff_cfairsynch

CFAIR Synch Flex portion of Hoytstaff code samples.
ActionScript
1
star
64

Max2013---Responsive-Design-in-Action

Presentations, code, and a step by step guide for a hands on lab in Responsive Web Design at Adobe Max 2013.
JavaScript
1
star
65

TerrenceRyan.com-Wordpress-Theme

PHP
1
star
66

google-cloud-coldfusion-demo

HCL
1
star
67

ColdFusion-Week-Demos

ColdFusion
1
star
68

preso-technicalpresenting

JavaScript
1
star
69

Flex4TwitterSearchApp

A twitter search application written in Flex 4 using Flash Builder Data Services.
ActionScript
1
star
70

GCPQuestCS

Just an experiment, nothing to see here.
Makefile
1
star
71

AboutTimeHero

An approximate clock for mobile devices.
ActionScript
1
star
72

TerrenceRyan.com

My website
ColdFusion
1
star
73

CSS-Regions-Examples

A few examples of working with CSS regions.
1
star