Getting an application running on Kubernetes is the easy part. Keeping it running through deployments, traffic spikes, and node failures depends on a short list of settings that are easy to skip when a manifest "already works".
This checklist collects those settings in one place, with a complete example at the end.
1. Health probes
Kubernetes can only route traffic sensibly if it knows whether your container is ready and alive.
- Readiness probe: "Can this pod receive traffic right now?" A failing readiness probe removes the pod from the Service without restarting it.
- Liveness probe: "Is this process stuck?" A failing liveness probe restarts the container.
- Startup probe: for slow-starting applications, it holds off liveness checks until the app has started.
2. Resource requests and limits
Requests tell the scheduler how much CPU and memory a pod needs. Limits cap what it can use.
- Always set memory requests and limits. A container that exceeds its memory limit is killed, which is better than starving its neighbours.
- Set CPU requests based on observed usage. Be careful with CPU limits: they throttle the container even when the node has spare capacity.
- Measure first. Start from real usage data rather than guesses.
3. Safe rollouts
The default rolling update can briefly reduce capacity. For user-facing services, be explicit:
maxUnavailable: 0keeps full capacity during a rollout.maxSurge: 1adds one new pod at a time.- Combined with a readiness probe, old pods only stop once new pods are ready.
Watch a rollout and undo it quickly if it goes wrong:
kubectl rollout status deployment/web
kubectl rollout undo deployment/web4. Configuration and secrets
- Keep configuration in ConfigMaps and credentials in Secrets, not baked into the image.
- Build one image and promote it through environments by changing configuration, not by rebuilding.
- Remember that Secrets are only base64-encoded by default. Restrict who can read them, and consider encryption at rest or an external secret manager.
5. Availability during maintenance
When nodes are drained for upgrades, Kubernetes evicts pods. A PodDisruptionBudget stops it from evicting too many replicas of the same service at once. Pair it with at least two replicas.
6. Container security basics
- Run as a non-root user.
- Use a read-only root filesystem where possible, and mount a writable volume only where the app needs one.
- Drop Linux capabilities the application does not need.
- Pin image versions. Avoid
latestin production.
Putting it together
Here is a Deployment and PodDisruptionBudget that apply the checklist. Adjust the numbers to your application's measured behaviour.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 3
selector:
matchLabels:
app: web
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
template:
metadata:
labels:
app: web
spec:
securityContext:
runAsNonRoot: true
containers:
- name: web
image: registry.example.com/web:1.4.2
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: web-config
- secretRef:
name: web-secrets
resources:
requests:
cpu: 250m
memory: 256Mi
limits:
memory: 512Mi
readinessProbe:
httpGet:
path: /ready
port: 8080
periodSeconds: 5
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 10
periodSeconds: 10
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: web
spec:
minAvailable: 2
selector:
matchLabels:
app: webWhen something still goes wrong
A short diagnostic sequence covers most cases:
kubectl get pods -l app=web
kubectl describe pod <pod-name> # events: scheduling, probe failures, OOMKilled
kubectl logs <pod-name> --previous # logs from the container before it restarteddescribe is usually the fastest route to the answer. The events at the bottom show whether the problem is scheduling, image pulls, failed probes, or memory.
Takeaways
None of these settings are advanced, but together they remove the most common causes of avoidable downtime: traffic sent to pods that are not ready, restarts triggered by dependencies, capacity drops during rollouts, and evictions during maintenance. Make them part of every service's baseline, and reliability stops depending on luck.