Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/v1beta1/rabbitmqcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ type StatefulSetSpec struct {
// Template.
// +optional
UpdateStrategy *appsv1.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty" protobuf:"bytes,7,opt,name=updateStrategy"`

// The minimum number of seconds for which a newly created StatefulSet 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).
// +optional
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,4,opt,name=minReadySeconds"`
}

// EmbeddedLabelsAnnotations is an embedded subset of the fields included in k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta.
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,9 @@ spec:
type: object
spec:
properties:
minReadySeconds:
format: int32
type: integer
podManagementPolicy:
type: string
replicas:
Expand Down
1 change: 1 addition & 0 deletions docs/api/rabbitmq.com.ref.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ StatefulSetSpec contains a subset of the fields included in k8s.io/api/apps/v1.S
| *`serviceName`* __string__ | serviceName is the name of the service that governs this StatefulSet. This service must exist before the StatefulSet, and is responsible for the network identity of the set. Pods get DNS/hostnames that follow the pattern: pod-specific-string.serviceName.default.svc.cluster.local where "pod-specific-string" is managed by the StatefulSet controller.
| *`podManagementPolicy`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#podmanagementpolicytype-v1-apps[$$PodManagementPolicyType$$]__ | podManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. The default policy is `OrderedReady`, where pods are created in increasing order (pod-0, then pod-1, etc) and the controller will wait until each pod is ready before continuing. When scaling down, the pods are removed in the opposite order. The alternative policy is `Parallel` which will create pods in parallel to match the desired scale without waiting, and on scale down will delete all pods at once.
| *`updateStrategy`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#statefulsetupdatestrategy-v1-apps[$$StatefulSetUpdateStrategy$$]__ | updateStrategy indicates the StatefulSetUpdateStrategy that will be employed to update Pods in the StatefulSet when a revision is made to Template.
| *`minReadySeconds`* __integer__ | The minimum number of seconds for which a newly created StatefulSet 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).
|===


Expand Down
5 changes: 5 additions & 0 deletions internal/resource/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (builder *StatefulSetBuilder) Build() (client.Object, error) {
if overrideSts.Spec.ServiceName != "" {
sts.Spec.ServiceName = overrideSts.Spec.ServiceName
}

}

return sts, nil
Expand Down Expand Up @@ -162,6 +163,10 @@ func applyStsOverride(instance *rabbitmqv1beta1.RabbitmqCluster, scheme *runtime
sts.Spec.PodManagementPolicy = stsOverride.Spec.PodManagementPolicy
}

if stsOverride.Spec.MinReadySeconds != 0 {
sts.Spec.MinReadySeconds = stsOverride.Spec.MinReadySeconds
}

if len(stsOverride.Spec.VolumeClaimTemplates) != 0 {
// If spec.persistence.storage == 0, ignore PVC overrides.
// Main reason for that is that there is no default PVC in such case (emptyDir is used instead)
Expand Down
12 changes: 12 additions & 0 deletions internal/resource/statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,18 @@ default_pass = {{ .Data.data.password }}
Expect(*statefulSet.Spec.Replicas).To(Equal(int32(10)))
})

It("overrides statefulSet.spec.MinReadySeconds", func() {
instance.Spec.Override.StatefulSet = &rabbitmqv1beta1.StatefulSet{
Spec: &rabbitmqv1beta1.StatefulSetSpec{
MinReadySeconds: 10,
},
}

stsBuilder := builder.StatefulSet()
Expect(stsBuilder.Update(statefulSet)).To(Succeed())
Expect(statefulSet.Spec.MinReadySeconds).To(Equal(int32(10)))
})

It("overrides statefulSet.spec.podManagementPolicy", func() {
instance.Spec.Override.StatefulSet = &rabbitmqv1beta1.StatefulSet{
Spec: &rabbitmqv1beta1.StatefulSetSpec{
Expand Down