From 3c91672fc3681c599d7a952c9c33bf2d6f0d7b52 Mon Sep 17 00:00:00 2001 From: iamabhishek-dubey Date: Fri, 7 Oct 2022 14:55:50 +0530 Subject: [PATCH] Fixed issue for redis persistence Signed-off-by: iamabhishek-dubey --- api/v1beta1/rediscluster_types.go | 1 + api/v1beta1/zz_generated.deepcopy.go | 5 +++++ .../crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml | 2 ++ k8sutils/redis-cluster.go | 4 +++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/api/v1beta1/rediscluster_types.go b/api/v1beta1/rediscluster_types.go index 210f27104..c817e21ca 100644 --- a/api/v1beta1/rediscluster_types.go +++ b/api/v1beta1/rediscluster_types.go @@ -39,6 +39,7 @@ type RedisClusterSpec struct { TLS *TLSConfig `json:"TLS,omitempty"` Sidecars *[]Sidecar `json:"sidecars,omitempty"` ServiceAccountName *string `json:"serviceAccountName,omitempty"` + PersistenceEnabled *bool `json:"persistenceEnabled,omitempty"` } func (cr *RedisClusterSpec) GetReplicaCounts(t string) int32 { diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 1e2f5f90d..9ae16c08d 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -256,6 +256,11 @@ func (in *RedisClusterSpec) DeepCopyInto(out *RedisClusterSpec) { *out = new(string) **out = **in } + if in.PersistenceEnabled != nil { + in, out := &in.PersistenceEnabled, &out.PersistenceEnabled + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RedisClusterSpec. diff --git a/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml b/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml index 4976ca66b..78486b846 100644 --- a/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml +++ b/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml @@ -194,6 +194,8 @@ spec: additionalProperties: type: string type: object + persistenceEnabled: + type: boolean priorityClassName: type: string redisExporter: diff --git a/k8sutils/redis-cluster.go b/k8sutils/redis-cluster.go index 72779203f..eedc348e2 100644 --- a/k8sutils/redis-cluster.go +++ b/k8sutils/redis-cluster.go @@ -83,8 +83,10 @@ func generateRedisClusterContainerParams(cr *redisv1beta1.RedisCluster, readines if livenessProbeDef != nil { containerProp.LivenessProbe = livenessProbeDef } - if cr.Spec.Storage != nil { + if cr.Spec.Storage != nil && *cr.Spec.PersistenceEnabled { containerProp.PersistenceEnabled = &trueProperty + } else { + containerProp.PersistenceEnabled = &falseProperty } if cr.Spec.TLS != nil { containerProp.TLSConfig = cr.Spec.TLS