Skip to main content

Kubernetes

Prerequisite: An existing Kubernetes-Cluster with at least one Node, e.g. k3s, k8s or minikube (local development only). Our recommendation is k3s with a minimum of 2 worker nodes.

High-Level Data Flow

Data Flow Kubernetes

Configuration files

Download the template-files here. Copy all files from the kubernetes directory to an empty Git-Repository (for version control) like this:

└─── UC-API-KUBERNETES
└─── app.yaml
└─── nginx.yaml
└─── psql.yaml

The YAML - files contain all infrastructure components you need to deploy on the cluster. Before you start with the deployment, read carefully through all files and change the placeholder-values that you need to change.

Sizing Requirements

The requested resources can only be estimated on a high level. Please keep an eye on your cluster to see the current usage of CPU, RAM and disk space. This repository also contains a k6-testrun-file you can use to trigger load- and performance-tests on your cluster. As a rule of thumb, you can use the following resources as minimum for the pods:

Monthly UsersAppDatabaseWebserver
0 - 300.0002x Pods, each 2 vCPU 2 GiB RAM2x Pods, each 2 vCPU 2 GiB RAM, shared PV with 1 TiB storage2x Pods, each 2 vCPU 2 GiB RAM
300.000 - 1.000.0004x Pods, each 2 vCPU 2 GiB RAM4x Pods, each 2 vCPU 2 GiB RAM, shared PV with 2 TiB storage4x Pods, each 2 vCPU 2 GiB RAM
1.000.000 - 2.000.0008x Pods, each 2 vCPU 2 GiB RAM8x Pods, each 2 vCPU 2 GiB RAM, shared PV with 4 TiB storage8x Pods, each 2 vCPU 2 GiB RAM

Installation

  1. Install kubectl and connect to the Kubernetes-Cluster with kubectl according to this documentation

  2. Check the existing namespaces with kubectl get namespaces. Create a new namespace with kubectl create namespace ucapi (or any other namespace name that is available) and make sure to adjust the namespace in all YAML - files accordingly

  3. In the next steps, you'll deploy the different components to the Cluster. Before you proceed, make sure that you have adjusted the YAML configuration files according to your needs and uploaded a repository secret to access the images.

  4. Start with the PostgreSQL-Database (you can skip this if you're using a database outside of the cluster). Create a secret that contains the credentials for the Postgres-DB. Make sure to use a secure password:

kubectl create secret -n ucapi \
generic \
postgres-secret \
--from-literal=POSTGRES_DB=uc_db \
--from-literal=POSTGRES_USER=ucapi \
--from-literal=POSTGRES_PASSWORD=secret
  1. Now deploy the database by running kubectl apply -f psql.yaml

  2. Next, deploy the App by running kubectl apply -f app.yaml

  3. Check if the pod(s) are running as expected: kubectl get pods -n ucapi. Also verify the database status by checking the logs of the pods with kubectl logs POD_NAME -n ucapi. The App-Pod should send a "connection success" in the logs

  4. Next, deploy the NGINX reverse proxy with kubectl apply -f nginx.yaml. Make sure that you have updated the configurations in the file before!

  5. Upload your static files in the /var/www/ directory of one of the NGINX-Pods

  6. Make sure to expose the NGINX-Service via an Ingress to the Internet, for example with NGINX Ingress Controller

  7. You're done! Make sure to properly test to access all static files and to store consents!