What is a Deployment in Kubernetes?
Why Interviewers Ask This
Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Kubernetes (K8s) development. It reveals whether you understand the building blocks that more complex concepts rely on.
Answer
A Deployment is a higher-level abstraction that manages a set of identical Pods (called a ReplicaSet). It provides declarative updates, rollout strategies, and rollback. Deployment spec: apiVersion: apps/v1 kind: Deployment metadata: name: my-app spec: replicas: 3 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: my-app image: my-app:1.0 ports: - containerPort: 3000 strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 0. Key features: ReplicaSet ensures N replicas are always running (self-healing); rolling updates with configurable strategy; rollback to previous revision. Kubectl commands: kubectl apply -f deployment.yaml kubectl scale deployment my-app --replicas=5 kubectl set image deployment/my-app my-app=my-app:2.0 kubectl rollout status deployment/my-app kubectl rollout history deployment/my-app kubectl rollout undo deployment/my-app kubectl rollout undo deployment/my-app --to-revision=2. Update strategies: RollingUpdate (default — gradually replace old pods with new ones. maxSurge: extra pods during update, maxUnavailable: pods that can be down); Recreate (kill all old pods before creating new — causes downtime, use for stateful). Deployment vs ReplicaSet vs Pod: always use Deployment (manages ReplicaSets for rollback history). Never create ReplicaSets or Pods directly in production. Pause/resume: kubectl rollout pause/resume deployment/my-app — pause during multi-step updates.
Common Mistake
A common mistake is memorizing definitions without understanding implications. When asked this question, go one level deeper — explain what happens when this concept is misused or ignored.