diff --git a/api/common_types.go b/api/common_types.go index c0212cf31..5e9ae247a 100644 --- a/api/common_types.go +++ b/api/common_types.go @@ -17,6 +17,7 @@ type KubernetesConfig struct { Service *ServiceConfig `json:"service,omitempty"` IgnoreAnnotations []string `json:"ignoreAnnotations,omitempty"` MinReadySeconds *int32 `json:"minReadySeconds,omitempty"` + PodManagementPolicy appsv1.PodManagementPolicyType `json:"podManagementPolicy,omitempty"` } // ServiceConfig define the type of service to be created and its annotations diff --git a/config/crd/bases/redis.redis.opstreelabs.in_redis.yaml b/config/crd/bases/redis.redis.opstreelabs.in_redis.yaml index 3ad451862..b86ea48d3 100644 --- a/config/crd/bases/redis.redis.opstreelabs.in_redis.yaml +++ b/config/crd/bases/redis.redis.opstreelabs.in_redis.yaml @@ -1110,6 +1110,10 @@ spec: minReadySeconds: format: int32 type: integer + podManagementPolicy: + description: PodManagementPolicyType defines the policy for creating + pods under a stateful set. + type: string redisSecret: description: ExistingPasswordSecret is the struct to access the existing secret @@ -6139,6 +6143,10 @@ spec: minReadySeconds: format: int32 type: integer + podManagementPolicy: + description: PodManagementPolicyType defines the policy for creating + pods under a stateful set. + type: string redisSecret: description: ExistingPasswordSecret is the struct to access the existing secret diff --git a/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml b/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml index a5a596988..1244f4869 100644 --- a/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml +++ b/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml @@ -162,6 +162,10 @@ spec: minReadySeconds: format: int32 type: integer + podManagementPolicy: + description: PodManagementPolicyType defines the policy for creating + pods under a stateful set. + type: string redisSecret: description: ExistingPasswordSecret is the struct to access the existing secret @@ -6755,6 +6759,10 @@ spec: minReadySeconds: format: int32 type: integer + podManagementPolicy: + description: PodManagementPolicyType defines the policy for creating + pods under a stateful set. + type: string redisSecret: description: ExistingPasswordSecret is the struct to access the existing secret diff --git a/config/crd/bases/redis.redis.opstreelabs.in_redisreplications.yaml b/config/crd/bases/redis.redis.opstreelabs.in_redisreplications.yaml index 8cf6c32eb..35de896c1 100644 --- a/config/crd/bases/redis.redis.opstreelabs.in_redisreplications.yaml +++ b/config/crd/bases/redis.redis.opstreelabs.in_redisreplications.yaml @@ -1112,6 +1112,10 @@ spec: minReadySeconds: format: int32 type: integer + podManagementPolicy: + description: PodManagementPolicyType defines the policy for creating + pods under a stateful set. + type: string redisSecret: description: ExistingPasswordSecret is the struct to access the existing secret @@ -6147,6 +6151,10 @@ spec: minReadySeconds: format: int32 type: integer + podManagementPolicy: + description: PodManagementPolicyType defines the policy for creating + pods under a stateful set. + type: string redisSecret: description: ExistingPasswordSecret is the struct to access the existing secret diff --git a/config/crd/bases/redis.redis.opstreelabs.in_redissentinels.yaml b/config/crd/bases/redis.redis.opstreelabs.in_redissentinels.yaml index 4599c070b..10ca7ec32 100644 --- a/config/crd/bases/redis.redis.opstreelabs.in_redissentinels.yaml +++ b/config/crd/bases/redis.redis.opstreelabs.in_redissentinels.yaml @@ -1113,6 +1113,10 @@ spec: minReadySeconds: format: int32 type: integer + podManagementPolicy: + description: PodManagementPolicyType defines the policy for creating + pods under a stateful set. + type: string redisSecret: description: ExistingPasswordSecret is the struct to access the existing secret @@ -3601,6 +3605,10 @@ spec: minReadySeconds: format: int32 type: integer + podManagementPolicy: + description: PodManagementPolicyType defines the policy for creating + pods under a stateful set. + type: string redisSecret: description: ExistingPasswordSecret is the struct to access the existing secret diff --git a/docs/content/en/docs/CRD Reference/Redis API/_index.md b/docs/content/en/docs/CRD Reference/Redis API/_index.md index f0331d16c..46295d935 100644 --- a/docs/content/en/docs/CRD Reference/Redis API/_index.md +++ b/docs/content/en/docs/CRD Reference/Redis API/_index.md @@ -56,6 +56,7 @@ _Appears in:_ | `redisSecret` _[ExistingPasswordSecret](#existingpasswordsecret)_ | | | `imagePullSecrets` _[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#localobjectreference-v1-core)_ | | | `updateStrategy` _[StatefulSetUpdateStrategy](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetupdatestrategy-v1-apps)_ | | +| `podManagementPolicy` _[PodManagementPolicyType](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-management-policies)_ | | #### VolumeMount diff --git a/k8sutils/redis-cluster.go b/k8sutils/redis-cluster.go index 9cc63ecd3..399a50bcd 100644 --- a/k8sutils/redis-cluster.go +++ b/k8sutils/redis-cluster.go @@ -52,6 +52,7 @@ func generateRedisClusterParams(cr *redisv1beta2.RedisCluster, replicas int32, e IgnoreAnnotations: cr.Spec.KubernetesConfig.IgnoreAnnotations, HostNetwork: cr.Spec.HostNetwork, MinReadySeconds: minreadyseconds, + PodManagementPolicy: cr.Spec.KubernetesConfig.PodManagementPolicy, } if cr.Spec.RedisExporter != nil { res.EnableMetrics = cr.Spec.RedisExporter.Enabled diff --git a/k8sutils/redis-replication.go b/k8sutils/redis-replication.go index 66c066492..847603da9 100644 --- a/k8sutils/redis-replication.go +++ b/k8sutils/redis-replication.go @@ -99,6 +99,7 @@ func generateRedisReplicationParams(cr *redisv1beta2.RedisReplication) statefulS UpdateStrategy: cr.Spec.KubernetesConfig.UpdateStrategy, IgnoreAnnotations: cr.Spec.KubernetesConfig.IgnoreAnnotations, MinReadySeconds: minreadyseconds, + PodManagementPolicy: cr.Spec.KubernetesConfig.PodManagementPolicy, } if cr.Spec.KubernetesConfig.ImagePullSecrets != nil { res.ImagePullSecrets = cr.Spec.KubernetesConfig.ImagePullSecrets diff --git a/k8sutils/redis-sentinel.go b/k8sutils/redis-sentinel.go index 873b05e1c..83a557690 100644 --- a/k8sutils/redis-sentinel.go +++ b/k8sutils/redis-sentinel.go @@ -104,6 +104,7 @@ func generateRedisSentinelParams(cr *redisv1beta2.RedisSentinel, replicas int32, UpdateStrategy: cr.Spec.KubernetesConfig.UpdateStrategy, IgnoreAnnotations: cr.Spec.KubernetesConfig.IgnoreAnnotations, MinReadySeconds: minreadyseconds, + PodManagementPolicy: cr.Spec.KubernetesConfig.PodManagementPolicy, } if cr.Spec.KubernetesConfig.ImagePullSecrets != nil { diff --git a/k8sutils/redis-standalone.go b/k8sutils/redis-standalone.go index 4fed7d135..934a57f68 100644 --- a/k8sutils/redis-standalone.go +++ b/k8sutils/redis-standalone.go @@ -94,6 +94,7 @@ func generateRedisStandaloneParams(cr *redisv1beta2.Redis) statefulSetParameters UpdateStrategy: cr.Spec.KubernetesConfig.UpdateStrategy, IgnoreAnnotations: cr.Spec.KubernetesConfig.IgnoreAnnotations, MinReadySeconds: minreadyseconds, + PodManagementPolicy: cr.Spec.KubernetesConfig.PodManagementPolicy, } if cr.Spec.KubernetesConfig.ImagePullSecrets != nil { res.ImagePullSecrets = cr.Spec.KubernetesConfig.ImagePullSecrets diff --git a/k8sutils/statefulset.go b/k8sutils/statefulset.go index d230c9c49..d1f115d41 100644 --- a/k8sutils/statefulset.go +++ b/k8sutils/statefulset.go @@ -118,6 +118,7 @@ type statefulSetParameters struct { IgnoreAnnotations []string HostNetwork bool MinReadySeconds int32 + PodManagementPolicy appsv1.PodManagementPolicyType } // containerParameters will define container input params @@ -290,11 +291,12 @@ 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, - MinReadySeconds: params.MinReadySeconds, + Selector: LabelSelectors(stsMeta.GetLabels()), + ServiceName: fmt.Sprintf("%s-headless", stsMeta.Name), + Replicas: params.Replicas, + UpdateStrategy: params.UpdateStrategy, + MinReadySeconds: params.MinReadySeconds, + PodManagementPolicy: params.PodManagementPolicy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: stsMeta.GetLabels(),