LAB16a: Deploying Stateful Application

LAB 200: Deploying Stateful Application

Installing Guestbook Application

  1. Install Frontend

cd frontend
kubectl apply -f configmap.yaml
kubectl apply -f service.yaml
kubectl apply -f deployment.yaml
  1. Install Backend

cd ../backend
kubectl apply -f secret.yaml
kubectl apply -f configmap.yaml
kubectl apply -f service.yaml
kubectl apply -f deployment.yaml
  1. Deploy database

cd ../database
kubectl apply -f secret.yaml
kubectl apply -f service.yaml
kubectl apply -f deployment.yaml
  1. Install Ingress

  1. Test the app

Next let's configure ssl

Create Your Own CA and TLS Certificates

We’ll generate:

  1. CA private key

  2. CA certificate

  3. Server private key

  4. Server CSR

  5. Server certificate signed by CA (for guestbook.frontend.laliguras.hotel)


  1. Create CA Private Key


  1. Create CA Certificate

This is your root certificate authority.


  1. Generate Server Private Key


  1. Create CSR (Certificate Signing Request)


  1. Create SAN Config File (Recommended)

Create san.cnf:


  1. Sign Server Certificate With Your CA

Resulting files:

  • tls.key → Server private key

  • tls.crt → Server certificate

  • ca.crt → CA certificate

Create Kubernetes TLS Secret

  1. Using kubectl command

  1. Update Ingress to use HTTPS

::: spoiler traefik ingress configuration Here is the Traefik equivalent of your NGINX Ingress.

Traefik does NOT use annotations for SSL redirect or advanced routing—most capabilities are automatic or moved into Middleware.


You’re expecting Traefik to route requests to your guestbook app, but your Ingress is configured for NGINX, not Traefik.

Let’s break down the issue and give you the correct Traefik config.


Fix: Change your Ingress to use Traefik

Replace:

WITH:

Traefik’s default ingress class in K3s is usually "traefik".


Correct Ingress for Traefik

Use this:

Verify Traefik is receiving the Ingress

Before applying:

Expected output:


Test again:

You should now get the frontend response.

TLS Configuration

Secret name: nginx-tls-secretTLS hosts:

  • guestbook.frontend.deepak.hotel

  • guestbook.backend.deepak.hotelIngressClass: traefikEntryPoints: websecure (port 443)


Traefik TLS Ingress (Using Your Secret)

Apply this:


HTTP → HTTPS redirect, use this annotation:

Add this:

Create Middleware:

This forces automatic redirect.


Test the Ingress

  1. HTTPS:

Backend:

To enable access log in the Traefik controller

  1. Update Traefik static pod

  1. Apply the Updated Config

  1. Check logs

:::

Also update backend url in frontend configmap

backend_uri: "https://guestbook.backend.laliguras.hotel:30334/guestbook"

Next let's configure external Loadbalancer

HA Proxy loadbalancer configuration guide herearrow-up-right

Let's Test

Let's use EmptyDir volume and test

Database deployment snippet

Let's configure NFS storage for dynamic storage provisioning with Storageclass

Nfs storage provisioner setuparrow-up-right

Configuring Mongodb replica

Check mongodb read/write workload balancing

Last updated