Containerisation and Orchestration with Docker and Kubernetes

Package Python services as lean, secure container images, run multi-container apps with Docker Compose, and deploy, scale and troubleshoot them on Kubernetes.

Advanced · Cloud & DevOps · about 19 hours · 5 modules · certificate on completion

Taught by Dariusz Wojciechowskì, Lachlaneè Mitchèll, AI Learning Companions.

About this course

Containers changed how software is shipped: an image carries an application with everything it needs, and Kubernetes runs those images across a cluster of machines, restarting, scaling and updating them for you. This advanced course takes one realistic service, a FastAPI inventory API with a Redis cache, from a first Dockerfile to a highly available deployment on a Kubernetes cluster on your own laptop. You'll see how containers isolate processes with namespaces and cgroups, write lean multi-stage Dockerfiles that run as a non-root user, and run the API and Redis together with Docker Compose, using healthchecks, networks and volumes.

Then you'll move to Kubernetes with kind: the control plane and nodes, Pods, ReplicaSets, Deployments, Services, namespaces and persistent storage. You'll deploy from declarative manifests with startup, readiness and liveness probes, configuration in ConfigMaps and Secrets, rolling updates and rollbacks, and scale on CPU with the Horizontal Pod Autoscaler. The last module is about running a cluster day to day: kubectl for diagnosis, the common failure states and their fixes, Ingress and Gateway API, quotas and limits, and keeping services up while nodes are drained. Every module ends with a hands-on lab on your own machine, and the capstone brings it together: a Compose setup for developers and Kubernetes manifests that keep serving while you take nodes away.

What you'll learn

  • Write optimised, multi-stage Dockerfiles that package Python services as small images running as a non-root user
  • Run and debug multi-container applications with Docker Compose, using networks, volumes and healthchecks
  • Explain Kubernetes' architecture and its core objects: Pods, ReplicaSets, Deployments, Services and namespaces
  • Deploy and scale applications with declarative manifests, probes, ConfigMaps, Secrets and the Horizontal Pod Autoscaler
  • Troubleshoot and manage cluster resources with kubectl, Ingress, resource quotas and limits

Skills you'll gain

Docker, Dockerfile optimisation, Docker Compose, Kubernetes, kubectl, Kubernetes manifests, Horizontal Pod Autoscaling, Kubernetes troubleshooting, Container security

Tools

Docker, Docker Compose, kind, kubectl, Helm, Python 3, FastAPI, Redis

Before you start

Comfort with the Linux command line and basic Python, as Python Scripting and Linux for DevOps teaches them (Linux Command Line Essentials covers the shell). You need a computer with at least 8 GB of memory and Docker (Docker Desktop on macOS and Windows, Docker Engine on Linux), plus kind, kubectl and Helm. No cloud account is needed.

Modules

  1. Introduction to Containerisation

    How containers differ from virtual machines, how Docker's client, daemon, images and registries fit together, and the container lifecycle, ending with a first Dockerfile for the course's sample service.

    • From virtual machines to containers (12 min)
    • Docker's architecture: client, daemon, images and registries (12 min)
    • The container lifecycle and your first Dockerfile (14 min)
    • Hands-on lab: Run containers and package the inventory API
  2. Docker and Docker Compose

    Write efficient, secure Dockerfiles with layer caching and multi-stage builds, manage images responsibly, and run multi-container applications with Docker Compose, its networks and its volumes.

    • Efficient Dockerfiles: layers, caching and multi-stage builds (14 min)
    • Image hygiene: tags, users, secrets and scanning (12 min)
    • Multi-container apps with Docker Compose (14 min)
    • Hands-on lab: Slim the image and run the stack with Compose
  3. Kubernetes Primitives

    How a Kubernetes cluster is built, and the objects you use every day: Pods, ReplicaSets, Deployments, Services, namespaces and persistent storage, explored on a three-node kind cluster.

    • Kubernetes architecture: the control plane and the nodes (13 min)
    • Pods, ReplicaSets and Deployments (14 min)
    • Services, DNS and namespaces (13 min)
    • Volumes, persistent storage and StatefulSets (12 min)
    • Hands-on lab: Explore Kubernetes primitives on kind
  4. Deploying and Scaling on K8s

    Deploy an application from declarative manifests, keep traffic away from unhealthy Pods with probes, supply configuration and secrets, update it without downtime, and scale it with the Horizontal Pod Autoscaler.

    • Declarative manifests and kubectl apply (12 min)
    • Health checks, resources and rolling updates (14 min)
    • ConfigMaps and Secrets (12 min)
    • Scaling with the Horizontal Pod Autoscaler (12 min)
    • Hands-on lab: Deploy, configure and scale the inventory service
  5. Managing K8s Clusters

    Use kubectl to inspect, diagnose and fix workloads, expose services with Ingress, share a cluster fairly with quotas and limits, and keep applications available while nodes are drained and upgraded.

    • kubectl for operators: contexts, output and inspection (12 min)
    • Troubleshooting Pods that won't run or won't serve (14 min)
    • Ingress, quotas and limits (13 min)
    • Keeping applications available during maintenance (12 min)
    • Hands-on lab: Troubleshoot a broken namespace

Project: Ship a highly available inventory service

Take inventory-api from a developer's laptop to a small but production-shaped Kubernetes deployment. Package it with a lean, multi-stage Dockerfile that runs as a non-root user, and give developers a compose.yaml that runs the API and Redis with healthchecks, a private network and a persistent volume. Then write numbered Kubernetes manifests for a three-node kind (or minikube) cluster: a namespace with a ResourceQuota and a LimitRange; Redis as a StatefulSet (or a Deployment with the Recreate strategy) with its data on a PersistentVolumeClaim and its password in a Secret created outside Git; the API with at least three replicas spread across nodes, startup, readiness and liveness probes, requests and limits, settings from a ConfigMap, a PodDisruptionBudget and a HorizontalPodAutoscaler; and access from your computer through a NodePort or an Ingress. Prove it works with the smoke test, keep it serving while you delete an API Pod and drain a worker node that isn't running Redis, and document how to run and operate it.

Part of

The products this course names are trademarks of their owners, who haven't made or endorsed it.

Start the course free