@@ -21,10 +21,13 @@ import (
2121type statefulSetParameters struct {
2222 Replicas * int32
2323 Name string
24- Metadata metav1.ObjectMeta
2524 PersistentVolumeClaim corev1.PersistentVolumeClaim
2625 TerminationGracePeriodSeconds * int64
2726 UpdateStrategy appsv1.StatefulSetUpdateStrategyType
27+ NodeSelector map [string ]string
28+ Affinity * corev1.Affinity
29+ TopologySpreadConstraints []corev1.TopologySpreadConstraint
30+ PriorityClassName string
2831}
2932
3033type containerParameters struct {
@@ -43,6 +46,8 @@ type containerParameters struct {
4346 LivenessProbe databasev1alpha1.ContainerProbe
4447 ReadinessProbe databasev1alpha1.ContainerProbe
4548 GroupConfig databasev1alpha1.GroupConfig
49+ EnableConverters bool
50+ HugePages * databasev1alpha1.HugePages
4651}
4752
4853func (oc * OperatorContext ) ReconcileStatefulset () (reconcile.Result , error ) {
@@ -188,7 +193,11 @@ func generateStatefulSetsDef(stsMeta metav1.ObjectMeta, params statefulSetParame
188193 Spec : corev1.PodSpec {
189194 Containers : generateContainerDef (stsMeta .GetName (), containerParams ),
190195 TerminationGracePeriodSeconds : params .TerminationGracePeriodSeconds ,
191- Volumes : generateVolumes (stsMeta .Name ),
196+ Volumes : generateVolumes (stsMeta .Name , containerParams ),
197+ NodeSelector : params .NodeSelector ,
198+ Affinity : params .Affinity ,
199+ TopologySpreadConstraints : params .TopologySpreadConstraints ,
200+ PriorityClassName : params .PriorityClassName ,
192201 },
193202 },
194203 },
@@ -227,17 +236,18 @@ func generateContainerDef(name string, containerParams containerParameters) []co
227236 ImagePullPolicy : containerParams .ImagePullPolicy ,
228237 Env : getEnvironmentVariables (containerParams ),
229238 Lifecycle : getLifeCycle (),
230- VolumeMounts : getVolumeMount (),
239+ VolumeMounts : getVolumeMount (containerParams ),
231240 },
232241 }
233242 if containerParams .Resources != nil {
234243 containerDef [0 ].Resources = * containerParams .Resources
235244 }
236- if containerParams .LivenessProbe .Enabled == true {
245+
246+ if containerParams .LivenessProbe .Enabled {
237247 containerDef [0 ].LivenessProbe = getLivenessProbe (containerParams .LivenessProbe )
238248 }
239249
240- if containerParams .ReadinessProbe .Enabled == true {
250+ if containerParams .ReadinessProbe .Enabled {
241251 containerDef [0 ].ReadinessProbe = getReadinessProbe (containerParams .ReadinessProbe )
242252 }
243253
@@ -250,6 +260,10 @@ func generateStatefulSetsParams(cr *databasev1alpha1.MarklogicGroup) statefulSet
250260 Name : cr .Spec .Name ,
251261 TerminationGracePeriodSeconds : cr .Spec .TerminationGracePeriodSeconds ,
252262 UpdateStrategy : cr .Spec .UpdateStrategy ,
263+ NodeSelector : cr .Spec .NodeSelector ,
264+ Affinity : cr .Spec .Affinity ,
265+ TopologySpreadConstraints : cr .Spec .TopologySpreadConstraints ,
266+ PriorityClassName : cr .Spec .PriorityClassName ,
253267 }
254268 if cr .Spec .Storage != nil {
255269 params .PersistentVolumeClaim = generatePVCTemplate (cr .Spec .Storage .Size )
@@ -260,15 +274,16 @@ func generateStatefulSetsParams(cr *databasev1alpha1.MarklogicGroup) statefulSet
260274func generateContainerParams (cr * databasev1alpha1.MarklogicGroup ) containerParameters {
261275 trueProperty := true
262276 containerParams := containerParameters {
263- Image : cr .Spec .Image ,
264- Resources : cr .Spec .Resources ,
265- Name : cr .Spec .Name ,
266- Namespace : cr .Namespace ,
267- ClusterDomain : cr .Spec .ClusterDomain ,
268- BootstrapHost : cr .Spec .BootstrapHost ,
269- LivenessProbe : cr .Spec .LivenessProbe ,
270- ReadinessProbe : cr .Spec .ReadinessProbe ,
271- GroupConfig : cr .Spec .GroupConfig ,
277+ Image : cr .Spec .Image ,
278+ Resources : cr .Spec .Resources ,
279+ Name : cr .Spec .Name ,
280+ Namespace : cr .Namespace ,
281+ ClusterDomain : cr .Spec .ClusterDomain ,
282+ BootstrapHost : cr .Spec .BootstrapHost ,
283+ LivenessProbe : cr .Spec .LivenessProbe ,
284+ ReadinessProbe : cr .Spec .ReadinessProbe ,
285+ GroupConfig : cr .Spec .GroupConfig ,
286+ EnableConverters : cr .Spec .EnableConverters ,
272287 }
273288
274289 if cr .Spec .Storage != nil {
@@ -283,6 +298,9 @@ func generateContainerParams(cr *databasev1alpha1.MarklogicGroup) containerParam
283298 containerParams .LicenseKey = cr .Spec .License .Key
284299 containerParams .Licensee = cr .Spec .License .Licensee
285300 }
301+ if cr .Spec .HugePages .Enabled {
302+ containerParams .HugePages = cr .Spec .HugePages
303+ }
286304
287305 return containerParams
288306}
@@ -302,7 +320,7 @@ func getLifeCycle() *corev1.Lifecycle {
302320 }
303321}
304322
305- func generateVolumes (stsName string ) []corev1.Volume {
323+ func generateVolumes (stsName string , containerParams containerParameters ) []corev1.Volume {
306324 volumes := []corev1.Volume {}
307325 volumes = append (volumes , corev1.Volume {
308326 Name : "helm-scripts" ,
@@ -322,6 +340,17 @@ func generateVolumes(stsName string) []corev1.Volume {
322340 },
323341 },
324342 })
343+ if containerParams .HugePages .Enabled {
344+ volumes = append (volumes , corev1.Volume {
345+ Name : "huge-pages" ,
346+ VolumeSource : corev1.VolumeSource {
347+ EmptyDir : & corev1.EmptyDirVolumeSource {
348+ Medium : corev1 .StorageMediumHugePages ,
349+ },
350+ },
351+ })
352+ }
353+
325354 return volumes
326355}
327356
@@ -364,6 +393,10 @@ func getEnvironmentVariables(containerParams containerParameters) []corev1.EnvVa
364393 Name : "MARKLOGIC_CLUSTER_TYPE" ,
365394 Value : "bootstrap" ,
366395 },
396+ corev1.EnvVar {
397+ Name : "INSTALL_CONVERTERS" ,
398+ Value : strconv .FormatBool (containerParams .EnableConverters ),
399+ },
367400 )
368401 if containerParams .LicenseKey != "" {
369402 envVars = append (envVars , corev1.EnvVar {
@@ -390,7 +423,7 @@ func getEnvironmentVariables(containerParams containerParameters) []corev1.EnvVa
390423 return envVars
391424}
392425
393- func getVolumeMount () []corev1.VolumeMount {
426+ func getVolumeMount (containerParams containerParameters ) []corev1.VolumeMount {
394427 var VolumeMounts []corev1.VolumeMount
395428
396429 // if persistenceEnabled != nil && *persistenceEnabled {
@@ -409,6 +442,14 @@ func getVolumeMount() []corev1.VolumeMount {
409442 ReadOnly : true ,
410443 },
411444 )
445+ if containerParams .HugePages .Enabled {
446+ VolumeMounts = append (VolumeMounts ,
447+ corev1.VolumeMount {
448+ Name : "huge-pages" ,
449+ MountPath : containerParams .HugePages .MountPath ,
450+ },
451+ )
452+ }
412453 return VolumeMounts
413454}
414455
0 commit comments