Why Kubernetes?
Docker gets your app into a container. Kubernetes gets that container running reliably at scale. It handles scheduling, self-healing, scaling, and rolling updates automatically — things that would take weeks to build manually.
In this guide, we'll use kind (Kubernetes in Docker) to spin up a local cluster and deploy a simple web app. No cloud account needed.
Prerequisites
- Docker installed and running
- kubectl CLI installed
- kind installed (
brew install kindor see kind.sigs.k8s.io)
Step 1: Create a Local Cluster
# Create a cluster named "devops-lab"
kind create cluster --name devops-lab
# Verify it's running
kubectl cluster-info --context kind-devops-lab
kubectl get nodes
You should see one node in Ready status within about 60 seconds.
Step 2: Understand the Core Concepts
Before deploying, know these three objects:
- Pod — the smallest deployable unit, wraps one or more containers
- Deployment — manages a set of identical Pods, handles rollouts and rollbacks
- Service — exposes your Pods to the network (internally or externally)
Step 3: Write Your First Deployment
Create a file called deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-app
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.25-alpine
ports:
- containerPort: 80
resources:
requests:
cpu: "50m"
memory: "64Mi"
limits:
cpu: "100m"
memory: "128Mi"
Apply it:
kubectl apply -f deployment.yaml
kubectl get pods -w # watch pods come up
Step 4: Expose it with a Service
Create service.yaml:
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
type: NodePort
kubectl apply -f service.yaml
kubectl port-forward service/nginx-service 8080:80
Open http://localhost:8080 — you should see the nginx welcome page. You just deployed your first app on Kubernetes.
Step 5: Scale and Self-Heal
Try killing a pod and watch Kubernetes bring it back:
# Scale to 5 replicas
kubectl scale deployment nginx-app --replicas=5
# Delete a pod — Kubernetes will recreate it automatically
kubectl delete pod $(kubectl get pods -l app=nginx -o jsonpath='{.items[0].metadata.name}')
# Watch the magic
kubectl get pods -w
Key Takeaways
- Kubernetes separates what you want (desired state) from how it gets there
- The control loop constantly reconciles actual state with desired state
- Always set resource requests and limits — without them, a noisy pod can starve your entire cluster
- Start with Deployments, Services, and ConfigMaps — those three cover 80% of real use cases

Member discussion