Video Thumbnail for Lesson
7.1: Authoring Kubernetes Manifests

Authoring Kubernetes Manifests

Deploying the demo application involves turning each microservice and the database into Kubernetes resources. The full manifests live in the course repo.

Resource Overview

  • Deployments for api-golang, api-node, client-react, and load-generator-python
  • StatefulSet for PostgreSQL installed via a Helm chart
  • Services exposing each Deployment and the database
  • Traefik ingress controller with IngressRoute resources
  • ConfigMaps and Secrets for configuration and credentials
  • A Job to run the initial database migration

Using Taskfile

Each directory contains a Taskfile.yaml to simplify deployment. Common commands are:

# Install Postgres and apply migrations
task postgresql:install-postgres
task postgresql:apply-initial-db-migration-job

# Deploy Traefik ingress controller
task common:deploy-traefik

# Apply application manifests
task api-golang:apply
task api-node:apply
task client-react:apply

# Deploy the load generator (requires an image pull secret)
task load-generator-python:create-image-pull-secret
task load-generator-python:apply

Running task apply-all will execute these steps in order.

Example Manifests

Go API Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-golang
  namespace: demo-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: api-golang
  template:
    metadata:
      labels:
        app: api-golang
    spec:
      containers:
        - name: api-golang
          image: sidpalas/devops-directive-docker-course-api-golang:foobarbaz
          envFrom:
            - secretRef:
                name: api-golang-database-url
          ports:
            - containerPort: 8000

Traefik IngressRoute

apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: api-golang-route
  namespace: demo-app
spec:
  entryPoints:
    - web
  routes:
    - match: Host(`kubernetescourse.devopsdirective.com`) && PathPrefix(`/api/golang`)
      kind: Rule
      services:
        - name: api-golang
          port: 8000

Once all resources are applied, Traefik exposes the services behind a cloud load balancer. The load generator continuously calls the Node API so you can observe traffic flowing through the stack.