Skip to content

Commit

Permalink
expose podManagementPolicy
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Rodgers <[email protected]>
  • Loading branch information
com6056 committed Aug 2, 2024
1 parent 6de507e commit a9f97cb
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 5 deletions.
1 change: 1 addition & 0 deletions api/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/redis.redis.opstreelabs.in_redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/content/en/docs/CRD Reference/Redis API/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions k8sutils/redis-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions k8sutils/redis-replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions k8sutils/redis-sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions k8sutils/redis-standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions k8sutils/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ type statefulSetParameters struct {
IgnoreAnnotations []string
HostNetwork bool
MinReadySeconds int32
PodManagementPolicy appsv1.PodManagementPolicyType
}

// containerParameters will define container input params
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit a9f97cb

Please sign in to comment.