Interview Prep/Kubernetes/Deployments and rollouts

How do you scale a Deployment and what happens if an HPA also manages it?

BeginnerScenarioDeployments and rollouts
Answer

Situation read → Someone ran kubectl scale deploy web --replicas=2 but replicas keep returning to 6.

What I'd do →

  1. kubectl get hpa to see whether an HPA targets the Deployment
  2. kubectl describe hpa web to read min/max and current metrics
  3. Change minReplicas/maxReplicas on the HPA instead of the Deployment
  4. Remove replicas: from the manifest in Git so GitOps does not fight the HPA

Why → The HPA controller owns spec.replicas once attached and overwrites manual changes on its next sync.

Interview tip → Mention that leaving replicas in the manifest causes a reset on every apply.

All Kubernetes questions Roadmap: Kubernetes core

More on Deployments and rollouts