Add recommendation for Deployment when HPA is enabled

* Advertise that we need to remove `spec.replicas` when a Horizontal Pod
  Autoscaler is active to prevent unnecessary changes in Pod counts during
  Deployment object changes
* Make note that a Deployment that has this value set behave awkwardly if a
  Deployment is scaled manually outside of the Deployment object

Signed-off-by: John T Skarbek <jtslear@gmail.com>
This commit is contained in:
John T Skarbek
2021-09-17 13:24:00 -04:00
parent 0a4887ebde
commit df3184bd52
3 changed files with 67 additions and 1 deletions
@@ -1070,6 +1070,18 @@ allowed, which is the default if not specified.
`.spec.replicas` is an optional field that specifies the number of desired Pods. It defaults to 1.
Should you manually scale a Deployment, example via `kubectl scale deployment
deployment --replicas=X`, and then you update that Deployment based on a manifest
(for example: by running `kubectl apply -f deployment.yaml`),
then applying that manifest overwrites the manual scaling that you previously did.
If a [HorizontalPodAutoscaler](/docs/tasks/run-application/horizontal-pod-autoscale/) (or any
similar API for horizontal scaling) is managing scaling for a Deployment, don't set `.spec.replicas`.
Instead, allow the Kubernetes
{{< glossary_tooltip text="control plane" term_id="control-plane" >}} to manage the
`.spec.replicas` field automatically.
### Selector
`.spec.selector` is a required field that specifies a [label selector](/docs/concepts/overview/working-with-objects/labels/)
@@ -295,6 +295,22 @@ a Pod is considered ready, see [Container Probes](/docs/concepts/workloads/pods/
Please note that this field only works if you enable the `StatefulSetMinReadySeconds` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/).
### Replicas
`.spec.replicas` is an optional field that specifies the number of desired Pods. It defaults to 1.
Should you manually scale a deployment, example via `kubectl scale
statefulset statefulset --replicas=X`, and then you update that StatefulSet
based on a manifest (for example: by running `kubectl apply -f
statefulset.yaml`), then applying that manifest overwrites the manual scaling
that you previously did.
If a [HorizontalPodAutoscaler](/docs/tasks/run-application/horizontal-pod-autoscale/)
(or any similar API for horizontal scaling) is managing scaling for a
Statefulset, don't set `.spec.replicas`. Instead, allow the Kubernetes
{{<glossary_tooltip text="control plane" term_id="control-plane" >}} to manage
the `.spec.replicas` field automatically.
## {{% heading "whatsnext" %}}