mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
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:
parent
a8985871f9
commit
49af835852
@ -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.
|
||||
|
@ -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{
|
||||
|
2
pkg/apis/apps/v1/zz_generated.conversion.go
generated
2
pkg/apis/apps/v1/zz_generated.conversion.go
generated
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
2
pkg/apis/apps/v1beta1/zz_generated.conversion.go
generated
2
pkg/apis/apps/v1beta1/zz_generated.conversion.go
generated
@ -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
|
||||
}
|
||||
|
||||
|
@ -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{
|
||||
|
2
pkg/apis/apps/v1beta2/zz_generated.conversion.go
generated
2
pkg/apis/apps/v1beta2/zz_generated.conversion.go
generated
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user