Why Container Orchestration?
Running a single container is easy. Running hundreds across multiple servers requires orchestration.
Challenges Without Orchestration
| Challenge | Solution with K8s |
|---|---|
| Container crashes | Auto-restart and self-healing |
| Traffic spikes | Auto-scaling |
| Server failures | Rescheduling to healthy nodes |
| Deployments | Rolling updates, zero downtime |
| Service discovery | Built-in DNS and load balancing |
| Configuration | ConfigMaps and Secrets |
Kubernetes Architecture
┌─────────────────────────────────────────────────────────┐
│ Control Plane │
│ ┌──────────┐ ┌───────────┐ ┌──────────┐ ┌──────────┐ │
│ │API Server│ │ Scheduler │ │Controller│ │ etcd │ │
│ │ │ │ │ │ Manager │ │(Key-Value)│ │
│ └──────────┘ └───────────┘ └──────────┘ └──────────┘ │
└────────────────────────┬────────────────────────────────┘
│
┌───────────────┼───────────────┐
│ │ │
┌────────▼────────┐ ┌───▼──────────┐ ┌──▼───────────┐
│ Worker Node 1 │ │ Worker Node 2│ │ Worker Node 3│
│ ┌─────┐ ┌─────┐│ │ ┌─────┐ │ │ ┌─────┐ │
│ │Pod A│ │Pod B││ │ │Pod C│ │ │ │Pod D│ │
│ └─────┘ └─────┘│ │ └─────┘ │ │ └─────┘ │
│ ┌──────────────┐│ │ ┌──────────┐ │ │ ┌──────────┐ │
│ │kubelet│kube- ││ │ │kubelet │ │ │ │kubelet │ │
│ │ │proxy ││ │ │kube-proxy│ │ │ │kube-proxy│ │
│ └──────────────┘│ │ └──────────┘ │ │ └──────────┘ │
└─────────────────┘ └──────────────┘ └──────────────┘
Control Plane Components
| Component | Role |
|---|---|
| API Server | Front door to the cluster — all communication goes through it |
| etcd | Distributed key-value store for cluster state |
| Scheduler | Assigns pods to nodes based on resources |
| Controller Manager | Runs controllers (ReplicaSet, Deployment, etc.) |
Worker Node Components
| Component | Role |
|---|---|
| kubelet | Agent that ensures containers are running in pods |
| kube-proxy | Network proxy for service communication |
| Container Runtime | Runs containers (containerd, CRI-O) |
Core Kubernetes Objects
Pods
The smallest deployable unit — one or more containers sharing network and storage.
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.25
ports:
- containerPort: 80Deployments
Manage pod replicas with rolling updates and rollbacks.
Services
Expose pods to network traffic (internal or external).
Namespaces
Logical isolation within a cluster.
Installing kubectl & Minikube
kubectl (Kubernetes CLI)
# macOS
brew install kubectl
# Linux
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
# Verify
kubectl version --clientMinikube (Local Cluster)
# macOS
brew install minikube
# Linux
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
# Start a cluster
minikube start --driver=docker
# Verify
kubectl cluster-info
kubectl get nodesEssential kubectl Commands
# Cluster info
kubectl cluster-info
kubectl get nodes
# Namespaces
kubectl get namespaces
kubectl create namespace dev
# View resources
kubectl get pods
kubectl get pods -A # All namespaces
kubectl get deployments
kubectl get services
# Describe a resource
kubectl describe pod nginx-pod
# Logs
kubectl logs nginx-pod
kubectl logs -f nginx-pod # Follow logs
# Execute into a pod
kubectl exec -it nginx-pod -- /bin/bashDeclarative vs Imperative
# Imperative (quick, not reproducible)
kubectl run nginx --image=nginx:1.25
kubectl expose pod nginx --port=80
# Declarative (recommended, version-controlled)
kubectl apply -f deployment.yaml
kubectl apply -f service.yamlAlways prefer declarative YAML manifests for production workloads.
Summary
You've learned:
- Why container orchestration is essential at scale
- Kubernetes architecture (control plane + worker nodes)
- Core objects: Pods, Deployments, Services, Namespaces
- How to install kubectl and Minikube
- Imperative vs declarative approaches
Next Steps
Next, we'll create Pods and Deployments to run applications on Kubernetes.