Kubernetes Deployment
Website Visitors:Deploying a production‑grade web service requires multiple concurrent instances and a controlled upgrade path. Rolling updates let you replace pods incrementally, preserving availability, while the rollback feature restores the previous revision if a new version introduces errors. The pause/resume mechanism lets you stage several changes—such as image upgrades, replica count adjustments, or resource limit modifications—and apply them as a single rollout.
Kubernetes implements these capabilities through the Deployment object, which sits above ReplicaSets in the resource hierarchy. A Deployment owns a ReplicaSet, which in turn creates Pods. Unlike a plain ReplicaSet, a Deployment tracks rollout history, supports declarative updates, and exposes commands for pause, resume, and rollback.
Deployment manifest structure
|
|
apiVersionmust beapps/v1.kindisDeployment, notReplicaSet.spec.replicasdefines the desired pod count.spec.selectormust match the labels inspec.template.metadata.labels.spec.templatecontains the full Pod spec, including containers and resource requests.
Creating and inspecting the Deployment
|
|
kubectl apply creates the Deployment, which immediately creates a ReplicaSet and the corresponding Pods. kubectl get all lists every object in the current namespace, confirming the hierarchy: Deployment → ReplicaSet → Pods.
Managing rollouts
- Rolling update – modify the
imagetag or other fields in the manifest and re‑apply; the Deployment updates the underlying ReplicaSet incrementally, respecting the defaultmaxSurgeandmaxUnavailablevalues (25 % ofreplicaseach). - Rollback – execute
kubectl rollout undo deployment/web-serverto revert to the previous revision. - Pause/Resume –
kubectl rollout pause deployment/web-serverhalts the rollout, allowing multiple edits beforekubectl rollout resume deployment/web-servertriggers a single combined update.
Corrected misconceptions
- Pods can host multiple containers, not only a single instance of an application.
- The command-line client is kubectl, not “kube control”.
- ReplicationControllers are legacy; current practice uses ReplicaSets and Deployments.
- A Deployment creates a new ReplicaSet each time its pod template changes, preserving previous ReplicaSets for rollback.
- Rolling updates do not automatically guarantee zero‑downtime; appropriate
maxSurge/maxUnavailablesettings and readiness probes are required to avoid service disruption.
Your inbox needs more DevOps articles.
Subscribe to get our latest content by email.
