@@ -108,8 +108,8 @@ type DatabaseStatefulSetOptions struct {
108
108
// InitDatabaseImage is the image used for the init container as well as for the static binary holder
109
109
InitDatabaseImage string
110
110
DatabaseNonStaticImage string
111
- MongodbImage string
112
- AgentImage string
111
+ MongodbImage string
112
+ AgentImage string
113
113
114
114
Annotations map [string ]string
115
115
VaultConfig vault.VaultConfiguration
@@ -414,8 +414,6 @@ func buildDatabaseStatefulSetConfigurationFunction(mdb databaseStatefulSetSource
414
414
PodAntiAffinityLabelKey : opts .Name ,
415
415
}
416
416
417
- configurePodSpecSecurityContext , _ := podtemplatespec .WithDefaultSecurityContextsModifications ()
418
-
419
417
configureImagePullSecrets := podtemplatespec .NOOP ()
420
418
name , found := env .Read (util .ImagePullSecrets ) // nolint:forbidigo
421
419
if found {
@@ -469,8 +467,6 @@ func buildDatabaseStatefulSetConfigurationFunction(mdb databaseStatefulSetSource
469
467
}
470
468
471
469
shareProcessNs := statefulset .NOOP ()
472
- secondContainerModification := podtemplatespec .NOOP ()
473
-
474
470
if architectures .IsRunningStaticArchitecture (mdb .GetAnnotations ()) {
475
471
shareProcessNs = func (sts * appsv1.StatefulSet ) {
476
472
sts .Spec .Template .Spec .ShareProcessNamespace = ptr .To (true )
@@ -493,9 +489,7 @@ func buildDatabaseStatefulSetConfigurationFunction(mdb databaseStatefulSetSource
493
489
podtemplatespec .WithAffinity (podAffinity , PodAntiAffinityLabelKey , 100 ),
494
490
podtemplatespec .WithTerminationGracePeriodSeconds (util .DefaultPodTerminationPeriodSeconds ),
495
491
podtemplatespec .WithPodLabels (podLabels ),
496
- secondContainerModification ,
497
492
volumesFunc ,
498
- configurePodSpecSecurityContext ,
499
493
configureImagePullSecrets ,
500
494
podTemplateSpecFunc ,
501
495
)),
@@ -664,21 +658,16 @@ func getVolumesAndVolumeMounts(mdb databaseStatefulSetSource, databaseOpts Datab
664
658
// buildMongoDBPodTemplateSpec constructs the podTemplateSpec for the MongoDB resource
665
659
func buildMongoDBPodTemplateSpec (opts DatabaseStatefulSetOptions , mdb databaseStatefulSetSource , log * zap.SugaredLogger ) podtemplatespec.Modification {
666
660
serviceAccountName := getServiceAccountName (opts )
661
+ configurePodSpecSecurityContext , _ := podtemplatespec .WithDefaultSecurityContextsModifications ()
667
662
668
663
// scripts volume is shared by the init container and the AppDB, so the startup
669
664
// script can be copied over
670
665
scriptsVolume := statefulset .CreateVolumeFromEmptyDir ("database-scripts" )
671
-
672
666
volumes := []corev1.Volume {scriptsVolume }
667
+
673
668
secretsToInject := buildVaultDatabaseSecretsToInject (mdb , opts )
674
669
_ , volumeMounts , _ := getVolumesAndPVCs (mdb , opts , secretsToInject , log )
675
670
676
- // Add hostname override volume if specified
677
- if opts .HostNameOverrideConfigmapName != "" {
678
- volumes = append (volumes , statefulset .CreateVolumeFromConfigMap (opts .HostNameOverrideConfigmapName , opts .HostNameOverrideConfigmapName ))
679
- }
680
-
681
- configurePodSpecSecurityContext , _ := podtemplatespec .WithDefaultSecurityContextsModifications ()
682
671
pullSecretsConfigurationFunc := podtemplatespec .NOOP ()
683
672
if pullSecrets , ok := env .Read (util .ImagePullSecrets ); ok { // nolint:forbidigo
684
673
pullSecretsConfigurationFunc = podtemplatespec .WithImagePullSecrets (pullSecrets )
@@ -798,12 +787,15 @@ func createDatabaseInitContainer(opts DatabaseStatefulSetOptions) corev1.Contain
798
787
799
788
// createDatabaseContainer creates the database container for non-static architecture
800
789
func createDatabaseContainer (opts DatabaseStatefulSetOptions , volumeMounts []corev1.VolumeMount ) corev1.Container {
790
+ // scripts volume is shared by the init container and the AppDB, so the startup
791
+ // script can be copied over
792
+
801
793
c := corev1.Container {
802
794
Name : util .DatabaseContainerName ,
803
795
Image : opts .DatabaseNonStaticImage ,
804
796
Command : []string {"/opt/scripts/agent-launcher.sh" },
805
797
Env : databaseEnvVars (opts ),
806
- VolumeMounts : volumeMounts ,
798
+ VolumeMounts : append ( volumeMounts , databaseScriptsVolumeMount ( true )) ,
807
799
Resources : buildRequirementsFromPodSpec (* opts .PodSpec ),
808
800
Ports : []corev1.ContainerPort {{ContainerPort : opts .ServicePort }},
809
801
ImagePullPolicy : corev1 .PullPolicy (env .ReadOrPanic (util .AutomationAgentImagePullPolicy )),
@@ -818,7 +810,7 @@ func createDatabaseContainer(opts DatabaseStatefulSetOptions, volumeMounts []cor
818
810
819
811
_ , containerSecurityContext := podtemplatespec .WithDefaultSecurityContextsModifications ()
820
812
821
- sharedDatabaseContainerFunc ( opts .DatabaseNonStaticImage , * opts .PodSpec , volumeMounts , containerSecurityContext , opts .ServicePort )(& c )
813
+ sharedDatabaseContainerFunc (opts .DatabaseNonStaticImage , * opts .PodSpec , volumeMounts , containerSecurityContext , opts .ServicePort )(& c )
822
814
823
815
return c
824
816
}
0 commit comments