Commit 75c5f4d6 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #37959 from kargakis/add-ready-replicas

Automatic merge from submit-queue Add ready replicas in Deployments Fixes https://github.com/kubernetes/kubernetes/issues/28381 @kubernetes/deployment PTAL
parents dbb8bf52 6cb946ea
...@@ -35210,6 +35210,11 @@ ...@@ -35210,6 +35210,11 @@
"type": "integer", "type": "integer",
"format": "int64" "format": "int64"
}, },
"readyReplicas": {
"description": "Total number of ready pods targeted by this deployment.",
"type": "integer",
"format": "int32"
},
"replicas": { "replicas": {
"description": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).", "description": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).",
"type": "integer", "type": "integer",
...@@ -8947,6 +8947,11 @@ ...@@ -8947,6 +8947,11 @@
"format": "int32", "format": "int32",
"description": "Total number of non-terminated pods targeted by this deployment that have the desired template spec." "description": "Total number of non-terminated pods targeted by this deployment that have the desired template spec."
}, },
"readyReplicas": {
"type": "integer",
"format": "int32",
"description": "Total number of ready pods targeted by this deployment."
},
"availableReplicas": { "availableReplicas": {
"type": "integer", "type": "integer",
"format": "int32", "format": "int32",
......
...@@ -469,6 +469,13 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; } ...@@ -469,6 +469,13 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr> <tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">readyReplicas</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total number of ready pods targeted by this deployment.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">integer (int32)</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">availableReplicas</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">availableReplicas</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
...@@ -6919,7 +6926,7 @@ Both these may change in the future. Incoming requests are matched against the h ...@@ -6919,7 +6926,7 @@ Both these may change in the future. Incoming requests are matched against the h
</div> </div>
<div id="footer"> <div id="footer">
<div id="footer-text"> <div id="footer-text">
Last updated 2016-12-16 21:59:42 UTC Last updated 2016-12-21 12:26:48 UTC
</div> </div>
</div> </div>
</body> </body>
......
...@@ -11616,6 +11616,11 @@ ...@@ -11616,6 +11616,11 @@
"type": "integer", "type": "integer",
"format": "int64" "format": "int64"
}, },
"readyReplicas": {
"description": "Total number of ready pods targeted by this deployment.",
"type": "integer",
"format": "int32"
},
"replicas": { "replicas": {
"description": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).", "description": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).",
"type": "integer", "type": "integer",
......
...@@ -312,6 +312,10 @@ type DeploymentStatus struct { ...@@ -312,6 +312,10 @@ type DeploymentStatus struct {
// +optional // +optional
UpdatedReplicas int32 UpdatedReplicas int32
// Total number of ready pods targeted by this deployment.
// +optional
ReadyReplicas int32
// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment. // Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
// +optional // +optional
AvailableReplicas int32 AvailableReplicas int32
......
...@@ -262,6 +262,10 @@ message DeploymentStatus { ...@@ -262,6 +262,10 @@ message DeploymentStatus {
// +optional // +optional
optional int32 updatedReplicas = 3; optional int32 updatedReplicas = 3;
// Total number of ready pods targeted by this deployment.
// +optional
optional int32 readyReplicas = 7;
// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment. // Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
// +optional // +optional
optional int32 availableReplicas = 4; optional int32 availableReplicas = 4;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -397,6 +397,10 @@ type DeploymentStatus struct { ...@@ -397,6 +397,10 @@ type DeploymentStatus struct {
// +optional // +optional
UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,3,opt,name=updatedReplicas"` UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,3,opt,name=updatedReplicas"`
// Total number of ready pods targeted by this deployment.
// +optional
ReadyReplicas int32 `json:"readyReplicas,omitempty" protobuf:"varint,7,opt,name=readyReplicas"`
// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment. // Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
// +optional // +optional
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,4,opt,name=availableReplicas"` AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,4,opt,name=availableReplicas"`
......
...@@ -174,6 +174,7 @@ var map_DeploymentStatus = map[string]string{ ...@@ -174,6 +174,7 @@ var map_DeploymentStatus = map[string]string{
"observedGeneration": "The generation observed by the deployment controller.", "observedGeneration": "The generation observed by the deployment controller.",
"replicas": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).", "replicas": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).",
"updatedReplicas": "Total number of non-terminated pods targeted by this deployment that have the desired template spec.", "updatedReplicas": "Total number of non-terminated pods targeted by this deployment that have the desired template spec.",
"readyReplicas": "Total number of ready pods targeted by this deployment.",
"availableReplicas": "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.", "availableReplicas": "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.",
"unavailableReplicas": "Total number of unavailable pods targeted by this deployment.", "unavailableReplicas": "Total number of unavailable pods targeted by this deployment.",
"conditions": "Represents the latest available observations of a deployment's current state.", "conditions": "Represents the latest available observations of a deployment's current state.",
......
...@@ -553,6 +553,7 @@ func autoConvert_v1beta1_DeploymentStatus_To_extensions_DeploymentStatus(in *Dep ...@@ -553,6 +553,7 @@ func autoConvert_v1beta1_DeploymentStatus_To_extensions_DeploymentStatus(in *Dep
out.ObservedGeneration = in.ObservedGeneration out.ObservedGeneration = in.ObservedGeneration
out.Replicas = in.Replicas out.Replicas = in.Replicas
out.UpdatedReplicas = in.UpdatedReplicas out.UpdatedReplicas = in.UpdatedReplicas
out.ReadyReplicas = in.ReadyReplicas
out.AvailableReplicas = in.AvailableReplicas out.AvailableReplicas = in.AvailableReplicas
out.UnavailableReplicas = in.UnavailableReplicas out.UnavailableReplicas = in.UnavailableReplicas
out.Conditions = *(*[]extensions.DeploymentCondition)(unsafe.Pointer(&in.Conditions)) out.Conditions = *(*[]extensions.DeploymentCondition)(unsafe.Pointer(&in.Conditions))
...@@ -567,6 +568,7 @@ func autoConvert_extensions_DeploymentStatus_To_v1beta1_DeploymentStatus(in *ext ...@@ -567,6 +568,7 @@ func autoConvert_extensions_DeploymentStatus_To_v1beta1_DeploymentStatus(in *ext
out.ObservedGeneration = in.ObservedGeneration out.ObservedGeneration = in.ObservedGeneration
out.Replicas = in.Replicas out.Replicas = in.Replicas
out.UpdatedReplicas = in.UpdatedReplicas out.UpdatedReplicas = in.UpdatedReplicas
out.ReadyReplicas = in.ReadyReplicas
out.AvailableReplicas = in.AvailableReplicas out.AvailableReplicas = in.AvailableReplicas
out.UnavailableReplicas = in.UnavailableReplicas out.UnavailableReplicas = in.UnavailableReplicas
out.Conditions = *(*[]DeploymentCondition)(unsafe.Pointer(&in.Conditions)) out.Conditions = *(*[]DeploymentCondition)(unsafe.Pointer(&in.Conditions))
......
...@@ -380,6 +380,7 @@ func DeepCopy_v1beta1_DeploymentStatus(in interface{}, out interface{}, c *conve ...@@ -380,6 +380,7 @@ func DeepCopy_v1beta1_DeploymentStatus(in interface{}, out interface{}, c *conve
out.ObservedGeneration = in.ObservedGeneration out.ObservedGeneration = in.ObservedGeneration
out.Replicas = in.Replicas out.Replicas = in.Replicas
out.UpdatedReplicas = in.UpdatedReplicas out.UpdatedReplicas = in.UpdatedReplicas
out.ReadyReplicas = in.ReadyReplicas
out.AvailableReplicas = in.AvailableReplicas out.AvailableReplicas = in.AvailableReplicas
out.UnavailableReplicas = in.UnavailableReplicas out.UnavailableReplicas = in.UnavailableReplicas
if in.Conditions != nil { if in.Conditions != nil {
......
...@@ -281,6 +281,7 @@ func ValidateDeploymentStatus(status *extensions.DeploymentStatus, fldPath *fiel ...@@ -281,6 +281,7 @@ func ValidateDeploymentStatus(status *extensions.DeploymentStatus, fldPath *fiel
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(status.ObservedGeneration, fldPath.Child("observedGeneration"))...) allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(status.ObservedGeneration, fldPath.Child("observedGeneration"))...)
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.Replicas), fldPath.Child("replicas"))...) allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.Replicas), fldPath.Child("replicas"))...)
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.UpdatedReplicas), fldPath.Child("updatedReplicas"))...) allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.UpdatedReplicas), fldPath.Child("updatedReplicas"))...)
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.ReadyReplicas), fldPath.Child("readyReplicas"))...)
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.AvailableReplicas), fldPath.Child("availableReplicas"))...) allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.AvailableReplicas), fldPath.Child("availableReplicas"))...)
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.UnavailableReplicas), fldPath.Child("unavailableReplicas"))...) allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.UnavailableReplicas), fldPath.Child("unavailableReplicas"))...)
return allErrs return allErrs
......
...@@ -359,6 +359,7 @@ func DeepCopy_extensions_DeploymentStatus(in interface{}, out interface{}, c *co ...@@ -359,6 +359,7 @@ func DeepCopy_extensions_DeploymentStatus(in interface{}, out interface{}, c *co
out.ObservedGeneration = in.ObservedGeneration out.ObservedGeneration = in.ObservedGeneration
out.Replicas = in.Replicas out.Replicas = in.Replicas
out.UpdatedReplicas = in.UpdatedReplicas out.UpdatedReplicas = in.UpdatedReplicas
out.ReadyReplicas = in.ReadyReplicas
out.AvailableReplicas = in.AvailableReplicas out.AvailableReplicas = in.AvailableReplicas
out.UnavailableReplicas = in.UnavailableReplicas out.UnavailableReplicas = in.UnavailableReplicas
if in.Conditions != nil { if in.Conditions != nil {
......
...@@ -595,6 +595,7 @@ func calculateStatus(allRSs []*extensions.ReplicaSet, newRS *extensions.ReplicaS ...@@ -595,6 +595,7 @@ func calculateStatus(allRSs []*extensions.ReplicaSet, newRS *extensions.ReplicaS
ObservedGeneration: deployment.Generation, ObservedGeneration: deployment.Generation,
Replicas: deploymentutil.GetActualReplicaCountForReplicaSets(allRSs), Replicas: deploymentutil.GetActualReplicaCountForReplicaSets(allRSs),
UpdatedReplicas: deploymentutil.GetActualReplicaCountForReplicaSets([]*extensions.ReplicaSet{newRS}), UpdatedReplicas: deploymentutil.GetActualReplicaCountForReplicaSets([]*extensions.ReplicaSet{newRS}),
ReadyReplicas: deploymentutil.GetReadyReplicaCountForReplicaSets(allRSs),
AvailableReplicas: availableReplicas, AvailableReplicas: availableReplicas,
UnavailableReplicas: unavailableReplicas, UnavailableReplicas: unavailableReplicas,
} }
......
...@@ -782,6 +782,17 @@ func GetActualReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) i ...@@ -782,6 +782,17 @@ func GetActualReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) i
return totalActualReplicas return totalActualReplicas
} }
// GetReadyReplicaCountForReplicaSets returns the number of ready pods corresponding to the given replica sets.
func GetReadyReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32 {
totalReadyReplicas := int32(0)
for _, rs := range replicaSets {
if rs != nil {
totalReadyReplicas += rs.Status.ReadyReplicas
}
}
return totalReadyReplicas
}
// GetAvailableReplicaCountForReplicaSets returns the number of available pods corresponding to the given replica sets. // GetAvailableReplicaCountForReplicaSets returns the number of available pods corresponding to the given replica sets.
func GetAvailableReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32 { func GetAvailableReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int32 {
totalAvailableReplicas := int32(0) totalAvailableReplicas := int32(0)
......
...@@ -10275,6 +10275,13 @@ var OpenAPIDefinitions *common.OpenAPIDefinitions = &common.OpenAPIDefinitions{ ...@@ -10275,6 +10275,13 @@ var OpenAPIDefinitions *common.OpenAPIDefinitions = &common.OpenAPIDefinitions{
Format: "int32", Format: "int32",
}, },
}, },
"readyReplicas": {
SchemaProps: spec.SchemaProps{
Description: "Total number of ready pods targeted by this deployment.",
Type: []string{"integer"},
Format: "int32",
},
},
"availableReplicas": { "availableReplicas": {
SchemaProps: spec.SchemaProps{ SchemaProps: spec.SchemaProps{
Description: "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.", Description: "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment