Getting Started with Kubernetes in Production
Kubernetes has become the de facto standard for container orchestration, but running it in production requires more than just kubectl apply. In this post, I’ll share key lessons learned from managing production Kubernetes clusters.
Why Kubernetes?
The shift from monolithic applications to microservices has created a need for sophisticated orchestration tools. Kubernetes solves several critical problems:
- Service discovery and load balancing across dynamic workloads
- Automated rollouts and rollbacks for zero-downtime deployments
- Self-healing through automatic restarts and rescheduling
- Horizontal scaling based on resource utilization
Essential Components for Production
1. Ingress Controller
An ingress controller is your gateway to the cluster. I recommend NGINX Ingress Controller for most use cases:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
annotations:
nginx.ingress.kubernetes.io/rate-limit: "100"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
tls:
- hosts:
- app.example.com
secretName: app-tls
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app-service
port:
number: 80
2. Resource Limits
Always set resource requests and limits. Without them, a single misbehaving pod can take down an entire node:
resources:
requests:
memory: "128Mi"
cpu: "250m"
limits:
memory: "256Mi"
cpu: "500m"
3. Pod Disruption Budgets
Protect your applications during maintenance:
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: app-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: my-app
Monitoring Stack
A production cluster needs comprehensive monitoring. My recommended stack:
| Component | Tool | Purpose |
|---|---|---|
| Metrics | Prometheus | Time-series metrics collection |
| Visualization | Grafana | Dashboards and alerting |
| Logging | Loki | Log aggregation |
| Tracing | Jaeger | Distributed tracing |
Security Best Practices
- Use RBAC - Never run workloads with cluster-admin privileges
- Network Policies - Restrict pod-to-pod communication
- Pod Security Standards - Enforce security contexts
- Image Scanning - Scan images in CI before deployment
- Secrets Management - Use external secret stores (Vault, AWS Secrets Manager)
Key Takeaways
Running Kubernetes in production is a journey, not a destination. Start with the basics, automate everything you can, and invest in observability from day one. The effort pays off with a platform that scales with your organization.
In future posts, I’ll dive deeper into GitOps workflows with ArgoCD and building a complete observability stack.