Skip to content

Commit 8dc3de8

Browse files
authored
KEP-3973: Consider deployment completion in DeploymentPodReplacementPolicy (#4976)
* Consider deployment completion in DeploymentPodReplacementPolicy - update API; TerminatingReplicas fields should be pointers * Update PodReplacementPolicy alpha to 1.33
1 parent a8e9e87 commit 8dc3de8

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

keps/sig-apps/3973-consider-terminating-pods-deployment/README.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- [Design Details](#design-details)
2020
- [Deployment Behavior Changes](#deployment-behavior-changes)
2121
- [ReplicaSet Status and Deployment Status Changes](#replicaset-status-and-deployment-status-changes)
22+
- [Deployment Completion and Progress Changes](#deployment-completion-and-progress-changes)
2223
- [Deployment Scaling Changes and a New Annotation for ReplicaSets](#deployment-scaling-changes-and-a-new-annotation-for-replicasets)
2324
- [kubectl Changes](#kubectl-changes)
2425
- [API](#api)
@@ -279,6 +280,20 @@ To satisfy the requirement for tracking terminating pods, and for implementation
279280
we propose a new field `.status.terminatingReplicas` to the ReplicaSet's and Deployment's
280281
status.
281282

283+
### Deployment Completion and Progress Changes
284+
285+
Currently, when the latest ReplicaSet is fully saturated and all of its pods become available, the
286+
Deployment is declared complete. However, there may still be old terminating pods. These pods can
287+
still be ready and hold/accept connections, meaning that the transition to the latest revision is
288+
not fully complete.
289+
290+
To avoid unexpected behavior, we should not declare the deployment complete until all of its
291+
terminating replicas have been fully terminated. We will therefore delay setting a `NewRSAvailable`
292+
reason to the `DeploymentProgressing` condition, when `TerminationComplete` policy is used.
293+
294+
We will also update the `LastUpdateTime` of the `DeploymentProgressing` condition when the number of
295+
terminating pods decreases to reset the progress deadline.
296+
282297
### Deployment Scaling Changes and a New Annotation for ReplicaSets
283298

284299
Currently, scaling is done proportionally over all ReplicaSets to mitigate the risk of losing
@@ -383,14 +398,17 @@ See [kubectl Skew](#kubectl-skew) for more details.
383398
type DeploymentPodReplacementPolicy string
384399
const (
385400
// TerminationStarted policy creates replacement Pods when the old Pods start
386-
// terminating (has a .metadata.deletionTimestamp). The total number of
387-
// Deployment Pods can be greater than specified by the Deployment's
401+
// terminating (have a non-null .metadata.deletionTimestamp). The total number
402+
// of Deployment Pods can be greater than specified by the Deployment's
388403
// .spec.replicas and the DeploymentStrategy.
389404
TerminationStarted DeploymentPodReplacementPolicy = "TerminationStarted"
390405
// TerminationComplete policy creates replacement Pods only when the old Pods
391406
// are fully terminated (reach Succeeded or Failed phase). The old Pods are
392407
// subsequently removed. The total number of the Deployment Pods is
393408
// limited by the Deployment's .spec.replicas and the DeploymentStrategy.
409+
//
410+
// This policy will also delay declaring the deployment as complete until all
411+
// of its terminating replicas have been fully terminated.
394412
TerminationComplete DeploymentPodReplacementPolicy = "TerminationComplete"
395413
)
396414
```
@@ -401,13 +419,15 @@ type DeploymentSpec struct {
401419
// podReplacementPolicy specifies when to create replacement Pods.
402420
// Possible values are:
403421
// - TerminationStarted policy creates replacement Pods when the old Pods start
404-
// terminating (has a .metadata.deletionTimestamp). The total number of
405-
// Deployment Pods can be greater than specified by the Deployment's
422+
// terminating (have a non-null .metadata.deletionTimestamp). The total number
423+
// of Deployment Pods can be greater than specified by the Deployment's
406424
// .spec.replicas and the DeploymentStrategy.
407425
// - TerminationComplete policy creates replacement Pods only when the old Pods
408426
// are fully terminated (reach Succeeded or Failed phase). The old Pods are
409427
// subsequently removed. The total number of the Deployment Pods is
410428
// limited by the Deployment's .spec.replicas and the DeploymentStrategy.
429+
// This policy will also delay declaring the deployment as complete until all
430+
// of its terminating replicas have been fully terminated.
411431
//
412432
// The default behavior when the policy is not specified depends on the DeploymentStrategy:
413433
// - Recreate strategy uses TerminationComplete behavior when recreating the deployment,
@@ -442,11 +462,11 @@ type ReplicaSetStatus struct {
442462
// +optional
443463
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,5,opt,name=availableReplicas"`
444464

445-
// The number of terminating replicas (have .metadata.deletionTimestamp) for this replica set.
465+
// The number of terminating pods (have a non-null .metadata.deletionTimestamp) for this replica set.
446466
//
447467
// This is an alpha field. Enable DeploymentPodReplacementPolicy to be able to use this field.
448468
// +optional
449-
TerminatingReplicas int32 `json:"terminatingReplicas,omitempty" protobuf:"varint,7,opt,name=terminatingReplicas"`
469+
TerminatingReplicas *int32 `json:"terminatingReplicas,omitempty" protobuf:"varint,7,opt,name=terminatingReplicas"`
450470
...
451471
}
452472
```
@@ -476,11 +496,11 @@ type DeploymentStatus struct {
476496
// +optional
477497
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty" protobuf:"varint,5,opt,name=unavailableReplicas"`
478498

479-
// Total number of terminating pods (have .metadata.deletionTimestamp) targeted by this deployment.
499+
// Total number of terminating pods (have a non-null .metadata.deletionTimestamp) targeted by this deployment.
480500
//
481501
// This is an alpha field. Enable DeploymentPodReplacementPolicy to be able to use this field.
482502
// +optional
483-
TerminatingReplicas int32 `json:"terminatingReplicas,omitempty" protobuf:"varint,9,opt,name=terminatingReplicas"`
503+
TerminatingReplicas *int32 `json:"terminatingReplicas,omitempty" protobuf:"varint,9,opt,name=terminatingReplicas"`
484504
...
485505
}
486506
```
@@ -929,6 +949,7 @@ deployment and replicaset controllers.
929949
- 2023-05-01: First version of the KEP opened (https://github.com/kubernetes/enhancements/pull/3974).
930950
- 2023-12-12: Second version of the KEP opened (https://github.com/kubernetes/enhancements/pull/4357).
931951
- 2024-29-05: Added a Deployment Scaling Changes and a New Annotation for ReplicaSets section (https://github.com/kubernetes/enhancements/pull/4670).
952+
- 2024-22-11: Added a Deployment Completion and Progress Changes section (https://github.com/kubernetes/enhancements/pull/4976).
932953

933954
## Drawbacks
934955

keps/sig-apps/3973-consider-terminating-pods-deployment/kep.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ stage: alpha
2222
# The most recent milestone for which work toward delivery of this KEP has been
2323
# done. This can be the current (upcoming) milestone, if it is being actively
2424
# worked on.
25-
latest-milestone: "v1.32"
25+
latest-milestone: "v1.33"
2626

2727
# The milestone at which this feature was, or is targeted to be, at each stage.
2828
milestone:
29-
alpha: "v1.32"
29+
alpha: "v1.33"
3030
beta: ""
3131
stable: ""
3232

0 commit comments

Comments
 (0)