Kubernetes
Container orchestration platform - deploy, scale, and manage containerized applications across clusters with automatic healing and rolling updates.
skill: Kubernetes category: Backend tags: [Kubernetes, K8s, Containers, Helm, DevOps] readingTime: 8
Kubernetes is justified when you have multiple services that need independent scaling, rolling updates, and self-healing. For a monolith or small team, Kubernetes adds operational complexity without proportional benefit - Docker Compose on a single VM or a managed PaaS (Railway, Render, Fly.io) is simpler.
Workflow
- Understand the core objectsKubernetes has many objects - understanding the 6 most common covers 90% of day-to-day work.
- Write a DeploymentA Deployment declares the desired state - Kubernetes continuously reconciles the actual state to match it.
- Expose with a Service and IngressA Service gives Pods a stable DNS name. An Ingress routes external HTTP/HTTPS traffic to Services by hostname or path.
- Manage config with ConfigMaps and SecretsHardcoding config in images violates 12-factor app principles. ConfigMaps and Secrets decouple config from the image.
- Package with HelmHelm charts template Kubernetes manifests - enabling parameterized deployments across environments (dev, staging, prod) without duplicating YAML.
Output Format
Kubernetes deployment: Deployment + Service + Ingress + ConfigMap + Secret + HPA, packaged as Helm chart.
k8s/
├── Chart.yaml
├── values.yaml # Default config
├── values.prod.yaml # Production overrides
└── templates/
├── deployment.yaml
├── service.yaml
├── ingress.yaml
├── configmap.yaml
├── secret.yaml
└── hpa.yamlExamples
Input
Output
Edge Cases & Gotchas
- OOMKilled pods - Pod is killed when memory exceeds limits. Increase limits or fix memory leaks. Monitor with kubectl top pods.
- ImagePullBackOff - Image can't be pulled - wrong tag, private registry missing imagePullSecret, or network issue. kubectl describe pod shows the exact error.
- Pending pods - Pod stays Pending when no node has enough resources. kubectl describe pod shows the scheduling failure reason. Scale the node pool or reduce resource requests.
- Secret data is only base64-encoded - Kubernetes Secrets are not encrypted at rest by default. Enable etcd encryption or use external secrets (AWS Secrets Manager, Vault) for production.
When to Break These Rules
- Use a managed PaaS (Railway, Render, Fly.io) instead of Kubernetes for teams < 10 engineers or single-service applications - Kubernetes operational overhead isn't worth it.
- Use AWS ECS or Google Cloud Run for containerized workloads that don't need Kubernetes' scheduling complexity - both are simpler to operate.
Reference Files
https://kubernetes.io/docs/home/https://helm.sh/docs/