api: Introduce minReadySeconds,AvailableReplicas in Statefulset

The minReadySeconds field on StatefulSet specifies the minimum
number of seconds for which a newly created Pod should be
ready without any of its containers crashing, for it to
be considered available. The AvailableReplicas field
in the status reflects the replicas that are available
This commit is contained in:
ravisantoshgudimetla 2021-04-05 17:07:59 -04:00
parent a8985871f9
commit 49af835852
10 changed files with 65 additions and 1 deletions

View File

@ -157,6 +157,13 @@ type StatefulSetSpec struct {
// consists of all revisions not represented by a currently applied
// StatefulSetSpec version. The default value is 10.
RevisionHistoryLimit *int32
// Minimum number of seconds for which a newly created pod should be ready
// without any of its container crashing for it to be considered available.
// Defaults to 0 (pod will be considered available as soon as it is ready)
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
// +optional
MinReadySeconds int32
}
// StatefulSetStatus represents the current state of a StatefulSet.
@ -196,6 +203,12 @@ type StatefulSetStatus struct {
// Represents the latest available observations of a statefulset's current state.
Conditions []StatefulSetCondition
// Total number of available pods (ready for at least minReadySeconds) targeted by this statefulset.
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
// Remove omitempty when graduating to beta
// +optional
AvailableReplicas int32
}
// StatefulSetConditionType describes the condition types of StatefulSets.

View File

@ -208,6 +208,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
},
Spec: appsv1.StatefulSetSpec{
Replicas: &defaultReplicas,
MinReadySeconds: int32(0),
Template: defaultTemplate,
PodManagementPolicy: appsv1.OrderedReadyPodManagement,
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
@ -235,6 +236,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
},
Spec: appsv1.StatefulSetSpec{
Replicas: &defaultReplicas,
MinReadySeconds: int32(0),
Template: defaultTemplate,
PodManagementPolicy: appsv1.OrderedReadyPodManagement,
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
@ -257,6 +259,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
},
Spec: appsv1.StatefulSetSpec{
Replicas: &defaultReplicas,
MinReadySeconds: int32(0),
Template: defaultTemplate,
PodManagementPolicy: appsv1.ParallelPodManagement,
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
@ -286,6 +289,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
},
Spec: appsv1.StatefulSetSpec{
Replicas: &defaultReplicas,
MinReadySeconds: int32(0),
Template: defaultTemplate,
PodManagementPolicy: appsv1.OrderedReadyPodManagement,
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{

View File

@ -1168,6 +1168,7 @@ func autoConvert_v1_StatefulSetSpec_To_apps_StatefulSetSpec(in *v1.StatefulSetSp
return err
}
out.RevisionHistoryLimit = (*int32)(unsafe.Pointer(in.RevisionHistoryLimit))
out.MinReadySeconds = in.MinReadySeconds
return nil
}
@ -1186,6 +1187,7 @@ func autoConvert_apps_StatefulSetSpec_To_v1_StatefulSetSpec(in *apps.StatefulSet
return err
}
out.RevisionHistoryLimit = (*int32)(unsafe.Pointer(in.RevisionHistoryLimit))
out.MinReadySeconds = in.MinReadySeconds
return nil
}

View File

@ -60,7 +60,6 @@ func SetDefaults_StatefulSet(obj *appsv1beta1.StatefulSet) {
obj.Spec.UpdateStrategy.RollingUpdate.Partition = new(int32)
*obj.Spec.UpdateStrategy.RollingUpdate.Partition = 0
}
}
// SetDefaults_Deployment sets additional defaults compared to its counterpart

View File

@ -832,6 +832,7 @@ func autoConvert_v1beta1_StatefulSetSpec_To_apps_StatefulSetSpec(in *v1beta1.Sta
return err
}
out.RevisionHistoryLimit = (*int32)(unsafe.Pointer(in.RevisionHistoryLimit))
out.MinReadySeconds = in.MinReadySeconds
return nil
}
@ -850,6 +851,7 @@ func autoConvert_apps_StatefulSetSpec_To_v1beta1_StatefulSetSpec(in *apps.Statef
return err
}
out.RevisionHistoryLimit = (*int32)(unsafe.Pointer(in.RevisionHistoryLimit))
out.MinReadySeconds = in.MinReadySeconds
return nil
}

View File

