@@ -878,14 +878,12 @@ func (c *Cluster) generatePodTemplate(
878878 addEmptyDirVolume (& podSpec , "exporter-tmp" , "postgres-exporter" , "/tmp" )
879879 }
880880
881- var readOnly bool
882881 if c .OpConfig .ReadOnlyRootFilesystem != nil {
883- readOnly = * c . OpConfig . ReadOnlyRootFilesystem
882+ addRunVolume ( & podSpec , "postgres-run" , "postgres" , "/run" )
884883 }
885884
886- if sharePgSocketWithSidecars != nil && * sharePgSocketWithSidecars || readOnly {
885+ if sharePgSocketWithSidecars != nil && * sharePgSocketWithSidecars {
887886 addVarRunVolume (& podSpec )
888-
889887 }
890888
891889 if additionalSecretMount != "" {
@@ -2231,6 +2229,27 @@ func addEmptyDirVolume(podSpec *v1.PodSpec, volumeName string, containerName str
22312229 }
22322230}
22332231
2232+ func addRunVolume (podSpec * v1.PodSpec , volumeName string , containerName string , path string ) {
2233+ vol := v1.Volume {
2234+ Name : volumeName ,
2235+ VolumeSource : v1.VolumeSource {
2236+ EmptyDir : & v1.EmptyDirVolumeSource {},
2237+ },
2238+ }
2239+ podSpec .Volumes = append (podSpec .Volumes , vol )
2240+
2241+ mount := v1.VolumeMount {
2242+ Name : vol .Name ,
2243+ MountPath : path ,
2244+ }
2245+
2246+ for i := range podSpec .Containers {
2247+ if podSpec .Containers [i ].Name == containerName {
2248+ podSpec .Containers [i ].VolumeMounts = append (podSpec .Containers [i ].VolumeMounts , mount )
2249+ }
2250+ }
2251+ }
2252+
22342253func addVarRunVolume (podSpec * v1.PodSpec ) {
22352254 volumes := append (podSpec .Volumes , v1.Volume {
22362255 Name : "postgresql-run" ,
0 commit comments