Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.
5.3.1. Kubernetes Concepts and Docker Compose
Docker Compose — Multi-Container Applications:
Compose defines multi-container applications in a single YAML file. It's designed for development and single-host deployments where you need multiple containers working together.
# docker-compose.yml
version: '3.8'
services:
web:
image: nginx:1.25
ports:
- "80:80"
volumes:
- ./html:/usr/share/nginx/html:ro
depends_on:
- app
app:
build: ./app # Build from ./app/Dockerfile
environment:
- DATABASE_URL=postgresql://user:pass@db:5432/mydb
restart: unless-stopped
db:
image: postgres:15
volumes:
- pgdata:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: "${DB_PASSWORD}" # From .env file
volumes:
pgdata: # Named volume managed by Compose
docker-compose up -d # Start all services (detached)
docker-compose down # Stop and remove containers
docker-compose ps # Status of services
docker-compose logs -f app # Follow logs for 'app' service
docker-compose exec app bash # Shell into running container
docker-compose build # Rebuild images
docker-compose pull # Pull latest images
Kubernetes Concepts:
Kubernetes (K8s) is the dominant container orchestration platform. Key objects:
| K8s Object | Purpose |
|---|---|
| Pod | Smallest deployable unit; 1+ containers sharing network/storage |
| Deployment | Declares a desired number of Pod replicas; its controller (through a ReplicaSet) creates a replacement whenever a Pod fails, is deleted, or is lost with its node, restoring that count; handles rolling updates |
| Service | Stable network endpoint for a set of Pods (load balancing) |
| ConfigMap | Non-secret configuration data for Pods |
| Secret | Sensitive data (passwords, keys) injected into Pods |
| Namespace | Logical cluster partition; isolates resources |
| Node | Physical or virtual machine running kubelet |
| Ingress | HTTP routing rules to Services (path/host-based routing) |
# kubectl — Kubernetes CLI
kubectl get pods # List Pods in default namespace
kubectl get pods -n kube-system # List Pods in kube-system namespace
kubectl get all # All objects in namespace
kubectl describe pod mypod # Detailed info including events
kubectl logs mypod # Container logs
kubectl logs -f mypod # Follow logs
kubectl exec -it mypod -- /bin/bash # Shell into Pod
kubectl apply -f deployment.yaml # Create/update from manifest
kubectl delete -f deployment.yaml # Delete resources in manifest
kubectl scale deployment myapp --replicas=5 # Scale Deployment
kubectl rollout status deployment/myapp # Watch rolling update
kubectl rollout undo deployment/myapp # Rollback to previous version
⚠️ Exam Trap: kubectl scale (like kubectl edit) changes only the live object. The manifest file — or the Git repository, under GitOps — still holds the old value, so the next kubectl apply of that file, or the next reconciliation, puts it back. To stay declarative, change the manifest and apply it, or update the manifest immediately after an emergency imperative change.
Enroll to unlock the 4 flashcards for this section and review them on a spaced-repetition schedule.
Written byAlvin Varughese
Founder•20 professional certifications