k8spractice Overview

This is part 1 of a 4-part series on deploying an application to Azure Kubernetes. Here’s a full list of this series:

I started k8spractice after completing the Kubernetes Fundamentals course as part of preparing for the Certified Kubernetes Administrator exam. Aside from practicing what I learned about Kubernetes, I created “k8spractice” because I also wanted to write a Jamstack site using React, Flask, and Redis. The site also uses PostgreSQL 12.5 to store user credentials.

The project source code is located on Github. The site code is in the /app directory; and the Kubernetes configuration files are in /k8s-file. Please be aware that the app was written with very little regard to application security. The main purpose of this project is to provide a payload to deploy in Kubernetes and NOT a proper Jamstack application.

The frontend container is based on Apache 2.4 on Linux Alpine. This image has the static files generated by “npm build” in /usr/local/apache2/htdocs; and an httpd.conf with the necessary Rewrite rules to handle React Router links. The frontend container runs like a normal static site served by an Apache server.

The backend container is based on Python 3.7 on Linux Alpine. Gunicorn WSGI server is used to run the Flask-based backend app. This containers handles all the backend stuff for user creation, authentication, session management, and providing the data for the site’s pages. The backend service uses the following environment variables for its configuration:

  • REDIS_HOST and REDIS_PORT = The host and port of the Redis server
  • SECRET_KEY = Secret key for Flask session cookie
  • DB_DSN = DSN string to connect to the PostgreSQL server

The rest of this series will focus on deploying k8spractice on an Azure Kubernetes cluster. I don’t have a particular preference for Microsoft or Azure. I decided to use the service mainly because its conveniently accessible to me at the time of this writing.

Let’s begin by deploying a PostgreSQL service to the cluster.