AddConfigToCloudBackupJob adds and mounts the pgBackRest configuration volumes to the backup job for creating a backup to a cloud repo.
( cluster *v1beta1.PostgresCluster, podTemplateSpec *corev1.PodTemplateSpec, )
| 160 | // AddConfigToCloudBackupJob adds and mounts the pgBackRest configuration volumes |
| 161 | // to the backup job for creating a backup to a cloud repo. |
| 162 | func AddConfigToCloudBackupJob( |
| 163 | cluster *v1beta1.PostgresCluster, podTemplateSpec *corev1.PodTemplateSpec, |
| 164 | ) { |
| 165 | configmap := corev1.VolumeProjection{ConfigMap: &corev1.ConfigMapProjection{}} |
| 166 | configmap.ConfigMap.Name = naming.PGBackRestConfig(cluster).Name |
| 167 | configmap.ConfigMap.Items = []corev1.KeyToPath{ |
| 168 | {Key: CMCloudRepoKey, Path: CMCloudRepoKey}, |
| 169 | } |
| 170 | |
| 171 | secret := corev1.VolumeProjection{Secret: &corev1.SecretProjection{}} |
| 172 | secret.Secret.Name = naming.PGBackRestSecret(cluster).Name |
| 173 | secret.Secret.Items = append(secret.Secret.Items, clientCertificates()...) |
| 174 | |
| 175 | // Start with a copy of projections specified in the cluster. Items later in |
| 176 | // the list take precedence over earlier items (that is, last write wins). |
| 177 | // - https://kubernetes.io/docs/concepts/storage/volumes/#projected |
| 178 | sources := append([]corev1.VolumeProjection{}, |
| 179 | cluster.Spec.Backups.PGBackRest.Configuration...) |
| 180 | |
| 181 | addConfigVolumeAndMounts(&podTemplateSpec.Spec, append(sources, configmap, secret)) |
| 182 | |
| 183 | // Add tmp directory for pgbackrest lock files |
| 184 | AddTMPEmptyDir(podTemplateSpec) |
| 185 | } |
| 186 | |
| 187 | // AddConfigToRestorePod adds and mounts the pgBackRest configuration volume |
| 188 | // for the restore job of cluster to pod. The pgBackRest containers must |