MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / CreatePostgresVolumeMounts

Function CreatePostgresVolumeMounts

pkg/specs/volumes.go:238–293  ·  view source on GitHub ↗

CreatePostgresVolumeMounts creates the volume mounts that are used by PostgreSQL Pods

(cluster apiv1.Cluster, extensions []apiv1.ExtensionConfiguration)

Source from the content-addressed store, hash-verified

236// CreatePostgresVolumeMounts creates the volume mounts that are used
237// by PostgreSQL Pods
238func CreatePostgresVolumeMounts(cluster apiv1.Cluster, extensions []apiv1.ExtensionConfiguration) []corev1.VolumeMount {
239 volumeMounts := []corev1.VolumeMount{
240 {
241 Name: pgdataVolumeName,
242 MountPath: "/var/lib/postgresql/data",
243 },
244 {
245 Name: "scratch-data",
246 MountPath: "/run",
247 },
248 {
249 Name: "scratch-data",
250 MountPath: postgres.ScratchDataDirectory,
251 },
252 {
253 Name: "shm",
254 MountPath: "/dev/shm",
255 },
256 }
257
258 if cluster.ShouldCreateWalArchiveVolume() {
259 volumeMounts = append(volumeMounts,
260 corev1.VolumeMount{
261 Name: "pg-wal",
262 MountPath: PgWalVolumePath,
263 },
264 )
265 }
266
267 if cluster.ShouldCreateProjectedVolume() {
268 volumeMounts = append(volumeMounts,
269 corev1.VolumeMount{
270 Name: "projected",
271 MountPath: postgres.ProjectedVolumeDirectory,
272 },
273 )
274 }
275
276 // we should create volumeMounts in fixed sequence as podSpec will store it in annotation and
277 // later it will be retrieved to do deepEquals
278 if cluster.ContainsTablespaces() {
279 tbsNames := getSortedTablespaceList(&cluster)
280 for i := range tbsNames {
281 volumeMounts = append(volumeMounts,
282 corev1.VolumeMount{
283 Name: VolumeMountNameForTablespace(tbsNames[i]),
284 MountPath: MountForTablespace(tbsNames[i]),
285 },
286 )
287 }
288 }
289
290 volumeMounts = append(volumeMounts, CreateExtensionVolumeMounts(extensions)...)
291
292 return volumeMounts
293}
294
295func getSortedTablespaceList(cluster *apiv1.Cluster) []string {

Callers 5

CreatePrimaryJobFunction · 0.85
createPostgresContainersFunction · 0.85
createBootstrapContainerFunction · 0.85
volumes_test.goFile · 0.85

Tested by

no test coverage detected