A beginner-friendly walkthrough of core Kubernetes concepts — Pods, Deployments, and Services — with real YAML examples.
Kubernetes (K8s) is the industry-standard container orchestration platform. It's intimidating at first, but the core concepts are straightforward once you see them in action.
| Concept | What It Does |
|---|---|
| Pod | The smallest deployable unit — wraps one or more containers |
| Deployment | Manages replicas of a Pod and handles rolling updates |
| Service | Stable network endpoint to reach your Pods |
| Namespace | Virtual cluster for isolating resources |
apiVersion: v1
kind: Pod
metadata:
name: my-app
labels:
app: my-app
spec:
containers:
- name: app
image: node:20-alpine
ports:
- containerPort: 3000
Apply it:
kubectl apply -f pod.yaml
kubectl get pods
Never run bare Pods in production. Use a Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: app
image: myrepo/my-app:latest
ports:
- containerPort: 3000
env:
- name: NODE_ENV
value: "production"
apiVersion: v1
kind: Service
metadata:
name: my-app-service
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 3000
type: LoadBalancer
# Apply any manifest
kubectl apply -f deployment.yaml
# Watch pods start up
kubectl get pods -w
# Check logs
kubectl logs deployment/my-app
# Exec into a container
kubectl exec -it <pod-name> -- /bin/sh
# Delete everything
kubectl delete -f deployment.yaml
Kubernetes has a steep learning curve but understanding Deployments and Services alone gets you 80% of the way there for most applications.