Deployment

A Kubernetes Deployment is a controller that keeps a specified number of identical pod replicas running and manages their updates, rollbacks, and scaling.

Table of Contents

Table of Contents

What Does Deployment Mean?

A Deployment in Kubernetes is a controller that manages pods and keeps the desired number of replicas running. If a pod fails, the Deployment replaces it automatically.

Deployments are the foundation for running stateless applications. They provide a declarative way to define application state, so teams focus on the app instead of pod management.

How Deployments Work in Kubernetes

A Deployment is defined in YAML. It sets replicas, a pod template, selectors, and an update strategy:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: billing-api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: billing-api
  template:
    metadata:
      labels:
        app: billing-api
    spec:
      containers:
        - name: billing-api
          image: registry.example.com/billing-api:1.4.2
          ports:
            - containerPort: 8080
  • Replicas: how many identical pods should run
  • Pod template: image, environment variables, and resource requests and limits
  • Update strategy: rolling updates or recreate
  • Selector labels: which pods belong to the Deployment
  • Health probes: liveness and readiness checks

Kubernetes continuously reconciles the actual state with this desired state.

Pod vs. ReplicaSet vs. Deployment

Object What It Does Managed By
Pod Runs one or more containers A ReplicaSet
ReplicaSet Keeps a set number of identical pods A Deployment
Deployment Manages ReplicaSets, updates, and rollbacks You, through YAML or GitOps

Why Deployments Matter

  • High availability: replicas spread across nodes keep apps reachable
  • Scalability: change replica counts or use autoscaling
  • Resilience: failed pods and nodes are replaced automatically
  • Safe updates: rolling updates and rollbacks reduce release risk

Without Deployments, teams would manage pods by hand, which is error-prone and slow.

Common Deployment Patterns

  • Rolling updates: replace pods gradually for zero downtime
  • Canary deployments: send a little traffic to a new version first
  • Blue-green deployments: switch traffic between two full environments
  • Resource management: requests and limits prevent exhaustion
  • Pod disruption budgets: limit unavailable replicas during maintenance

Real-World Example

A B2B SaaS team rolls out a new billing API version with a rolling update. After the rollout completes, a Testkube workflow runs API and smoke tests against the new pods.

When a test fails, the team runs kubectl rollout undo and restores the previous version in seconds.

How Deployments Relate to Testkube

Testkube is Kubernetes-native. Its long-running services, such as the agent and API components, run as Deployments.

  • Reliable services: core components restart automatically after failures
  • Safe upgrades: rolling updates keep Testkube available during upgrades
  • Isolated test runs: each test execution runs as its own Job and pod
  • Post-rollout testing: workflows can validate your Deployments after every change

Testkube fits existing monitoring, logging, and GitOps tooling because it uses standard primitives.

Best Practices for Deployments

  • Set probes: readiness and liveness probes guide safe rollouts
  • Define resources: requests and limits keep scheduling predictable
  • Pin image versions: avoid latest for reproducible rollouts
  • Test after rollouts: validate new versions before shifting traffic
  • Manage with GitOps: version Deployments and roll back by commit

Frequently Asked Questions (FAQs)

What is the difference between a Deployment and a pod?

A pod is a single running instance of containers. A Deployment manages many pod replicas and keeps them in the desired state.

How do Deployments handle updates?

They use rolling updates by default, replacing pods gradually to minimize downtime.

Can Deployments be rolled back?

Yes. Kubernetes keeps revision history, so you can roll back to a previous version quickly.

Do Deployments support scaling?

Yes. Scale replicas manually or with a Horizontal Pod Autoscaler.

How does Testkube use Deployments?

Testkube runs its core services as Deployments. Individual test executions run as Kubernetes Jobs and pods.

Related Terms and Concepts

No items found.