@@ -122,6 +122,8 @@ func appDbPodSpec(initContainerImage string, om om.MongoDBOpsManager) podtemplat
122
122
construct .AgentName ,
123
123
container .WithResourceRequirements (buildRequirementsFromPodSpec (* appdbPodSpec )),
124
124
)
125
+ scriptsVolumeMount := statefulset .CreateVolumeMount ("agent-scripts" , "/opt/scripts" , statefulset .WithReadOnly (false ))
126
+ hooksVolumeMount := statefulset .CreateVolumeMount ("hooks" , "/hooks" , statefulset .WithReadOnly (false ))
125
127
126
128
initUpdateFunc := podtemplatespec .NOOP ()
127
129
if ! architectures .IsRunningStaticArchitecture (om .Annotations ) {
@@ -130,8 +132,6 @@ func appDbPodSpec(initContainerImage string, om om.MongoDBOpsManager) podtemplat
130
132
// volumes of different containers.
131
133
initUpdateFunc = func (templateSpec * corev1.PodTemplateSpec ) {
132
134
templateSpec .Spec .InitContainers = []corev1.Container {}
133
- scriptsVolumeMount := statefulset .CreateVolumeMount ("agent-scripts" , "/opt/scripts" , statefulset .WithReadOnly (false ))
134
- hooksVolumeMount := statefulset .CreateVolumeMount ("hooks" , "/hooks" , statefulset .WithReadOnly (false ))
135
135
podtemplatespec .WithInitContainer (InitAppDbContainerName , buildAppDBInitContainer (initContainerImage , []corev1.VolumeMount {scriptsVolumeMount , hooksVolumeMount }))(templateSpec )
136
136
}
137
137
}
@@ -233,6 +233,12 @@ func CAConfigMapName(appDb om.AppDBSpec, log *zap.SugaredLogger) string {
233
233
// and volumemounts for TLS.
234
234
func tlsVolumes (appDb om.AppDBSpec , podVars * env.PodEnvVars , log * zap.SugaredLogger ) podtemplatespec.Modification {
235
235
volumesToAdd , volumeMounts := getTLSVolumesAndVolumeMounts (appDb , podVars , log )
236
+
237
+ // Add agent API key volume mount if not using vault and monitoring is enabled
238
+ if ! vault .IsVaultSecretBackend () && ShouldEnableMonitoring (podVars ) {
239
+ volumeMounts = append (volumeMounts , statefulset .CreateVolumeMount (AgentAPIKeyVolumeName , AgentAPIKeySecretPath ))
240
+ }
241
+
236
242
volumesFunc := func (spec * corev1.PodTemplateSpec ) {
237
243
for _ , v := range volumesToAdd {
238
244
podtemplatespec .WithVolume (v )(spec )
@@ -380,7 +386,7 @@ func AppDbStatefulSet(opsManager om.MongoDBOpsManager, podVars *env.PodEnvVars,
380
386
externalDomain := appDb .GetExternalDomainForMemberCluster (scaler .MemberClusterName ())
381
387
382
388
if ShouldEnableMonitoring (podVars ) {
383
- monitoringModification = addMonitoringContainer (* appDb , * podVars , opts , externalDomain , log )
389
+ monitoringModification = addMonitoringContainer (* appDb , * podVars , opts , externalDomain , architectures . IsRunningStaticArchitecture ( opsManager . Annotations ), log )
384
390
} else {
385
391
// Otherwise, let's remove for now every podTemplateSpec related to monitoring
386
392
// We will apply them when enabling monitoring
@@ -390,7 +396,7 @@ func AppDbStatefulSet(opsManager om.MongoDBOpsManager, podVars *env.PodEnvVars,
390
396
}
391
397
392
398
// We copy the Automation Agent command from community and add the agent startup parameters
393
- automationAgentCommand := construct .AutomationAgentCommand (true , opsManager .Spec .AppDB .GetAgentLogLevel (), opsManager .Spec .AppDB .GetAgentLogFile (), opsManager .Spec .AppDB .GetAgentMaxLogFileDurationHours ())
399
+ automationAgentCommand := construct .AutomationAgentCommand (architectures . IsRunningStaticArchitecture ( opsManager . Annotations ), true , opsManager .Spec .AppDB .GetAgentLogLevel (), opsManager .Spec .AppDB .GetAgentLogFile (), opsManager .Spec .AppDB .GetAgentMaxLogFileDurationHours ())
394
400
idx := len (automationAgentCommand ) - 1
395
401
automationAgentCommand [idx ] += appDb .AutomationAgent .StartupParameters .ToCommandLineArgs ()
396
402
@@ -403,13 +409,10 @@ func AppDbStatefulSet(opsManager om.MongoDBOpsManager, podVars *env.PodEnvVars,
403
409
MountPath : "/var/lib/automation/config/acVersion" ,
404
410
}
405
411
406
- // Here we ask to craete init containers which also creates required volumens .
412
+ // Here we ask to create init containers which also creates required volumes .
407
413
// Note that we provide empty images for init containers. They are not important
408
- // at this stage beucase later we will define our own init containers for non-static architecture.
409
- mod := construct .BuildMongoDBReplicaSetStatefulSetModificationFunction (& opsManager .Spec .AppDB , scaler , opts .MongodbImage , opts .AgentImage , "" , "" , true )
410
- if architectures .IsRunningStaticArchitecture (opsManager .Annotations ) {
411
- mod = construct .BuildMongoDBReplicaSetStatefulSetModificationFunction (& opsManager .Spec .AppDB , scaler , opts .MongodbImage , opts .AgentImage , "" , "" , false )
412
- }
414
+ // at this stage because later we will define our own init containers for non-static architecture.
415
+ mod := construct .BuildMongoDBReplicaSetStatefulSetModificationFunction (& opsManager .Spec .AppDB , scaler , opts .MongodbImage , opts .AgentImage , "" , "" , ! architectures .IsRunningStaticArchitecture (opsManager .Annotations ), opts .InitAppDBImage )
413
416
414
417
sts := statefulset .New (
415
418
mod ,
@@ -493,7 +496,7 @@ func getVolumeMountIndexByName(mounts []corev1.VolumeMount, name string) int {
493
496
// addMonitoringContainer returns a podtemplatespec modification that adds the monitoring container to the AppDB Statefulset.
494
497
// Note that this replicates some code from the functions that do this for the base AppDB Statefulset. After many iterations
495
498
// this was deemed to be an acceptable compromise to make code clearer and more maintainable.
496
- func addMonitoringContainer (appDB om.AppDBSpec , podVars env.PodEnvVars , opts AppDBStatefulSetOptions , externalDomain * string , log * zap.SugaredLogger ) podtemplatespec.Modification {
499
+ func addMonitoringContainer (appDB om.AppDBSpec , podVars env.PodEnvVars , opts AppDBStatefulSetOptions , externalDomain * string , isStatic bool , log * zap.SugaredLogger ) podtemplatespec.Modification {
497
500
var monitoringAcVolume corev1.Volume
498
501
var monitoringACFunc podtemplatespec.Modification
499
502
@@ -516,7 +519,7 @@ func addMonitoringContainer(appDB om.AppDBSpec, podVars env.PodEnvVars, opts App
516
519
}
517
520
// Construct the command by concatenating:
518
521
// 1. The base command - from community
519
- command := construct .MongodbUserCommandWithAPIKeyExport
522
+ command := construct .GetMongodbUserCommandWithAPIKeyExport ( isStatic )
520
523
command += "agent/mongodb-agent"
521
524
command += " -healthCheckFilePath=" + monitoringAgentHealthStatusFilePathValue
522
525
command += " -serveStatusPort=5001"
0 commit comments