Sunday, September 7, 2025

Kubernetes: high level best practices

1. Running Everything in the Default Namespace

This quickly becomes messy, especially when you scale to multiple apps and environments.

Fix: Always create and use separate namespaces for applications, environments (dev, staging, prod), and monitoring tools.

2. Forgetting to Define Resource Requests and Limits

Without CPU and memory requests/limits, pods can consume unlimited resources, leading to instability or even node crashes.

Fix: Always define resources.requests and resources.limits in your pod specs.

3. Ignoring Liveness and Readiness Probes

Beginners often skip health probes. Without them, Kubernetes won’t know when your app is ready or if it’s stuck.

 Fix: Always configure readiness probes (for traffic) and liveness probes (for restarts).

4. Hardcoding Configurations Inside Pods

Putting configuration values (like DB passwords, API keys) directly inside pod definitions is a rookie mistake.

Fix: Use ConfigMaps for non-sensitive configs and Secrets for sensitive data.

5. Exposing Applications Using NodePort

Many start with NodePort, but it’s not production-grade and makes apps hard to access securely.

Fix: Use Ingress controllers (NGINX, Traefik, etc.) with proper domain names and TLS.

6. Not Using Labels and Selectors Properly

Labels are the glue of Kubernetes. Without consistent labeling, managing workloads, deployments, and monitoring is a nightmare.

Fix: Define a clear labeling strategy (app, env, version) and stick to it.

7. Overlooking RBAC (Role-Based Access Control)

Running everything with cluster-admin privileges is risky. It’s common for beginners to skip RBAC setup entirely.

Fix: Use least-privilege access and set up RBAC roles early.

8. Forgetting About Persistent Volumes

Beginners often assume storage works like stateless pods. When a pod restarts, all data inside disappears.

 Fix: Use PersistentVolumes (PV) and PersistentVolumeClaims (PVC) for stateful apps.

9. Not Monitoring and Logging

Kubernetes without observability is like flying blind. Many beginners only check pod status and logs manually.

Fix: Use monitoring tools like Prometheus + Grafana and logging with ELK stack or Loki.

10. Deploying Without Understanding the Basics

Many jump straight into complex Helm charts and operators without understanding Pods, Services, and Deployments first.

Fix: Master the fundamentals before moving on to advanced tooling.

references:
https://aws.plainenglish.io/10-kubernetes-mistakes-beginners-make-and-how-to-avoid-them-5c92f5766605

No comments:

Post a Comment