When creating a Deployment and HorizontalPodAutoscaler together in a Helm chart, should the deployment’s .spec.replicas be set to null, or should it be unset, or should it be set to some value between the hpa’s minReplicas and maxReplicas?
When you create a hpa, the hpa controller manages the deployment’s .spec.replicas, so when you update the deployment’s other fields you shouldn’t change the replicas.
Comparing to kubectl apply declarative config, you can modify other fields of the deployment without modifying .spec.replicas if you leave .spec.replicas unset the first time the deployment is created, so that the 3-way diff ignores that field when the deployment is applied in the future. Or to omit the field after creation time, you have to use kubectl apply edit-last-applied to avoid accidentally scaling down to 1 when removing the field (kubernetes/kubernetes#67135). So with kubectl apply it is possible to apply a deployment while not touching .spec.replicas.
What is the correct way to helm upgrade a deployment’s other fields without changing its scaling?