@@ -674,6 +674,7 @@ func (c *Cluster) generatePodTemplate(
674674 spiloContainer * v1.Container ,
675675 initContainers []v1.Container ,
676676 sidecarContainers []v1.Container ,
677+ sharePGSocketWithSidecars * bool ,
677678 tolerationsSpec * []v1.Toleration ,
678679 spiloRunAsUser * int64 ,
679680 spiloRunAsGroup * int64 ,
@@ -736,6 +737,10 @@ func (c *Cluster) generatePodTemplate(
736737 podSpec .PriorityClassName = priorityClassName
737738 }
738739
740+ if sharePGSocketWithSidecars != nil && * sharePGSocketWithSidecars {
741+ addVarRunVolume (& podSpec )
742+ }
743+
739744 if additionalSecretMount != "" {
740745 addSecretVolume (& podSpec , additionalSecretMount , additionalSecretMountPath )
741746 }
@@ -1317,6 +1322,7 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
13171322 spiloContainer ,
13181323 initContainers ,
13191324 sidecarContainers ,
1325+ c .OpConfig .SharePGSocketWithSidecars ,
13201326 & tolerationSpec ,
13211327 effectiveRunAsUser ,
13221328 effectiveRunAsGroup ,
@@ -1502,6 +1508,28 @@ func addShmVolume(podSpec *v1.PodSpec) {
15021508 podSpec .Volumes = volumes
15031509}
15041510
1511+ func addVarRunVolume (podSpec * v1.PodSpec ) {
1512+ volumes := append (podSpec .Volumes , v1.Volume {
1513+ Name : "postgresql-run" ,
1514+ VolumeSource : v1.VolumeSource {
1515+ EmptyDir : & v1.EmptyDirVolumeSource {
1516+ Medium : "Memory" ,
1517+ },
1518+ },
1519+ })
1520+
1521+ for i := range podSpec .Containers {
1522+ mounts := append (podSpec .Containers [i ].VolumeMounts ,
1523+ v1.VolumeMount {
1524+ Name : "postgresql-run" ,
1525+ MountPath : "/var/run/postgresql" ,
1526+ })
1527+ podSpec .Containers [i ].VolumeMounts = mounts
1528+ }
1529+
1530+ podSpec .Volumes = volumes
1531+ }
1532+
15051533func addSecretVolume (podSpec * v1.PodSpec , additionalSecretMount string , additionalSecretMountPath string ) {
15061534 volumes := append (podSpec .Volumes , v1.Volume {
15071535 Name : additionalSecretMount ,
@@ -2037,6 +2065,7 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1beta1.CronJob, error) {
20372065 logicalBackupContainer ,
20382066 []v1.Container {},
20392067 []v1.Container {},
2068+ util .False (),
20402069 & []v1.Toleration {},
20412070 nil ,
20422071 nil ,
0 commit comments