Why Kubernetes?
When you move beyond a single container, you need something to schedule, scale and heal your workloads. Kubernetes gives you that with a declarative API.
The core objects
- Deployment — declares the desired state of your pods and manages rollouts.
- Service — provides a stable network endpoint for a set of pods.
- ConfigMap / Secret — decouple configuration from images.
A minimal Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 3
selector:
matchLabels: { app: web }
template:
metadata:
labels: { app: web }
spec:
containers:
- name: web
image: myrepo/web:1.0.0
ports:
- containerPort: 3000
Apply it with kubectl apply -f deployment.yaml and expose it with a Service. From there you can layer in liveness probes, resource limits and horizontal autoscaling.
Takeaway
Start declarative, keep manifests in version control, and let Kubernetes reconcile the difference between desired and actual state.