7. Comprehensive Practice

The purpose of the comprehensive practice is to give students an opportunity to execute the labs again in a workshop environment. This workshop will not be presented as a step-by-step lab guide. Rather, this workshop is presented as a list of high level tasks that students should be prepared to execute.

This comprehensive practice will act as both an opportunity to reinforce understanding of all that’s been done during this course and to put it all together in a single scenario, as well as to prepare students who plan to take the certification exams.

If you’re not sure which command to use for step execution, run kubectl --help and grep -i to find an appropriate subcommand. You may then run kubectl <subcommand> --help for additional help. Enabling bash completion by running source <(kubectl completion bash) is also helpful. It is best to use yaml configuration files and declarative commands such as kubectl create -f <resource.yaml> to create your objects. To find sample configuration files you may refer to https://kubernetes.io/docs/home and search for resource specification sytanx. Alternatively, you may use kubectl explain resource to get detailed explaination of resource subfields. You should only use the dashboard to verify your results. Also helpful, would be using kubectl apply instead of kubectl create during development for safe updating and quick redeployment of your resource.

Chapter Details
Chapter Goal Review the topics covered in the course
Chapter Sections

7.1. Comprehensive Practice Overview

Your manager has asked your to port an existing Docker Swarm application to Kubernetes. You can find the Swarm yaml file at https://github.com/dockersamples/example-voting-app/blob/master/docker-stack.yml. Use Kubernetes PersistentVolumes, PersistentVolumeClaim, Deployment, and Service resources in your implementation. As an overall guidance in porting this project please keep in mind that swarm services find each other using swarm’s built-in DNS. Hence, when porting to Kubernetes we can replace the swarm service with a Kubernetes Service with the same name, listening on the same port, and any application using DNS service discovery should continue to behave the same - i.e. do not change the service names.

7.2. Comprehensive Practice Task List

Task 1 Review the existing Docker Swarm deployment and gather requirements.

The Example Voting App is a popular Docker training application which we already used in Section 3.2. Build a multi-container application. It is composed of five component apps, each of which is a containerized application you can pull from Docker hub, that interact with each other as depicted here:

_images/vote-architecture.png
  • A Python webapp which lets you vote between two options
  • A Redis queue which collects new votes
  • A .NET worker which consumes votes and stores them in a database
  • A Postgres database backed by a Docker volume
  • A Node.js webapp which shows the results of the voting in real time

A Kubernetes solution is available at https://github.com/dockersamples/example-voting-app/tree/master/k8s-specifications. Follow the instructions below to create you own solution and then compare your results to the standard solution provided.

7.2.1. Administrative Tasks

Task 2 As a kubernetes cluster admin create three PersistenVolumes of type hostPath and size 50Mi, 100Mi, and 150Mi.

Task 3 As a kubernetes cluster admin create a namespace called vote.

7.2.2. Project Specific Tasks

These tasks are specific to the vote project.

Task 4 Set the current context to vote

Task 5 Create a PersistentVolumeClaim with accessMode of read and write of size 80Mi.

Task 6 Create a deployment with 1 replica for image postgres:9.4 that uses the PVC created in the previous step.

Task 7 Create a Service for the previous deployment which targets port 5432

Task 8 Create a deployment with 2 replicas for image redis:alpine with port 6379

Task 9 Create a Service for the previous deployment which targets port 6379

Task 10 Create a Deployment with 2 replicas for image dockersamples/examplevotingapp_worker

Task 11 Create a Deployment with 2 replica for image dockersamples/examplevotingapp_vote:before

Task 12 Create a Service of type NodePort for the previous deployment

Task 13 Create a Deployment with 2 replica for image dockersamples/examplevotingapp_result:before

Task 14 Create a Service of type NodePort for the previous deployment

Task 15 Test your deployment in your browser

Task 16 View your application resources in the dashboard

Great job, you are done with the 7. Comprehensive Practice chapter.

Checkpoint

  • Practice all of the topics presented in this course
  • Take all that’s been covered and put it all together
  • Familiarize yourself with both the dashboard and the command-line client of Kubernetes