@ -207,6 +207,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
},
Spec: appsv1beta2.StatefulSetSpec{
Replicas: &defaultReplicas,
MinReadySeconds: int32(0),
Template: defaultTemplate,
PodManagementPolicy: appsv1beta2.OrderedReadyPodManagement,
UpdateStrategy: appsv1beta2.StatefulSetUpdateStrategy{
@ -234,6 +235,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
},
Spec: appsv1beta2.StatefulSetSpec{
Replicas: &defaultReplicas,
MinReadySeconds: int32(0),
Template: defaultTemplate,
PodManagementPolicy: appsv1beta2.OrderedReadyPodManagement,
UpdateStrategy: appsv1beta2.StatefulSetUpdateStrategy{
@ -256,6 +258,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
},
Spec: appsv1beta2.StatefulSetSpec{
Replicas: &defaultReplicas,
MinReadySeconds: int32(0),
Template: defaultTemplate,
PodManagementPolicy: appsv1beta2.ParallelPodManagement,
UpdateStrategy: appsv1beta2.StatefulSetUpdateStrategy{

View File

@ -1264,6 +1264,7 @@ func autoConvert_v1beta2_StatefulSetSpec_To_apps_StatefulSetSpec(in *v1beta2.Sta
return err
}
out.RevisionHistoryLimit = (*int32)(unsafe.Pointer(in.RevisionHistoryLimit))
out.MinReadySeconds = in.MinReadySeconds
return nil
}
@ -1282,6 +1283,7 @@ func autoConvert_apps_StatefulSetSpec_To_v1beta2_StatefulSetSpec(in *apps.Statef
return err
}
out.RevisionHistoryLimit = (*int32)(unsafe.Pointer(in.RevisionHistoryLimit))
out.MinReadySeconds = in.MinReadySeconds
return nil
}

View File

@ -175,6 +175,13 @@ type StatefulSetSpec struct {
// consists of all revisions not represented by a currently applied
// StatefulSetSpec version. The default value is 10.
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,8,opt,name=revisionHistoryLimit"`
// Minimum number of seconds for which a newly created pod should be ready
// without any of its container crashing for it to be considered available.
// Defaults to 0 (pod will be considered available as soon as it is ready)
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
// +optional
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"`
}
// StatefulSetStatus represents the current state of a StatefulSet.
@ -217,6 +224,12 @@ type StatefulSetStatus struct {
// +patchMergeKey=type
// +patchStrategy=merge
Conditions []StatefulSetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,10,rep,name=conditions"`
// Total number of available pods (ready for at least minReadySeconds) targeted by this statefulset.
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
// Remove omitempty when graduating to beta
// +optional
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,11,opt,name=availableReplicas"`
}
type StatefulSetConditionType string

View File

@ -218,6 +218,13 @@ type StatefulSetSpec struct {
// consists of all revisions not represented by a currently applied
// StatefulSetSpec version. The default value is 10.
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,8,opt,name=revisionHistoryLimit"`
// Minimum number of seconds for which a newly created pod should be ready
// without any of its container crashing for it to be considered available.
// Defaults to 0 (pod will be considered available as soon as it is ready)
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
// +optional
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"`
}
// StatefulSetStatus represents the current state of a StatefulSet.
@ -260,6 +267,12 @@ type StatefulSetStatus struct {
// +patchMergeKey=type
// +patchStrategy=merge
Conditions []StatefulSetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,10,rep,name=conditions"`
// Total number of available pods (ready for at least minReadySeconds) targeted by this StatefulSet.
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
// Remove omitempty when graduating to beta
// +optional
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,11,opt,name=availableReplicas"`
}
type StatefulSetConditionType string

View File

@ -228,6 +228,13 @@ type StatefulSetSpec struct {
// consists of all revisions not represented by a currently applied
// StatefulSetSpec version. The default value is 10.
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,8,opt,name=revisionHistoryLimit"`
// Minimum number of seconds for which a newly created pod should be ready
// without any of its container crashing for it to be considered available.
// Defaults to 0 (pod will be considered available as soon as it is ready)
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
// +optional
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"`
}
// StatefulSetStatus represents the current state of a StatefulSet.
@ -270,6 +277,12 @@ type StatefulSetStatus struct {
// +patchMergeKey=type
// +patchStrategy=merge
Conditions []StatefulSetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,10,rep,name=conditions"`
// Total number of available pods (ready for at least minReadySeconds) targeted by this StatefulSet.
// This is an alpha field and requires enabling StatefulSetMinReadySeconds feature gate.
// Remove omitempty when graduating to beta
// +optional
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,11,opt,name=availableReplicas"`
}
type StatefulSetConditionType string