All posts
Emire Barış profile photoEmire Barış · Member2 min read

What is a Deployment in Kubernetes? (with kubectl examples)

What a Kubernetes Deployment is, how it manages Pods and ReplicaSets, kubectl get/describe/rollout commands, common beginner mistakes, and optional natural-language checks with kprompt.

If you searched what is a deployment in kubernetes, here is the short version: a Deployment is the controller you usually create for a stateless app. It declares how many Pod copies you want, which container image to run, and how updates should roll out. Kubernetes then creates and replaces Pods so reality matches that declaration.

This page is Deployment-first. For the Pod vs Deployment comparison, see Pods vs Deployments. For how traffic reaches those Pods, see Service vs Deployment.

The one-sentence version

  • A Deployment is desired state for a set of identical Pods (replicas + template).
  • It owns ReplicaSets, which create the actual Pods.
  • You rarely create lone Pods in production — you create a Deployment.

What a Deployment actually does

You give Kubernetes a Pod template (containers, ports, labels, probes) and a replica count. The Deployment controller creates a ReplicaSet. The ReplicaSet creates Pods. If a Pod dies or a node fails, a replacement Pod appears. If you change the image, the Deployment performs a rolling update (by default) and keeps history so you can roll back.

Mental model

Deployment "api"
  └── ReplicaSet (current revision)
        ├── Pod api-aaa
        ├── Pod api-bbb
        └── Pod api-ccc

kubectl commands that stick

Inspect and manage a Deployment

kubectl get deployments -n staging
kubectl describe deployment api -n staging
kubectl get pods -l app=api -n staging

kubectl scale deployment api --replicas=3 -n staging
kubectl rollout status deployment/api -n staging
kubectl rollout undo deployment/api -n staging
kubectl rollout history deployment/api -n staging

READY columns on kubectl get deploy show desired vs available replicas. If READY is 0/3, dig into Pods next — status reasons live on the Pod objects. See kubectl get pods explained.

Common beginner mistakes

  • Creating a bare Pod YAML for an app that should restart and scale → use a Deployment
  • Editing a live Pod and expecting the change to survive → the Deployment recreates Pods from the template
  • Treating the Pod name as stable → names change on recreate; the Deployment name stays
  • Forgetting labels → Services cannot select Pods if labels/selectors do not match

Optional natural-language checks

kprompt can list and explain Deployments as reads. Scaling or restarting still produces a plan you approve.

Soft kprompt examples

kprompt "list deployments in staging"
kprompt "describe deployment api in staging"
kprompt "scale api to 3 in staging"   # review plan → y or n

What to learn next

Compare objects with Pods vs Deployments, then networking with Services / Service vs Deployment, then Namespaces. Day-2 tooling: kubectl vs K9s.