11 Kubernetes Deployment Management
Kubernetes Deployment Management ensures reliable, scalable application deployment through automated lifecycle processes and orchestration in containerized environments.
Kubernetes Deployment Management is the practice of using the Deployment object to declaratively control how a stateless application's Pods are created, updated, scaled, and rolled back, without requiring operators to manually orchestrate the underlying ReplicaSets or individual Pods involved in a release.
The Deployment Object
Desired State for Applications
A Deployment specifies a Pod template, a desired replica count, and an update strategy. The Deployment controller continuously reconciles this desired state against the cluster, creating and managing ReplicaSets to bring the actual number and version of running Pods in line with what was declared.
Ownership Chain
A Deployment owns one or more ReplicaSets, and each ReplicaSet owns a set of Pods. This layered ownership is what allows a Deployment to keep multiple ReplicaSets around temporarily during a rollout, and to retain old ones for rollback purposes.
Update Strategies
RollingUpdate
The default update strategy gradually replaces old Pods with new ones, controlled by two parameters: maxUnavailable, the maximum number of Pods that can be unavailable during the update, and maxSurge, the maximum number of extra Pods that can be created above the desired count during the transition.
Recreate
The Recreate strategy terminates all existing Pods before creating replacements, resulting in a period of downtime but guaranteeing that old and new versions never run simultaneously, which is sometimes required for applications that cannot tolerate mixed versions.
Rolling Out a Change
Triggering a Rollout
Any change to a Deployment's Pod template, such as updating the container image, environment variables, or resource limits, triggers a new rollout. Changes to fields outside the Pod template, such as the replica count alone, instead trigger scaling rather than a new rollout.
Monitoring Rollout Progress
A rollout's progress can be observed through the Deployment's status conditions, which report whether the rollout is progressing, has completed, or has stalled due to failing Pods, giving operators visibility into whether a release is succeeding before it fully replaces the previous version.
Rollbacks
Revision History
Deployments retain a history of previous ReplicaSets, each representing a prior revision of the Pod template, up to a configurable limit. This history allows an operator to revert to any retained prior revision.
Automatic Rollback Conditions
Some deployment strategies incorporate automated rollback triggers, reverting to the last known good revision if health checks or external validation signals indicate the new revision is unhealthy, reducing the time a faulty release remains live.
Scaling a Deployment
Manual Scaling
The replica count of a Deployment can be adjusted directly, causing the underlying ReplicaSet to create or terminate Pods to match the new count without triggering a rollout, since the Pod template itself has not changed.
Autoscaling Integration
A Deployment's replica count can also be managed automatically by a Horizontal Pod Autoscaler, which adjusts it based on observed metrics such as CPU utilization, removing the need for manual intervention as load fluctuates.
Deployment Rollout Diagram
This combination of controlled rollout strategies, revision history, and integration with autoscaling makes Deployments the primary mechanism for managing the lifecycle of stateless applications in Kubernetes.
Content in this section
- 11.1 Kubernetes Deployment Management Scope
- 11.2 Kubernetes Deployment Object Management
- 11.3 Kubernetes Deployment Spec Management
- 11.4 Kubernetes Deployment Selector Management
- 11.5 Kubernetes Deployment Pod Template Management
- 11.6 Kubernetes Deployment Replica Management
- 11.7 Kubernetes Deployment Manual Scaling
- 11.8 Kubernetes Deployment Rollout Management
- 11.9 Kubernetes Deployment Rolling Update Management
- 11.10 Kubernetes Deployment Recreate Strategy Management
- 11.11 Kubernetes Deployment Image Update Management
- 11.12 Kubernetes Deployment Environment Update Management
- 11.13 Kubernetes Deployment Annotation Management
- 11.14 Kubernetes Deployment Restart Management
- 11.15 Kubernetes Deployment Pause Management
- 11.16 Kubernetes Deployment Resume Management
- 11.17 Kubernetes Deployment Rollback Management
- 11.18 Kubernetes Deployment Revision History Management
- 11.19 Kubernetes Deployment Status Management
- 11.20 Kubernetes Deployment Condition Management
- 11.21 Kubernetes Deployment Availability Management
- 11.22 Kubernetes Deployment Progress Management
- 11.23 Kubernetes Deployment Ownership Management
- 11.24 Kubernetes Deployment Manifest Management
- 11.25 Kubernetes Deployment Management Boundary