Commit b87c9f34 authored by Bruce Flynn's avatar Bruce Flynn
Browse files


parent f9bb57a9
......@@ -6,6 +6,9 @@ Presented on 04 Nov, 2019
> to provide an example of as many K8S moving parts as I could.
# Overview
This demo was developed using minikube v1.5.2 running kubernetes 1.16. It also makes
use of Helm v2.
This is a demo of used various types of components provided by Kubernetes. The
demo is deployed as a [Helm]( chart and consists of a Python
web application to which you can submit a string. Upon submission the App will
......@@ -28,74 +31,96 @@ It makes use of the following Kubernetes componets
* [ConfigMap](
* [Secret](
## Requirements
* Install `kubectl`
- I highly recommend you also make use of the included shell completion
* Install `helm`
* Install `minikube`
# Environment Setup
## Install/Run Kubernetes
This example will make use of [minikube]( for a
Kubernetes cluster. Generally speaking, the confiuration/deployment here should
be deployable to any K8S cluster you have available, however, it was only
tested with minikube.
Follow the instructions [here]( to install minikube
on your system.
## Start K8S with the required plugins
minikube start
minikube addons enable helm-tiller
minikube addons enable ingress
After installing the minikube binary, on my Linux box I create a new cluster with
## Build our docker image
minikube start --vm-driver=kvm2
eval $(minikube docker-env)
docker build -t say-hello .
## Helm Charts
This demonstration also provides a [Helm]( chart.
## Install PostgreSQL
$he Helm PostgreSQL [chart](
is configured using by overriding the default chart values with values from
> **NOTE**: Helm v3 is the current version but this demo uses Helm v2 because
I have not had the opportunity to check out v3 yet. So make sure if you are looking
at docs you are looking at the right version.
The database password is set in a secret named in the values that must be created
before deploying the app.
Helm requires that the `helm-tiller` addon be enabled:
Replace `<MYPASSWORD>` with whatever you want the password to be.
minikube addons enable helm-tiller
kubectl create secret generic myapp --from-literal=postgresql-password=<MYPASSWORD>
helm install --name myappdb -f chart/pg-values.yaml stable/postgresql
Also, the Chart includes a K8S Ingress which is enabled by default. Unless you
specifically disable the ingress you will need to also enable the `ingress` addon:
> **NOTE**: If you change the name here you will also have to set `dburl` when you
deploy the myapp chart as the name will be part of the automatically provided cluster
DNS name.
## Install the App
The app is an *unpackaged* chart in `./chart/myapp` and can be installed by giving `helm`
the direct path to the chart.
minikube addons enable ingress
helm install --name myapp ./chart/myapp
The app contains an `initContainer` configured to ensure the required DB table is created
before the app starts.
As part of the app a
will start a [Job]( that will start a [Pod]( to sync job status with the database.
# Database
The database password is set in a secret that must be created before deploying the
Eventually, as the jobs complete the `CronJob`s should update the job status in the
database and be available in the table in the app.
Set `<MYPASSWORD>` to whatever you want the password to be.
You can check the status of the app after it's installed by using either `kubectl` or
the `helm` command:
kubectl create secret generic myapp --from-literal=postgresql-password=<MYPASSWORD>
kubectl get all -l
helm status myapp
Deploy an empty database `myapp` that will use the password from the secret created
above. The `-f` is providing configuration values that override the defaults provided
as a part of the Helm PostgreSQL [chart](
The app will be available via its [Ingress]( and [Service]( which will proxy conections into
the cluster to one of the 3 replicas available at the minikube IP address:
helm install --name myappdb -f chart/pg-values.yaml stable/postgresql
echo http://$(minikube ip)/say-hello
> **NOTE**: If you change the name here you will also have to set `dburl` when you
deploy the myapp chart.
# Install App
You can install the app provided in the `./chart` directory (after Helm is installed)
by doing the following:
If you navigate to the above URL you should see a simple form where you can enter in
some text. There should also be a table listing all the jobs currently in the database.
If you enter text and hit `Submit` the webapp will create and submit a K8S Batch
that will simply echo your text. You can view your job like so:
helm install --name myapp ./chart/myapp
kubectl get jobs <name>
After the app is installed you can check the status of all components that were deployed
as part of the app by:
Where `<name>` is the value from the table on the web page. The Pods created for the Job
can be views like so:
helm status myapp
kubectl get pods -ljob-name=<name>
You can additionally delete all components as part of this particular Helm realse by:
## Removing/Uninstalling
You can delete all components created as part of this particular Helm realse by doing the
helm delete --purge myapp
PostgreSQL is **not** part of the App and therefore will not be removed.
The `--purge` flag removes all trace of the release in Helm. You would probalby not use
the `--purge` flag in production.
\ No newline at end of file
......@@ -2,7 +2,7 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
replicaCount: 3
repository: say-hello
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment