Skip to content

Commit

Permalink
feat: support setting minReadySeconds on the stateful sets
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Robinson <[email protected]>
  • Loading branch information
mattrobinsonsre committed Jul 11, 2024
1 parent 0dddaea commit 43afd82
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type KubernetesConfig struct {
UpdateStrategy appsv1.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty"`
Service *ServiceConfig `json:"service,omitempty"`
IgnoreAnnotations []string `json:"ignoreAnnotations,omitempty"`
MinReadySeconds *int32 `json:"minReadySeconds,omitempty"`
}

// ServiceConfig define the type of service to be created and its annotations
Expand Down
5 changes: 5 additions & 0 deletions k8sutils/redis-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ type RedisClusterService struct {

// generateRedisClusterParams generates Redis cluster information
func generateRedisClusterParams(cr *redisv1beta2.RedisCluster, replicas int32, externalConfig *string, params RedisClusterSTS) statefulSetParameters {
var minreadyseconds int32 = 0
if cr.Spec.KubernetesConfig.MinReadySeconds != nil {
minreadyseconds = *cr.Spec.KubernetesConfig.MinReadySeconds
}
res := statefulSetParameters{
Replicas: &replicas,
ClusterMode: true,
Expand All @@ -47,6 +51,7 @@ func generateRedisClusterParams(cr *redisv1beta2.RedisCluster, replicas int32, e
UpdateStrategy: cr.Spec.KubernetesConfig.UpdateStrategy,
IgnoreAnnotations: cr.Spec.KubernetesConfig.IgnoreAnnotations,
HostNetwork: cr.Spec.HostNetwork,
MinReadySeconds: minreadyseconds,
}
if cr.Spec.RedisExporter != nil {
res.EnableMetrics = cr.Spec.RedisExporter.Enabled
Expand Down
10 changes: 6 additions & 4 deletions k8sutils/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type statefulSetParameters struct {
TerminationGracePeriodSeconds *int64
IgnoreAnnotations []string
HostNetwork bool
MinReadySeconds int32
}

// containerParameters will define container input params
Expand Down Expand Up @@ -279,10 +280,11 @@ func generateStatefulSetsDef(stsMeta metav1.ObjectMeta, params statefulSetParame
TypeMeta: generateMetaInformation("StatefulSet", "apps/v1"),
ObjectMeta: stsMeta,
Spec: appsv1.StatefulSetSpec{
Selector: LabelSelectors(stsMeta.GetLabels()),
ServiceName: fmt.Sprintf("%s-headless", stsMeta.Name),
Replicas: params.Replicas,
UpdateStrategy: params.UpdateStrategy,
Selector: LabelSelectors(stsMeta.GetLabels()),
ServiceName: fmt.Sprintf("%s-headless", stsMeta.Name),
Replicas: params.Replicas,
UpdateStrategy: params.UpdateStrategy,
MinReadySeconds: params.MinReadySeconds,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: stsMeta.GetLabels(),
Expand Down

0 comments on commit 43afd82

Please sign in to comment.