AddConfigToRepoPod adds and mounts the pgBackRest configuration volumes for the dedicated repository host of cluster to pod. The pgBackRest containers must already be in pod.
( cluster *v1beta1.PostgresCluster, pod *corev1.PodSpec, )
| 134 | // the dedicated repository host of cluster to pod. The pgBackRest containers |
| 135 | // must already be in pod. |
| 136 | func AddConfigToRepoPod( |
| 137 | cluster *v1beta1.PostgresCluster, pod *corev1.PodSpec, |
| 138 | ) { |
| 139 | configmap := corev1.VolumeProjection{ConfigMap: &corev1.ConfigMapProjection{}} |
| 140 | configmap.ConfigMap.Name = naming.PGBackRestConfig(cluster).Name |
| 141 | configmap.ConfigMap.Items = []corev1.KeyToPath{ |
| 142 | {Key: CMRepoKey, Path: CMRepoKey}, |
| 143 | {Key: ConfigHashKey, Path: ConfigHashKey}, |
| 144 | {Key: serverConfigMapKey, Path: serverConfigProjectionPath}, |
| 145 | } |
| 146 | |
| 147 | secret := corev1.VolumeProjection{Secret: &corev1.SecretProjection{}} |
| 148 | secret.Secret.Name = naming.PGBackRestSecret(cluster).Name |
| 149 | secret.Secret.Items = append(secret.Secret.Items, clientCertificates()...) |
| 150 | |
| 151 | // Start with a copy of projections specified in the cluster. Items later in |
| 152 | // the list take precedence over earlier items (that is, last write wins). |
| 153 | // - https://kubernetes.io/docs/concepts/storage/volumes/#projected |
| 154 | sources := append([]corev1.VolumeProjection{}, |
| 155 | cluster.Spec.Backups.PGBackRest.Configuration...) |
| 156 | |
| 157 | addConfigVolumeAndMounts(pod, append(sources, configmap, secret)) |
| 158 | } |
| 159 | |
| 160 | // AddConfigToCloudBackupJob adds and mounts the pgBackRest configuration volumes |
| 161 | // to the backup job for creating a backup to a cloud repo. |