Back to Home

Kubernetes in Production

Deployments & Workloads

Master deployment strategies, workload types, and best practices for zero-downtime releases.

Understanding Deployments

Deployments provide declarative updates for Pods and ReplicaSets. They are the most common way to run stateless applications in Kubernetes.

Core Concepts

  • Declarative updates: Describe desired state, Kubernetes handles the transition
  • Rolling updates: Gradual rollout of changes with zero downtime
  • Rollback capability: Easy reversion to previous versions if issues occur
  • Scaling: Horizontal scaling by adjusting replica count
  • Self-healing: Automatically replaces failed pods

Deployment Strategies

Rolling Update (Default)

Gradually replaces old pods with new ones

Pros

  • Zero downtime
  • Gradual rollout
  • Easy rollback
  • Resource efficient

Cons

  • Mixed versions during rollout
  • Slower than recreate
Use Case: Most production applications

Recreate

Terminates all old pods before creating new ones

Pros

  • Simple
  • No version mixing
  • Resource cleanup

Cons

  • Downtime during update
  • Not suitable for production
Use Case: Development environments, maintenance windows

Blue-Green

Run two identical environments, switch traffic between them

Pros

  • Instant rollback
  • No version mixing
  • Full testing before switch

Cons

  • Double resources needed
  • Complex setup
Use Case: Critical applications, large releases

Canary

Gradual rollout to subset of users before full deployment

Pros

  • Risk mitigation
  • Real user testing
  • Early issue detection

Cons

  • Complex traffic management
  • Requires monitoring
Use Case: Feature releases, A/B testing

Workload Types

🔄

ReplicaSet

Maintains a stable set of replica pods running at any given time

💾

StatefulSet

For stateful applications requiring stable network identities and persistent storage

📡

DaemonSet

Ensures a pod runs on all (or selected) nodes

Job

Creates pods that run to completion

CronJob

Creates Jobs on a time-based schedule

Best Practices

  • Use health checks (liveness and readiness probes) for reliable rollouts
  • Set appropriate resource requests and limits to prevent resource contention
  • Configure PodDisruptionBudgets to maintain availability during updates
  • Use image tags (not :latest) for reproducible deployments
  • Implement proper monitoring and alerting for deployment health
  • Test rollbacks in staging before relying on them in production

Key Takeaways

  • Deployments enable declarative, automated application updates with rollback capability
  • Choose deployment strategy based on application requirements and risk tolerance
  • Different workload types serve different use cases (stateless, stateful, batch, etc.)
  • Health checks and resource management are critical for reliable deployments