Kubernetes YAML Cheat Sheet/Basic Deployment YAML

Run a replicated stateless workload.

Section: Deployments

Basic Deployment YAML

yaml
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
        - name: api
          image: ghcr.io/example/api:1.0.0
          ports:
            - containerPort: 8080
Explanation

Deployments manage ReplicaSets and provide declarative rollout behavior for Pods.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Deployments
Customize rolling update strategy
Tune availability during rollout.
OpenIn sheetyamlsame section
Set deployment progress deadline
Mark failed rollouts sooner.
OpenIn sheetyamlsame section
Apply deployment manifest
Create or update the Deployment.
OpenIn sheetbashsame section
Watch rollout status
See whether the new ReplicaSet becomes ready.
OpenIn sheetbashsame section
Minimal Pod manifest
Smallest practical Pod YAML shape.
Labels and annotations example
Common metadata block for selectors and tooling.