Kubernetes Core Concepts
Learn the building blocks of Kubernetes: pods, deployments, services, and namespaces. Understand how K8s orchestrates containers at scale.
What Kubernetes Solves
Docker runs containers on a single machine. Kubernetes runs them across a cluster of machines, handling:
- Scheduling — deciding which node runs each container
- Scaling — adding/removing replicas based on load
- Self-healing — restarting failed containers automatically
- Service discovery — letting containers find each other
- Rolling updates — deploying new versions with zero downtime
Pods
A pod is the smallest deployable unit — one or more containers that share network and storage. In practice, most pods run a single container.
apiVersion: v1
kind: Pod
metadata:
name: web
labels:
app: web
spec:
containers:
- name: app
image: myapp:latest
ports:
- containerPort: 3000Deployments
A deployment manages a set of identical pods. It handles scaling, rolling updates, and rollbacks. You almost never create pods directly — use deployments instead.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: app
image: myapp:v2
ports:
- containerPort: 3000
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "500m"Services
A service provides a stable network endpoint for a set of pods. Pods are ephemeral — they get new IPs when restarted. Services give them a consistent address.
- ClusterIP — internal only (default)
- NodePort — exposes on each node's IP at a static port
- LoadBalancer — provisions a cloud load balancer
apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector:
app: web
ports:
- port: 80
targetPort: 3000
type: LoadBalancerEssential kubectl Commands
These cover day-to-day cluster operations:
# Apply a manifest
kubectl apply -f deployment.yaml
# List pods with status
kubectl get pods -o wide
# View logs
kubectl logs -f deployment/web
# Scale a deployment
kubectl scale deployment/web --replicas=5
# Roll back a bad deployment
kubectl rollout undo deployment/web
# Exec into a running pod
kubectl exec -it web-abc123 -- /bin/shRelated Tutorials
Docker Fundamentals
Get started with Docker containers. Learn images, containers, volumes, networking, and how to write a Dockerfile from scratch.
Git Branching Strategies
Compare Git branching models: trunk-based development, GitHub Flow, and GitFlow. Pick the right strategy for your team size and release cadence.