Skip to main content
Kubernetes Deployments automate application upgrades, scaling, and self-healing in production environments. They enable rolling updates, controlled rollbacks, and pause/resume capabilities—all without downtime. In this guide, you’ll learn how Deployments manage ReplicaSets and Pods, define a Deployment manifest, and inspect your resources using kubectl.

Why Use a Deployment?

  • Rolling Updates: Replace pods one by one to avoid service interruption.
  • Rollbacks: Instantly revert to a previous version if something goes wrong.
  • Pause & Resume: Apply several changes as a batch and resume when ready.
  • Declarative Scaling: Increase or decrease replicas in your manifest.

How Deployments Work

A Deployment sits above ReplicaSets and Pods:
  1. Pod: The basic execution unit (one or more containers).
  2. ReplicaSet: Ensures a specified number of pod replicas run at any time.
  3. Deployment: Manages ReplicaSets and orchestrates updates, rollbacks, and scaling.
The image illustrates a Kubernetes deployment structure, showing a deployment with multiple pods and a replica set, along with versioning and control icons.

Resource Comparison

Writing a Deployment Manifest

Create a YAML file (deployment-definition.yml) to declare your desired state:
  • apiVersion: The API group (apps/v1).
  • kind: Must be Deployment.
  • metadata: Identifies the Deployment (name and labels).
  • spec.replicas: Desired number of pods.
  • spec.selector: Matches labels on pods.
  • spec.template: Defines the pod spec, just like a ReplicaSet.
Using kubectl apply -f is recommended for idempotent updates. It creates or updates resources based on your manifest.

Deploying and Inspecting Resources

  1. Create or update the Deployment
  2. View Deployments
    Example output:
  3. List ReplicaSets
  4. Check Pods
  5. See All Resources
If an update fails, rollback immediately:

Next Steps & References

Watch Video