@@ -646,6 +646,11 @@ The output is similar to this:
646646deployment.apps/nginx-deployment scaled
647647```
648648
649+ {{< note >}}
650+ Scaling may be partial if the ` TerminationComplete ` [ pod replacement policy] ( #pod-replacement-policy )
651+ is used and there are terminating Deployment Pods. Scaling will complete once these Pods have terminated.
652+ {{< /note >}}
653+
649654### Proportional scaling
650655
651656RollingUpdate Deployments support running multiple versions of an application at the same time. When you
@@ -1164,9 +1169,10 @@ All existing Pods are killed before new ones are created when `.spec.strategy.ty
11641169{{< note >}}
11651170This will only guarantee Pod termination previous to creation for upgrades. If you upgrade a Deployment, all Pods
11661171of the old revision will be terminated immediately. Successful removal is awaited before any Pod of the new
1167- revision is created. If you manually delete a Pod, the lifecycle is controlled by the ReplicaSet and the
1168- replacement will be created immediately (even if the old Pod is still in a Terminating state). If you need an
1169- "at most" guarantee for your Pods, you should consider using a
1172+ revision is created (unless you used the ` TerminationStarted ` [ pod replacement policy] ( #pod-replacement-policy ) ).
1173+ If you manually delete a Pod, the lifecycle is controlled by the ReplicaSet and the replacement will be created
1174+ immediately (even if the old Pod is still in a Terminating state). If you need an "at most" guarantee for your
1175+ Pods, you should consider using a
11701176[ StatefulSet] ( /docs/concepts/workloads/controllers/statefulset/ ) .
11711177{{< /note >}}
11721178
@@ -1299,6 +1305,15 @@ spec:
12991305{{% /tab %}}
13001306{{< /tabs >}}
13011307
1308+ {{< note >}}
1309+ If you use the ` TerminationComplete` [pod replacement policy](#pod-replacement-policy), the Deployment may not fully
1310+ use the `maxUnavailable` and `maxSurge` capacity that you configure.
1311+
1312+ Using the `TerminationComplete`pod replacement policy can result in fewer (or no) surge
1313+ Pods, and slower rollouts overall.
1314+ {{< /note >}}
1315+
1316+
13021317# ## Progress Deadline Seconds
13031318
13041319` .spec.progressDeadlineSeconds` is an optional field that specifies the number of seconds you want
@@ -1317,6 +1332,48 @@ created Pod should be ready without any of its containers crashing, for it to be
13171332This defaults to 0 (the Pod will be considered available as soon as it is ready). To learn more about when
13181333a Pod is considered ready, see [Container Probes](/docs/concepts/workloads/pods/pod-lifecycle/#container-probes).
13191334
1335+ # ## Pod replacement policy
1336+
1337+ {{< feature-state feature_gate_name="DeploymentPodReplacementPolicy" >}}
1338+
1339+ This feature is disabled by default. You can enable it by setting the `DeploymentPodReplacementPolicy`
1340+ [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
1341+ on the [API server](/docs/reference/command-line-tools-reference/kube-apiserver/)
1342+ and on the [kube-controller-manager](/docs/reference/command-line-tools-reference/kube-controller-manager/)
1343+
1344+ Pods that belong to a Deployment can become terminating due to deletion, usually during
1345+ the rollout or an update to the scale of an existing Deployment.
1346+ After a change to a Deployment, some pods may take a long time to terminate and may consume
1347+ additional resources during that period. As a result, the total number of all pods can temporarily exceed
1348+ ` .spec.replicas` (or `.spec.replicas` + `.spec.strategy.rollingUpdate.maxSurge` for RollingUpdate Deployments).
1349+ A `.spec.podReplacementPolicy` field can be used to control when a Deployment should create new pods.
1350+
1351+ Policies :
1352+
1353+ ` TerminationStarted`
1354+ : This policy creates replacement Pods when the old Pods start terminating (has a
1355+ ` .metadata.deletionTimestamp` ). The total number of Deployment Pods can be greater than specified by the
1356+ Deployment's `.spec.replicas` and the DeploymentStrategy. It can increase the speed of rollouts, but it will
1357+ result in a temporarily higher resource consumption.
1358+
1359+ ` TerminationComplete`
1360+ : This policy creates replacement Pods only when the old Pods are fully terminated (reach `Succeeded` or
1361+ ` Failed` phase). The old Pods are subsequently removed. The total number of the Deployment Pods is limited by
1362+ the Deployment's `.spec.replicas` and the DeploymentStrategy. It can slow down the speed of rollouts, but
1363+ prevents spikes in resource consumption.
1364+
1365+ If you don't specify a pod replacement policy, the behavior of that Deployment depends on
1366+ the DeploymentStrategy :
1367+ * Recreate strategy uses `TerminationComplete` behavior when recreating the deployment,
1368+ but uses `TerminationStarted` when scaling the deployment.
1369+ * RollingUpdate strategy uses `TerminationStarted` behavior for both rolling out and
1370+ scaling the deployments.
1371+
1372+ If you manually delete a Pod, the lifecycle of that Pod and its replacement is controlled by the associated ReplicaSet;
1373+ a replacement will be created immediately. When you delete a Pod manually, and the deleted Pod was owned by a
1374+ ReplicaSet, the ReplicaSet creates a new Pod as soon as you trigger deletion (even if the old Pod is still in a Terminating state).
1375+ Setting a pod replacement policy for a Deployment only has an effect on Deployment rollouts and changes to the scale.
1376+
13201377# ## Revision History Limit
13211378
13221379A Deployment's revision history is stored in the ReplicaSets it controls.
0 commit comments