Skip to content

coollog/kubernetes-survey-app-demo

Repository files navigation

Kubernetes Survey App Demo

This repository contains a demo we did to showcase continuous development on Kubernetes withSkaffoldandJib.We gave the demo during the Skaffold for Java talk at Oracle Code One 2018.

How to set up the demo

Step 1 - infrastructure

  1. Set up a Kubernetes cluster.

  2. Allocate a static external IP to use.

  3. (Recommended) Register a domain name. (We usedskaffold-code.one.)

    1. Add an A record to point to the allocated external IP.
  4. Clone the repository:

    $ git clone https://github /coollog/kubernetes-survey-app-demo

Step 2 - set up ingress

  1. Make surekubectlis configured correctly.

  2. Set theEXTERNAL_IPenvironment variable to the allocated external IP:

    exportEXTERNAL_IP=???
  3. Set up Ambassador for ingress:

    $ kubectl create clusterrolebinding my-cluster-admin-binding --clusterrole=cluster-admin --user=$(gcloud info --format="value(config.account)")
    $./apply_ambassador.sh

Step 3 - start the app

  1. Make surekubectlis configured correctly.

  2. Start Skaffold:

    $ skaffold dev
  3. Once everything is up and running, visit your app at its domain name (or external IP).

  4. Results are viewable at/results.

Changing the survey

The survey prompt and options can be changed by editing the HTML files:

frontend-service/src/main/resources/public/index.html

  • Only need to touch the#optionsdiv.

frontend-service/src/main/resources/public/results.html

  • Only need to touch theVotesconstructor,and change whatthis._votesis set to.
  • Change the domain name in the#bannerdiv.

How to give the demo

The following is a script for the demo:

  1. State that we have a cluster set up on GKE already, and that it's simple to do so if you don't. All you would need to run isgcloud container clusters create.

  2. Give a brief overview of the app. Can show a diagram like:

  3. Start Skaffold.

    $ skaffold dev
  4. Watch as Skaffold containerizes the 3 microservices and deploys them to the Kubernetes cluster without any extra effort. The app is now live.

  5. Navigate to your app's domain to show the audience what they should expect to see. Something like:

  6. Navigate to the/resultspage to display the results as they come in. The page will animate in realtime as people cast votes:

  7. Ask the audience to please take out their phones/laptops and navigate to the domain to cast their votes. Watch as the results roll in.

  8. Make some comedic remark about the results coming in.

  9. Now, it's time to show how easy it is to make a change to the app and have it updated live on the Kubernetes cluster.

  10. Ask the audience to shout out a new option they would like to add to the survey. Pick one and add that to the survey in some code editor (frontend-serviceHTML files). Save the edits and watch as Skaffold automatically picks that up and re-containerizes/re-deploys the app, even quicker this time. Refresh the results page to see the new option show up.

  11. Have the audience cast votes with that option available as well and watch as results roll in.

  12. (Optional) Shut down Skaffold and show that Skaffold cleans up the services from the cluster.

What are the three services?

frontend-service- Micronaut/Groovy

  • /- take the survey
  • /results- survey results page

vote-service- Spring/Java

  • /- send vote data to this, publishes to notification-service

notification-service- NodeJS

  • Subscribes to vote notifications.