diff --git a/api/common_types.go b/api/common_types.go index 42af4be25..c0212cf31 100644 --- a/api/common_types.go +++ b/api/common_types.go @@ -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 diff --git a/k8sutils/redis-cluster.go b/k8sutils/redis-cluster.go index bfecb9ab2..9cc63ecd3 100644 --- a/k8sutils/redis-cluster.go +++ b/k8sutils/redis-cluster.go @@ -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, @@ -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 diff --git a/k8sutils/statefulset.go b/k8sutils/statefulset.go index 10d5f0288..bc31d4975 100644 --- a/k8sutils/statefulset.go +++ b/k8sutils/statefulset.go @@ -107,6 +107,7 @@ type statefulSetParameters struct { TerminationGracePeriodSeconds *int64 IgnoreAnnotations []string HostNetwork bool + MinReadySeconds int32 } // containerParameters will define container input params @@ -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(),