Skip to main content

Kubernetes in production: 7 essential best practices

· 2 min read
Karim Benali
Kubernetes Architect @ InSkillOps

Running Kubernetes locally is one thing; operating it in production is another. Here are 7 practices we apply consistently on our clusters.

1. Set requests and limits

Without requests/limits, a pod can starve its neighbours. Always set realistic values:

resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "500m"
memory: "256Mi"

2. Configure probes

Liveness and readiness probes prevent traffic from reaching a pod that isn't ready (or is stuck):

livenessProbe:
httpGet: { path: /healthz, port: 3000 }
initialDelaySeconds: 10
readinessProbe:
httpGet: { path: /ready, port: 3000 }

3. Enable autoscaling

The Horizontal Pod Autoscaler adjusts the number of replicas based on load:

kubectl autoscale deployment my-app --cpu-percent=70 --min=2 --max=10

4. Lock down access with RBAC

Apply the principle of least privilege: each ServiceAccount gets only the permissions it needs.

5. Isolate with namespaces

Separate environments (dev, staging, prod) and teams by namespace, with ResourceQuotas to avoid overruns.

6. Never store secrets in plain text

Use Kubernetes Secrets, encrypted at rest, or an external manager (Vault, AWS Secrets Manager). Never a password in an image or a versioned manifest.

7. Monitor and alert

Prometheus + Grafana for metrics, a centralized logging stack, and alerts on key signals (error rate, latency, saturation).


These practices form the basis of a robust cluster. We detail them with hands-on labs in the Kubernetes path.