Skip to content

Kubernetes Deployment

A Kubernetes Deployment is a controller that manages a set of Pod replicas declaratively: it creates a ReplicaSet, ensures the desired number of Pods is running, and performs rolling updates with configurable strategy.

Definition

What it is

A Deployment does not run Pods directly. It creates a ReplicaSet, which creates Pods. When you update the Deployment's PodTemplate, it creates a new ReplicaSet with the new template, scales it up, and scales the old one down. That is the rolling update: no downtime, no lost requests, verified by the readinessProbe of each Pod.

Why it matters

Without a Deployment, you would manage bare Pods manually: create one, watch it crash, create another. Deployments automate the loop. They also give you kubectl rollout undo: one command reverts to the previous revision. That alone justifies their use.

Deployment vs ReplicaSet vs StatefulSet vs DaemonSet

Controller

Purpose

Pod identity

Storage

Deployment

Stateless replicas + rolling update

Ephemeral

Shared (emptyDir)

ReplicaSet

Enforce N replicas

Ephemeral

None

StatefulSet

Stateful workloads

Stable ordinal + network

Per-Pod PVC

DaemonSet

One Pod per node

Node-bound

HostPath

The rolling update

Rolling update

  1. Set the strategy

    strategy.type: RollingUpdate. Default maxSurge: 25%, maxUnavailable: 25%. Lower values = safer but slower.

  2. Readiness probe mandatory

    Without a readinessProbe, Kubernetes considers a new Pod ready immediately and shifts traffic before the app booted.

  3. Liveness probe for restarts

    If the app hangs, livenessProbe fails and Kubernetes restarts it. Never share readiness and liveness endpoints.

  4. Rollback ready

    kubectl rollout undo deployment/app. Uses the revisionHistoryLimit (default 10) retained ReplicaSets.

Common failures

Origin

ReplicationController was the original primitive (2014). Deployments were added in Kubernetes 1.2 (March 2016) to add rolling updates and rollback. They are now the default for stateless workloads. StatefulSets came in 1.9 (2017) for stateful needs.

Evidence

FAQ

Deployment vs ReplicaSet?

A Deployment owns one or more ReplicaSets (one per revision). You almost never interact with a ReplicaSet directly.

How do I rollback?

kubectl rollout undo deployment/name. Reverts to the previous ReplicaSet.

Does it work for databases?

No. Use StatefulSet. Deployments assume ephemeral Pod identity.

What is maxSurge/maxUnavailable?

Controls how aggressive the rolling update is. maxSurge: 1, maxUnavailable: 0 = safest, slowest.

Connections

Pros and cons

Pros

  • Rolling update without downtime when readinessProbe is correct.
  • Rollback in one command: kubectl rollout undo.
  • Declarative reconciliation applied continuously.
  • Horizontal scaling is trivial.
  • Revision history for audit via revisionHistoryLimit.

Cons

  • Not for stateful workloads: no stable Pod identity.
  • Without readinessProbe: traffic before the app is ready.
  • Not zero-downtime by default: depends on maxSurge and maxUnavailable.
  • Rollback does not revert data migrations.

Key numbers

25%default maxSurge
25%default maxUnavailable
10default revisionHistoryLimit
600sdefault progressDeadlineSeconds
2016Deployments GA (v1.2)

Timeline

  1. 2014 — ReplicationController (v1.0).

  2. 2016 — Deployments GA (v1.2, March).

  3. 2017 — StatefulSet for stateful workloads (v1.9).

  4. 2019 — Argo Rollouts introduces progressive delivery.

  5. 2024 — Default strategy across ecosystems.

Core components

Deployment hierarchy

nameroletypelaunched
DeploymentDeclarative spec + rollout strategycontroller2016
ReplicaSetPod replicas at one revisioncontroller2014
PodRuns containersworkload2015
ServiceStable endpoint for Podsnetworking2014

Learning path

Progression

  1. Prerequisite

    kubernetes, k8s-pod, container-image

  2. This term

    You are here.

  3. Next

    k8s-service, k8s-ingress, argocd, helm

Semantic network

Kubernetes DKubernetesKubernetesKubernetesContainerContainer

● broader ● narrower ● related

Used in the garden

Sources