Skip to content

Microservice/Kubernetes examples used in my 2018-Apr presentations at CodeEurope, Warsaw and Wroclaw

Notifications You must be signed in to change notification settings

mjbright/ConferenceDemo.2018-04_codeeurope-microservices

Repository files navigation

CodeEurope.pl Microservices talk demos

This repo contains the Microservice/Kubernetes examples I created for my "Developing Micro-services with Kubernetes" talks given in April 2018 at CodeEurope.pl in Warsaw and Wroclaw, Poland.

Refer to https://mjbright.github.io/Talks/index.html#201804_codeeu for the slides and other information about those talks.

A revised version will be available after Pyconfr, Lille happening in October 2018.

The demo at Wroclaw was run on a Mac AirBook Pro using

  • minikube as a single-node Kubernetes cluster
  • a simple demo dashboard integrating a test button & output, a shell console and a cluster visualization

The demo has also been tested/documented on

  • Windows10 using Docker Desktop to provide the Kubernetes cluster, using a MSYS2 buid of ttyd.
  • Ubuntu 18.04.1 LTS

The demo dashboard

The demo dashboard integrates several components

  • the button and output for a simple Flask/Redis counter application
  • a web console based on ttyd: allowing running of shell commands in the demo browser window
  • a Kubernetes visualization

Flask/Redis counter application

You don't need to rebuild this application, you can use the 'mjbright/flask-web' images available on DockerHub.

The steps to deploy these images are described later in this document.

Nevertheless the sources for this application are located in the subdirectory kubernetes-flask-redis-microservice along with a script to automatically build the different versions of the app (v1, v2, v3) used in the demo.

Kubernetes visualization

The visualizer is derived from a fork of Brendan Burns' K8S visualizer, implemented using jsPlumb library.

A modified version is integrated into the demo, it's sources are in the subdirectory live-k8s-visualizer, along with a script to start the visualizer.

The steps to deploy the visualizer are described later in this document.

To run the demos:

SETUP

Setup instructions are provided in SETUP.md - this document describes how to setup the full dashboard. You can also run the demo steps with minikube or any other Kubernetes cluster.

Demo Steps

Below I detail most of the steps of the CodeEurope demo with the exception of the use of Nginx on minikube. This will come later.

Slides

Refer to https://mjbright.github.io/Talks/index.html#201804_codeeu for the slides and other information about those talks.

You can refer to the presentation slides to see the commands used.

The demo steps are described from slide#23 onwards.

The steps are described in greater detail in those slides, and where these "declarative" steps (i.e. by "apply"ing the yaml files which are a declaration of the desired configuration) are also compared to alternative "imperative" such as kubectl run or kubectl expose.

Deploy Redis

Deploy a Redis backend (this will create a Deployment, a ReplicaSet and one instance of a Redis pod).

kubectl apply -f redis-deployment.yaml

Deploy Flask

Deploy a Flask app as frontend (this will create a Deployment, a ReplicaSet and one instance of a Flask-based application server pod).

kubectl apply -f flask-deployment.yaml

Expose the Redis Service

Expose the Redis service on a "known port" so that the flask-app can access it.

kubectl apply -f redis-service.yaml

Expose the Flask Service

Expose the Flask service so that we can connect to it.

kubectl apply -f flask-service.yaml

NOTE: We have not yet set the exposed service port in our demo page - the button still displays PORT_UNSET.

Update the demo page to set the service port

We rerun the create_demo_html.sh script now with the '-s' option to recuperate the service port:

cd live-k8s-visualizer/

./create_demo_html.sh -s

Now reload the demo page and we see that the port number now appears in the button and the first request to our service has been made "Redis counter value=1".

Press the button to see the value increment.

Scale the flask-app

In the file flask-deployment.yaml, modify the line

     replicas: 1 

to

     replicas: 4 

Now reapply this resource file:

kubectl apply -f flask-deployment.yaml

Rollout an upgrade to the flask-app

In the file flask-deployment.yaml, modify the line

     - image: mjbright/flask-web:v1 

to

     - image: mjbright/flask-web:v2 

Now reapply this resource file:

kubectl apply -f flask-deployment.yaml

Rollout an upgrade to the flask-app

In the file flask-deployment.yaml, modify the line

     - image: mjbright/flask-web:v2 

to

     - image: mjbright/flask-web:v3 

Now reapply this resource file:

kubectl apply -f flask-deployment.yaml

About

Microservice/Kubernetes examples used in my 2018-Apr presentations at CodeEurope, Warsaw and Wroclaw

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published