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 →
kubectl get hpato see whether an HPA targets the Deploymentkubectl describe hpa webto read min/max and current metrics- Change
minReplicas/maxReplicason the HPA instead of the Deployment - 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.
More on Deployments and rollouts
You applied a new image tag and the rollout seems stuck at "1 out of 3 new replicas have been updated". What do you check first?BeginnerHow do you roll back a bad release and verify you are back on the previous version?BeginnerA rollout must never reduce capacity below current replicas. How do you configure the strategy?IntermediateYou need a blue/green deployment without a service mesh. How do you do it with plain Kubernetes?IntermediateHow would you do a canary release with only Deployments and a Service?IntermediateWhat is the difference between Recreate and RollingUpdate strategies and when would you pick Recreate?Beginner