@@ -519,7 +519,6 @@ func (c *Cluster) generatePodTemplate(
519519 podAntiAffinityTopologyKey string ,
520520 additionalSecretMount string ,
521521 additionalSecretMountPath string ,
522- volumes []v1.Volume ,
523522 additionalVolumes []acidv1.AdditionalVolume ,
524523) (* v1.PodTemplateSpec , error ) {
525524
@@ -539,7 +538,6 @@ func (c *Cluster) generatePodTemplate(
539538 InitContainers : initContainers ,
540539 Tolerations : * tolerationsSpec ,
541540 SecurityContext : & securityContext ,
542- Volumes : volumes ,
543541 }
544542
545543 if shmVolume != nil && * shmVolume {
@@ -854,7 +852,7 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
854852 sidecarContainers []v1.Container
855853 podTemplate * v1.PodTemplateSpec
856854 volumeClaimTemplate * v1.PersistentVolumeClaim
857- volumes []v1. Volume
855+ additionalVolumes = spec . AdditionalVolumes
858856 )
859857
860858 // Improve me. Please.
@@ -1007,8 +1005,10 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
10071005 // this is combined with the FSGroup in the section above
10081006 // to give read access to the postgres user
10091007 defaultMode := int32 (0640 )
1010- volumes = append (volumes , v1.Volume {
1011- Name : "tls-secret" ,
1008+ mountPath := "/tls"
1009+ additionalVolumes = append (additionalVolumes , acidv1.AdditionalVolume {
1010+ Name : spec .TLS .SecretName ,
1011+ MountPath : mountPath ,
10121012 VolumeSource : v1.VolumeSource {
10131013 Secret : & v1.SecretVolumeSource {
10141014 SecretName : spec .TLS .SecretName ,
@@ -1017,13 +1017,6 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
10171017 },
10181018 })
10191019
1020- mountPath := "/tls"
1021- volumeMounts = append (volumeMounts , v1.VolumeMount {
1022- MountPath : mountPath ,
1023- Name : "tls-secret" ,
1024- ReadOnly : true ,
1025- })
1026-
10271020 // use the same filenames as Secret resources by default
10281021 certFile := ensurePath (spec .TLS .CertificateFile , mountPath , "tls.crt" )
10291022 privateKeyFile := ensurePath (spec .TLS .PrivateKeyFile , mountPath , "tls.key" )
@@ -1034,11 +1027,31 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
10341027 )
10351028
10361029 if spec .TLS .CAFile != "" {
1037- caFile := ensurePath (spec .TLS .CAFile , mountPath , "" )
1030+ // support scenario when the ca.crt resides in a different secret, diff path
1031+ mountPathCA := mountPath
1032+ if spec .TLS .CASecretName != "" {
1033+ mountPathCA = mountPath + "ca"
1034+ }
1035+
1036+ caFile := ensurePath (spec .TLS .CAFile , mountPathCA , "" )
10381037 spiloEnvVars = append (
10391038 spiloEnvVars ,
10401039 v1.EnvVar {Name : "SSL_CA_FILE" , Value : caFile },
10411040 )
1041+
1042+ // the ca file from CASecretName secret takes priority
1043+ if spec .TLS .CASecretName != "" {
1044+ additionalVolumes = append (additionalVolumes , acidv1.AdditionalVolume {
1045+ Name : spec .TLS .CASecretName ,
1046+ MountPath : mountPathCA ,
1047+ VolumeSource : v1.VolumeSource {
1048+ Secret : & v1.SecretVolumeSource {
1049+ SecretName : spec .TLS .CASecretName ,
1050+ DefaultMode : & defaultMode ,
1051+ },
1052+ },
1053+ })
1054+ }
10421055 }
10431056 }
10441057
@@ -1108,8 +1121,7 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
11081121 c .OpConfig .PodAntiAffinityTopologyKey ,
11091122 c .OpConfig .AdditionalSecretMount ,
11101123 c .OpConfig .AdditionalSecretMountPath ,
1111- volumes ,
1112- spec .AdditionalVolumes )
1124+ additionalVolumes )
11131125
11141126 if err != nil {
11151127 return nil , fmt .Errorf ("could not generate pod template: %v" , err )
@@ -1614,11 +1626,11 @@ func (c *Cluster) generateCloneEnvironment(description *acidv1.CloneDescription)
16141626 c .logger .Info (msg , description .S3WalPath )
16151627
16161628 envs := []v1.EnvVar {
1617- v1. EnvVar {
1629+ {
16181630 Name : "CLONE_WAL_S3_BUCKET" ,
16191631 Value : c .OpConfig .WALES3Bucket ,
16201632 },
1621- v1. EnvVar {
1633+ {
16221634 Name : "CLONE_WAL_BUCKET_SCOPE_SUFFIX" ,
16231635 Value : getBucketScopeSuffix (description .UID ),
16241636 },
@@ -1790,7 +1802,6 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1beta1.CronJob, error) {
17901802 "" ,
17911803 c .OpConfig .AdditionalSecretMount ,
17921804 c .OpConfig .AdditionalSecretMountPath ,
1793- nil ,
17941805 []acidv1.AdditionalVolume {}); err != nil {
17951806 return nil , fmt .Errorf ("could not generate pod template for logical backup pod: %v" , err )
17961807 }
0 commit comments