Script Valley
Kubernetes: From Containers to Clusters
Core Workload Resources: Pods, Deployments, and ReplicaSetsLesson 2.2

Kubernetes Deployment: how to deploy and manage stateless applications

Deployment resource, ReplicaSet relationship, desired state reconciliation, creating deployments, scaling deployments, rollout status, deployment strategy types, kubectl rollout commands

Deployments Manage Your App Lifecycle

Kubernetes Deployment ReplicaSet Pod hierarchy

A Deployment is the standard way to run stateless applications on Kubernetes. It owns a ReplicaSet, which owns Pods. You declare the desired state (image version, replica count) in the Deployment — it handles creating and replacing Pods to match.

Creating a Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
  namespace: production
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
      - name: web-app
        image: nginx:1.25
        ports:
        - containerPort: 80
        resources:
          requests:
            memory: "64Mi"
            cpu: "100m"
          limits:
            memory: "128Mi"
            cpu: "200m"

Scaling and Checking Status

# Apply the deployment
kubectl apply -f deployment.yaml

# Scale to 5 replicas
kubectl scale deployment web-app --replicas=5

# Watch rollout progress
kubectl rollout status deployment/web-app

# View rollout history
kubectl rollout history deployment/web-app

Kubernetes updates the Deployment by creating a new ReplicaSet with the new Pod template and gradually scaling it up while scaling the old ReplicaSet down. This is a rolling update — zero downtime by default.

Up next

Kubernetes rolling updates and rollbacks: how to deploy without downtime

Sign in to track progress