Skip to content

Commit f7c46df

Browse files
committed
api: add terminatingReplicas field to ReplicaSet and Deployment statuses
- update internal ReplicaSet and Deployment type documentation to match with versioned API - made Replicaset and Deployment type documentation more consistent
1 parent 067012f commit f7c46df

File tree

7 files changed

+129
-55
lines changed

7 files changed

+129
-55
lines changed

pkg/apis/apps/types.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -507,19 +507,19 @@ type DeploymentStatus struct {
507507
// +optional
508508
ObservedGeneration int64
509509

510-
// Total number of non-terminated pods targeted by this deployment (their labels match the selector).
510+
// Total number of non-terminating pods targeted by this deployment (their labels match the selector).
511511
// +optional
512512
Replicas int32
513513

514-
// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
514+
// Total number of non-terminating pods targeted by this deployment that have the desired template spec.
515515
// +optional
516516
UpdatedReplicas int32
517517

518-
// Total number of ready pods targeted by this deployment.
518+
// Total number of non-terminating pods targeted by this Deployment with a Ready Condition.
519519
// +optional
520520
ReadyReplicas int32
521521

522-
// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
522+
// Total number of available non-terminating pods (ready for at least minReadySeconds) targeted by this deployment.
523523
// +optional
524524
AvailableReplicas int32
525525

@@ -529,6 +529,13 @@ type DeploymentStatus struct {
529529
// +optional
530530
UnavailableReplicas int32
531531

532+
// Total number of terminating pods targeted by this deployment. Terminating pods have a non-null
533+
// .metadata.deletionTimestamp and have not yet reached the Failed or Succeeded .status.phase.
534+
//
535+
// This is an alpha field. Enable DeploymentPodReplacementPolicy to be able to use this field.
536+
// +optional
537+
TerminatingReplicas *int32
538+
532539
// Represents the latest available observations of a deployment's current state.
533540
Conditions []DeploymentCondition
534541

@@ -865,22 +872,30 @@ type ReplicaSetSpec struct {
865872

866873
// ReplicaSetStatus represents the current status of a ReplicaSet.
867874
type ReplicaSetStatus struct {
868-
// Replicas is the number of actual replicas.
875+
// Replicas is the most recently observed number of non-terminating pods.
876+
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset
869877
Replicas int32
870878

871-
// The number of pods that have labels matching the labels of the pod template of the replicaset.
879+
// The number of non-terminating pods that have labels matching the labels of the pod template of the replicaset.
872880
// +optional
873881
FullyLabeledReplicas int32
874882

875-
// The number of ready replicas for this replica set.
883+
// The number of non-terminating pods targeted by this ReplicaSet with a Ready Condition.
876884
// +optional
877885
ReadyReplicas int32
878886

879-
// The number of available replicas (ready for at least minReadySeconds) for this replica set.
887+
// The number of available non-terminating pods (ready for at least minReadySeconds) for this replica set.
880888
// +optional
881889
AvailableReplicas int32
882890

883-
// ObservedGeneration is the most recent generation observed by the controller.
891+
// The number of terminating pods for this replica set. Terminating pods have a non-null .metadata.deletionTimestamp
892+
// and have not yet reached the Failed or Succeeded .status.phase.
893+
//
894+
// This is an alpha field. Enable DeploymentPodReplacementPolicy to be able to use this field.
895+
// +optional
896+
TerminatingReplicas *int32
897+
898+
// ObservedGeneration reflects the generation of the most recently observed ReplicaSet.
884899
// +optional
885900
ObservedGeneration int64
886901

pkg/features/kube_features.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ const (
159159
// Enable usage of Provision of PVCs from snapshots in other namespaces
160160
CrossNamespaceVolumeDataSource featuregate.Feature = "CrossNamespaceVolumeDataSource"
161161

162+
// owner: @atiratree
163+
// kep: http://kep.k8s.io/3973
164+
//
165+
// Deployments and replica sets can now also track terminating pods via .status.terminatingReplicas.
166+
DeploymentPodReplacementPolicy featuregate.Feature = "DeploymentPodReplacementPolicy"
167+
162168
// owner: @elezar
163169
// kep: http://kep.k8s.io/4009
164170
//

pkg/features/versioned_kube_features.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
152152
{Version: version.MustParse("1.32"), Default: true, LockToDefault: true, PreRelease: featuregate.GA},
153153
},
154154

155+
DeploymentPodReplacementPolicy: {
156+
{Version: version.MustParse("1.32"), Default: false, PreRelease: featuregate.Alpha},
157+
},
158+
155159
DevicePluginCDIDevices: {
156160
{Version: version.MustParse("1.28"), Default: false, PreRelease: featuregate.Alpha},
157161
{Version: version.MustParse("1.29"), Default: true, PreRelease: featuregate.Beta},

staging/src/k8s.io/api/apps/v1/types.go

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -486,19 +486,19 @@ type DeploymentStatus struct {
486486
// +optional
487487
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`
488488

489-
// Total number of non-terminated pods targeted by this deployment (their labels match the selector).
489+
// Total number of non-terminating pods targeted by this deployment (their labels match the selector).
490490
// +optional
491491
Replicas int32 `json:"replicas,omitempty" protobuf:"varint,2,opt,name=replicas"`
492492

493-
// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
493+
// Total number of non-terminating pods targeted by this deployment that have the desired template spec.
494494
// +optional
495495
UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,3,opt,name=updatedReplicas"`
496496

497-
// readyReplicas is the number of pods targeted by this Deployment with a Ready Condition.
497+
// Total number of non-terminating pods targeted by this Deployment with a Ready Condition.
498498
// +optional
499499
ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,7,opt,name=readyReplicas"`
500500

501-
// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
501+
// Total number of available non-terminating pods (ready for at least minReadySeconds) targeted by this deployment.
502502
// +optional
503503
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,4,opt,name=availableReplicas"`
504504

@@ -508,6 +508,13 @@ type DeploymentStatus struct {
508508
// +optional
509509
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty" protobuf:"varint,5,opt,name=unavailableReplicas"`
510510

511+
// Total number of terminating pods targeted by this deployment. Terminating pods have a non-null
512+
// .metadata.deletionTimestamp and have not yet reached the Failed or Succeeded .status.phase.
513+
//
514+
// This is an alpha field. Enable DeploymentPodReplacementPolicy to be able to use this field.
515+
// +optional
516+
TerminatingReplicas *int32 `json:"terminatingReplicas,omitempty" protobuf:"varint,9,opt,name=terminatingReplicas"`
517+
511518
// Represents the latest available observations of a deployment's current state.
512519
// +patchMergeKey=type
513520
// +patchStrategy=merge
@@ -839,16 +846,16 @@ type ReplicaSetList struct {
839846
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
840847

841848
// List of ReplicaSets.
842-
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller
849+
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset
843850
Items []ReplicaSet `json:"items" protobuf:"bytes,2,rep,name=items"`
844851
}
845852

846853
// ReplicaSetSpec is the specification of a ReplicaSet.
847854
type ReplicaSetSpec struct {
848-
// Replicas is the number of desired replicas.
855+
// Replicas is the number of desired pods.
849856
// This is a pointer to distinguish between explicit zero and unspecified.
850857
// Defaults to 1.
851-
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#what-is-a-replicationcontroller
858+
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset
852859
// +optional
853860
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
854861

@@ -866,29 +873,36 @@ type ReplicaSetSpec struct {
866873

867874
// Template is the object that describes the pod that will be created if
868875
// insufficient replicas are detected.
869-
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template
876+
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/#pod-template
870877
// +optional
871878
Template v1.PodTemplateSpec `json:"template,omitempty" protobuf:"bytes,3,opt,name=template"`
872879
}
873880

874881
// ReplicaSetStatus represents the current status of a ReplicaSet.
875882
type ReplicaSetStatus struct {
876-
// Replicas is the most recently observed number of replicas.
877-
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#what-is-a-replicationcontroller
883+
// Replicas is the most recently observed number of non-terminating pods.
884+
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset
878885
Replicas int32 `json:"replicas" protobuf:"varint,1,opt,name=replicas"`
879886

880-
// The number of pods that have labels matching the labels of the pod template of the replicaset.
887+
// The number of non-terminating pods that have labels matching the labels of the pod template of the replicaset.
881888
// +optional
882889
FullyLabeledReplicas int32 `json:"fullyLabeledReplicas,omitempty" protobuf:"varint,2,opt,name=fullyLabeledReplicas"`
883890

884-
// readyReplicas is the number of pods targeted by this ReplicaSet with a Ready Condition.
891+
// The number of non-terminating pods targeted by this ReplicaSet with a Ready Condition.
885892
// +optional
886893
ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,4,opt,name=readyReplicas"`
887894

888-
// The number of available replicas (ready for at least minReadySeconds) for this replica set.
895+
// The number of available non-terminating pods (ready for at least minReadySeconds) for this replica set.
889896
// +optional
890897
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,5,opt,name=availableReplicas"`
891898

899+
// The number of terminating pods for this replica set. Terminating pods have a non-null .metadata.deletionTimestamp
900+
// and have not yet reached the Failed or Succeeded .status.phase.
901+
//
902+
// This is an alpha field. Enable DeploymentPodReplacementPolicy to be able to use this field.
903+
// +optional
904+
TerminatingReplicas *int32 `json:"terminatingReplicas,omitempty" protobuf:"varint,7,opt,name=terminatingReplicas"`
905+
892906
// ObservedGeneration reflects the generation of the most recently observed ReplicaSet.
893907
// +optional
894908
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"`

staging/src/k8s.io/api/apps/v1beta1/types.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -548,33 +548,40 @@ type RollingUpdateDeployment struct {
548548

549549
// DeploymentStatus is the most recently observed status of the Deployment.
550550
type DeploymentStatus struct {
551-
// observedGeneration is the generation observed by the deployment controller.
551+
// The generation observed by the deployment controller.
552552
// +optional
553553
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`
554554

555-
// replicas is the total number of non-terminated pods targeted by this deployment (their labels match the selector).
555+
// Total number of non-terminating pods targeted by this deployment (their labels match the selector).
556556
// +optional
557557
Replicas int32 `json:"replicas,omitempty" protobuf:"varint,2,opt,name=replicas"`
558558

559-
// updatedReplicas is the total number of non-terminated pods targeted by this deployment that have the desired template spec.
559+
// Total number of non-terminating pods targeted by this deployment that have the desired template spec.
560560
// +optional
561561
UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,3,opt,name=updatedReplicas"`
562562

563-
// readyReplicas is the number of pods targeted by this Deployment controller with a Ready Condition.
563+
// Total number of non-terminating pods targeted by this Deployment with a Ready Condition.
564564
// +optional
565565
ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,7,opt,name=readyReplicas"`
566566

567-
// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
567+
// Total number of available non-terminating pods (ready for at least minReadySeconds) targeted by this deployment.
568568
// +optional
569569
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,4,opt,name=availableReplicas"`
570570

571-
// unavailableReplicas is the total number of unavailable pods targeted by this deployment. This is the total number of
571+
// Total number of unavailable pods targeted by this deployment. This is the total number of
572572
// pods that are still required for the deployment to have 100% available capacity. They may
573573
// either be pods that are running but not yet available or pods that still have not been created.
574574
// +optional
575575
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty" protobuf:"varint,5,opt,name=unavailableReplicas"`
576576

577-
// Conditions represent the latest available observations of a deployment's current state.
577+
// Total number of terminating pods targeted by this deployment. Terminating pods have a non-null
578+
// .metadata.deletionTimestamp and have not yet reached the Failed or Succeeded .status.phase.
579+
//
580+
// This is an alpha field. Enable DeploymentPodReplacementPolicy to be able to use this field.
581+
// +optional
582+
TerminatingReplicas *int32 `json:"terminatingReplicas,omitempty" protobuf:"varint,9,opt,name=terminatingReplicas"`
583+
584+
// Represents the latest available observations of a deployment's current state.
578585
// +patchMergeKey=type
579586
// +patchStrategy=merge
580587
// +listType=map

staging/src/k8s.io/api/apps/v1beta2/types.go

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -530,19 +530,19 @@ type DeploymentStatus struct {
530530
// +optional
531531
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"`
532532

533-
// Total number of non-terminated pods targeted by this deployment (their labels match the selector).
533+
// Total number of non-terminating pods targeted by this deployment (their labels match the selector).
534534
// +optional
535535
Replicas int32 `json:"replicas,omitempty" protobuf:"varint,2,opt,name=replicas"`
536536

537-
// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
537+
// Total number of non-terminating pods targeted by this deployment that have the desired template spec.
538538
// +optional
539539
UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,3,opt,name=updatedReplicas"`
540540

541-
// readyReplicas is the number of pods targeted by this Deployment controller with a Ready Condition.
541+
// Total number of non-terminating pods targeted by this Deployment with a Ready Condition.
542542
// +optional
543543
ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,7,opt,name=readyReplicas"`
544544

545-
// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
545+
// Total number of available non-terminating pods (ready for at least minReadySeconds) targeted by this deployment.
546546
// +optional
547547
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,4,opt,name=availableReplicas"`
548548

@@ -552,6 +552,13 @@ type DeploymentStatus struct {
552552
// +optional
553553
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty" protobuf:"varint,5,opt,name=unavailableReplicas"`
554554

555+
// Total number of terminating pods targeted by this deployment. Terminating pods have a non-null
556+
// .metadata.deletionTimestamp and have not yet reached the Failed or Succeeded .status.phase.
557+
//
558+
// This is an alpha field. Enable DeploymentPodReplacementPolicy to be able to use this field.
559+
// +optional
560+
TerminatingReplicas *int32 `json:"terminatingReplicas,omitempty" protobuf:"varint,9,opt,name=terminatingReplicas"`
561+
555562
// Represents the latest available observations of a deployment's current state.
556563
// +patchMergeKey=type
557564
// +patchStrategy=merge
@@ -897,16 +904,16 @@ type ReplicaSetList struct {
897904
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
898905

899906
// List of ReplicaSets.
900-
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller
907+
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset
901908
Items []ReplicaSet `json:"items" protobuf:"bytes,2,rep,name=items"`
902909
}
903910

904911
// ReplicaSetSpec is the specification of a ReplicaSet.
905912
type ReplicaSetSpec struct {
906-
// Replicas is the number of desired replicas.
913+
// Replicas is the number of desired pods.
907914
// This is a pointer to distinguish between explicit zero and unspecified.
908915
// Defaults to 1.
909-
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#what-is-a-replicationcontroller
916+
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset
910917
// +optional
911918
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
912919

@@ -924,29 +931,36 @@ type ReplicaSetSpec struct {
924931

925932
// Template is the object that describes the pod that will be created if
926933
// insufficient replicas are detected.
927-
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template
934+
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/#pod-template
928935
// +optional
929936
Template v1.PodTemplateSpec `json:"template,omitempty" protobuf:"bytes,3,opt,name=template"`
930937
}
931938

932939
// ReplicaSetStatus represents the current status of a ReplicaSet.
933940
type ReplicaSetStatus struct {
934-
// Replicas is the most recently observed number of replicas.
935-
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#what-is-a-replicationcontroller
941+
// Replicas is the most recently observed number of non-terminating pods.
942+
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset
936943
Replicas int32 `json:"replicas" protobuf:"varint,1,opt,name=replicas"`
937944

938-
// The number of pods that have labels matching the labels of the pod template of the replicaset.
945+
// The number of non-terminating pods that have labels matching the labels of the pod template of the replicaset.
939946
// +optional
940947
FullyLabeledReplicas int32 `json:"fullyLabeledReplicas,omitempty" protobuf:"varint,2,opt,name=fullyLabeledReplicas"`
941948

942-
// readyReplicas is the number of pods targeted by this ReplicaSet controller with a Ready Condition.
949+
// The number of non-terminating pods targeted by this ReplicaSet with a Ready Condition.
943950
// +optional
944951
ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,4,opt,name=readyReplicas"`
945952

946-
// The number of available replicas (ready for at least minReadySeconds) for this replica set.
953+
// The number of available non-terminating pods (ready for at least minReadySeconds) for this replica set.
947954
// +optional
948955
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,5,opt,name=availableReplicas"`
949956

957+
// The number of terminating pods for this replica set. Terminating pods have a non-null .metadata.deletionTimestamp
958+
// and have not yet reached the Failed or Succeeded .status.phase.
959+
//
960+
// This is an alpha field. Enable DeploymentPodReplacementPolicy to be able to use this field.
961+
// +optional
962+
TerminatingReplicas *int32 `json:"terminatingReplicas,omitempty" protobuf:"varint,7,opt,name=terminatingReplicas"`
963+
950964
// ObservedGeneration reflects the generation of the most recently observed ReplicaSet.
951965
// +optional
952966
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"`

0 commit comments

Comments
 (0)