Documentation ¶
Index ¶
- Constants
- func AddConfigToInstancePod(cluster *v1beta1.PostgresCluster, pod *corev1.PodSpec)
- func AddConfigToRepoPod(cluster *v1beta1.PostgresCluster, pod *corev1.PodSpec)
- func AddConfigToRestorePod(cluster *v1beta1.PostgresCluster, sourceCluster *v1beta1.PostgresCluster, ...)
- func AddRepoVolumesToPod(postgresCluster *v1beta1.PostgresCluster, template *corev1.PodTemplateSpec, ...) error
- func AddServerToInstancePod(cluster *v1beta1.PostgresCluster, pod *corev1.PodSpec, ...)
- func AddServerToRepoPod(cluster *v1beta1.PostgresCluster, pod *corev1.PodSpec)
- func CalculateConfigHashes(postgresCluster *v1beta1.PostgresCluster) (map[string]string, string, error)
- func CreatePGBackRestConfigMapIntent(postgresCluster *v1beta1.PostgresCluster, ...) *corev1.ConfigMap
- func DedicatedRepoHostEnabled(postgresCluster *v1beta1.PostgresCluster) bool
- func InstanceCertificates(ctx context.Context, inCluster *v1beta1.PostgresCluster, ...) error
- func MakePGBackrestLogDir(template *corev1.PodTemplateSpec, cluster *v1beta1.PostgresCluster)
- func Permissions(cluster *v1beta1.PostgresCluster) []rbacv1.PolicyRule
- func PostgreSQL(inCluster *v1beta1.PostgresCluster, outParameters *postgres.Parameters)
- func ReplicaCreateCommand(cluster *v1beta1.PostgresCluster, instance *v1beta1.PostgresInstanceSetSpec) []string
- func RepoVolumeMount() corev1.VolumeMount
- func RestoreCommand(pgdata string, args ...string) []string
- func RestoreConfig(sourceConfigMap, targetConfigMap *corev1.ConfigMap, ...)
- func Secret(ctx context.Context, inCluster *v1beta1.PostgresCluster, ...) error
- type Executor
Constants ¶
const ( // DefaultStanzaName is the name of the default pgBackRest stanza DefaultStanzaName = "db" // CMInstanceKey is the name of the pgBackRest configuration file for a PostgreSQL instance CMInstanceKey = "pgbackrest_instance.conf" // CMRepoKey is the name of the pgBackRest configuration file for a pgBackRest dedicated // repository host CMRepoKey = "pgbackrest_repo.conf" // ConfigHashKey is the name of the file storing the pgBackRest config hash ConfigHashKey = "config-hash" )
Variables ¶
This section is empty.
Functions ¶
func AddConfigToInstancePod ¶
func AddConfigToInstancePod( cluster *v1beta1.PostgresCluster, pod *corev1.PodSpec, )
AddConfigToInstancePod adds and mounts the pgBackRest configuration volumes for an instance of cluster to pod. The database container and any pgBackRest containers must already be in pod.
func AddConfigToRepoPod ¶
func AddConfigToRepoPod( cluster *v1beta1.PostgresCluster, pod *corev1.PodSpec, )
AddConfigToRepoPod adds and mounts the pgBackRest configuration volume for the dedicated repository host of cluster to pod. The pgBackRest containers must already be in pod.
func AddConfigToRestorePod ¶
func AddConfigToRestorePod( cluster *v1beta1.PostgresCluster, sourceCluster *v1beta1.PostgresCluster, pod *corev1.PodSpec, )
AddConfigToRestorePod adds and mounts the pgBackRest configuration volume for the restore job of cluster to pod. The pgBackRest containers must already be in pod.
func AddRepoVolumesToPod ¶
func AddRepoVolumesToPod(postgresCluster *v1beta1.PostgresCluster, template *corev1.PodTemplateSpec, repoPVCNames map[string]string, containerNames ...string) error
AddRepoVolumesToPod adds pgBackRest repository volumes to the provided Pod template spec, while also adding associated volume mounts to the containers specified.
func AddServerToInstancePod ¶
func AddServerToInstancePod( cluster *v1beta1.PostgresCluster, pod *corev1.PodSpec, instanceCertificateSecretName string, )
AddServerToInstancePod adds the TLS server container and volume to pod for an instance of cluster. Any PostgreSQL volumes must already be in pod.
func AddServerToRepoPod ¶
func AddServerToRepoPod( cluster *v1beta1.PostgresCluster, pod *corev1.PodSpec, )
AddServerToRepoPod adds the TLS server container and volume to pod for the dedicated repository host of cluster.
func CalculateConfigHashes ¶
func CalculateConfigHashes( postgresCluster *v1beta1.PostgresCluster) (map[string]string, string, error)
CalculateConfigHashes calculates hashes for any external pgBackRest repository configuration present in the PostgresCluster spec (e.g. configuration for Azure, GCR and/or S3 repositories). Additionally it returns a hash of the hashes for each external repository.
func CreatePGBackRestConfigMapIntent ¶
func CreatePGBackRestConfigMapIntent(postgresCluster *v1beta1.PostgresCluster, repoHostName, configHash, serviceName, serviceNamespace string, instanceNames []string) *corev1.ConfigMap
CreatePGBackRestConfigMapIntent creates a configmap struct with pgBackRest pgbackrest.conf settings in the data field. The keys within the data field correspond to the use of that configuration. pgbackrest_job.conf is used by certain jobs, such as stanza create and backup pgbackrest_primary.conf is used by the primary database pod pgbackrest_repo.conf is used by the pgBackRest repository pod
func DedicatedRepoHostEnabled ¶
func DedicatedRepoHostEnabled(postgresCluster *v1beta1.PostgresCluster) bool
DedicatedRepoHostEnabled determines whether not a pgBackRest dedicated repository host is enabled according to the provided PostgresCluster
func InstanceCertificates ¶
func InstanceCertificates(ctx context.Context, inCluster *v1beta1.PostgresCluster, inRoot pki.Certificate, inDNS pki.Certificate, inDNSKey pki.PrivateKey, outInstanceCertificates *corev1.Secret, ) error
InstanceCertificates populates the shared Secret with certificates needed to run pgBackRest.
func MakePGBackrestLogDir ¶
func MakePGBackrestLogDir(template *corev1.PodTemplateSpec, cluster *v1beta1.PostgresCluster)
MakePGBackrestLogDir creates the pgBackRest default log path directory used when a dedicated repo host is configured.
func Permissions ¶
func Permissions(cluster *v1beta1.PostgresCluster) []rbacv1.PolicyRule
Permissions returns the RBAC rules pgBackRest needs for a cluster.
func PostgreSQL ¶
func PostgreSQL( inCluster *v1beta1.PostgresCluster, outParameters *postgres.Parameters, )
PostgreSQL populates outParameters with any settings needed to run pgBackRest.
func ReplicaCreateCommand ¶
func ReplicaCreateCommand( cluster *v1beta1.PostgresCluster, instance *v1beta1.PostgresInstanceSetSpec, ) []string
ReplicaCreateCommand returns the command that can initialize the PostgreSQL data directory on an instance from one of cluster's repositories. It returns nil when no repository is available.
func RepoVolumeMount ¶
func RepoVolumeMount() corev1.VolumeMount
RepoVolumeMount returns the name and mount path of the pgBackRest repo volume.
func RestoreCommand ¶
RestoreCommand returns the command for performing a pgBackRest restore. In addition to calling the pgBackRest restore command with any pgBackRest options provided, the script also does the following:
- Removes the patroni.dynamic.json file if present. This ensures the configuration from the cluster being restored from is not utilized when bootstrapping a new cluster, and the configuration for the new cluster is utilized instead.
- Starts the database and allows recovery to complete. A temporary postgresql.conf file with the minimum settings needed to safely start the database is created and utilized.
- Renames the data directory as needed to bootstrap the cluster using the restored database. This ensures compatibility with the "existing" bootstrap method that is included in the Patroni config when bootstrapping a cluster using an existing data directory.
func RestoreConfig ¶
func RestoreConfig( sourceConfigMap, targetConfigMap *corev1.ConfigMap, sourceSecret, targetSecret *corev1.Secret, )
RestoreConfig populates targetConfigMap and targetSecret with values needed to restore a cluster from repositories defined in sourceConfigMap and sourceSecret.
func Secret ¶
func Secret(ctx context.Context, inCluster *v1beta1.PostgresCluster, inRepoHost *appsv1.StatefulSet, inRoot *pki.RootCertificateAuthority, inSecret *corev1.Secret, outSecret *corev1.Secret, ) error
Secret populates the pgBackRest Secret.
Types ¶
type Executor ¶
type Executor func( ctx context.Context, stdin io.Reader, stdout, stderr io.Writer, command ...string, ) error
Executor calls "pgbackrest" commands
func (Executor) StanzaCreateOrUpgrade ¶
func (exec Executor) StanzaCreateOrUpgrade(ctx context.Context, configHash string, upgrade bool) (bool, error)
StanzaCreateOrUpgrade runs either the pgBackRest "stanza-create" or "stanza-upgrade" command depending on the boolean value of the "upgrade" function parameter. This function is invoked by the "reconcileStanzaCreate" function with "upgrade" set to false; if the stanza already exists but the PG version has changed, pgBackRest will error with the "errMsgBackupDbMismatch" error. If that occurs, we then rerun the command with "upgrade" set to true. - https://github.com/pgbackrest/pgbackrest/blob/release/2.38/src/command/check/common.c#L154-L156 If the bool returned from this function is true, this indicates that a pgBackRest config hash mismatch was identified that prevented the pgBackRest stanza-create or stanza-upgrade command from running (with a config mismatch indicating that the pgBackRest configuration as stored in the cluster's pgBackRest ConfigMap has not yet propagated to the Pod).