Kubernetes Overview
Understand Kubernetes architecture, pods, deployments, and services for container orchestration.
What you'll learn
- What Kubernetes is and why it exists
- Core concepts: pods, deployments, services
- The control plane and worker nodes
- Basic kubectl commands
Concept
What Is Kubernetes?
Kubernetes (K8s) is a container orchestration platform. When you have a few containers, Docker Compose works fine. But when you have hundreds or thousands of containers across multiple servers, you need a way to schedule them, keep them running, scale them, and connect them. Kubernetes automates all of this. It decides which server runs which container, restarts failed containers, scales them up or down based on load, and rolls out updates without downtime.
Core Concepts
A Pod is the smallest unit in Kubernetes — it runs one or more containers together. A Deployment manages a set of identical pods, handling rolling updates and scaling. A Service provides a stable network address for a set of pods, load-balancing across them. A ConfigMap stores configuration, and a Secret stores sensitive data. These abstractions let you describe your application declaratively — Kubernetes works to make reality match your description.
Architecture
A Kubernetes cluster has a control plane (the brain) and worker nodes (the muscle). The control plane runs the API server, scheduler, and controller manager — it makes decisions. Worker nodes run your pods — they do the actual work. Each node runs kubelet (which talks to the control plane) and kube-proxy (which handles networking). You interact with the control plane via kubectl, the Kubernetes command-line tool.
kubectl Basics
kubectl get pods lists running pods. kubectl apply -f deployment.yaml creates or updates resources from a file. kubectl logs <pod> shows a pod's logs. kubectl exec -it <pod> -- bash opens a shell in a pod. kubectl scale deployment myapp --replicas=5 scales a deployment. kubectl describe pod <pod> shows detailed information for debugging. These commands are the daily tools of a Kubernetes engineer.
Helm and Package Management
Helm is the package manager for Kubernetes. A Helm chart is a collection of templates that generate Kubernetes manifests, parameterized by a values file. Instead of writing YAML from scratch, you install a chart: helm install myapp ./chart. The public Helm repository has charts for databases, monitoring tools, and common applications. Helm makes it easy to share, version, and reuse Kubernetes configurations, just as package managers do for application code.
Example
# A Kubernetes Deployment and Service
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: web
image: myapp:1.0
ports:
- containerPort: 80
resources:
limits:
memory: "256Mi"
cpu: "500m"
---
apiVersion: v1
kind: Service
metadata:
name: myapp
spec:
selector:
app: myapp
ports:
- port: 80
targetPort: 80
type: LoadBalancer
The Deployment runs 3 replicas of the myapp container with resource limits. The Service exposes them via a load balancer. The --- separator divides multiple resources in one file.
Try it
- YAML Validator
Validate Kubernetes manifest YAML files.
- YAML to JSON
Convert K8s manifests to JSON for inspection.
- Docker Compose Generator
Generate compose files as a K8s alternative.
Common mistakes
The mistake
Not setting resource requests and limits
The fix
Always set CPU and memory requests and limits on containers. Without them, Kubernetes cannot schedule efficiently, and a single pod can consume all node resources.
The mistake
Using :latest tag for container images
The fix
Use specific version tags. Kubernetes won't pull a new :latest image if it already has one cached. Versioned tags ensure updates are actually deployed.
Practice Kubernetes Overview
4 exercises
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.