diff --git a/k8sutils/const.go b/k8sutils/const.go new file mode 100644 index 000000000..3a3da6603 --- /dev/null +++ b/k8sutils/const.go @@ -0,0 +1,5 @@ +package k8sutils + +const ( + AnnotationKeyRecreateStatefulset = "redis.opstreelabs.in/recreate-statefulset" +) diff --git a/k8sutils/redis-cluster.go b/k8sutils/redis-cluster.go index a99fe8b19..a5bae1bb7 100644 --- a/k8sutils/redis-cluster.go +++ b/k8sutils/redis-cluster.go @@ -52,7 +52,7 @@ func generateRedisClusterParams(cr *redisv1beta1.RedisCluster, replicas int32, e if externalConfig != nil { res.ExternalConfig = externalConfig } - if _, found := cr.ObjectMeta.GetAnnotations()["redis.opstreelabs.in/recreate-statefulset"]; found { + if _, found := cr.ObjectMeta.GetAnnotations()[AnnotationKeyRecreateStatefulset]; found { res.RecreateStatefulSet = true } return res diff --git a/k8sutils/redis-replication.go b/k8sutils/redis-replication.go index 5874bfe4d..76f31b532 100644 --- a/k8sutils/redis-replication.go +++ b/k8sutils/redis-replication.go @@ -93,6 +93,9 @@ func generateRedisReplicationParams(cr *redisv1beta1.RedisReplication) statefulS if cr.Spec.ServiceAccountName != nil { res.ServiceAccountName = cr.Spec.ServiceAccountName } + if _, found := cr.ObjectMeta.GetAnnotations()[AnnotationKeyRecreateStatefulset]; found { + res.RecreateStatefulSet = true + } return res } diff --git a/k8sutils/redis-standalone.go b/k8sutils/redis-standalone.go index 3dadfcabe..a1321cb84 100644 --- a/k8sutils/redis-standalone.go +++ b/k8sutils/redis-standalone.go @@ -98,7 +98,7 @@ func generateRedisStandaloneParams(cr *redisv1beta1.Redis) statefulSetParameters if cr.Spec.ServiceAccountName != nil { res.ServiceAccountName = cr.Spec.ServiceAccountName } - if _, found := cr.ObjectMeta.GetAnnotations()["redis.opstreelabs.in/recreate-statefulset"]; found { + if _, found := cr.ObjectMeta.GetAnnotations()[AnnotationKeyRecreateStatefulset]; found { res.RecreateStatefulSet = true } return res