postgrescluster

package
v0.0.0-...-43879ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2025 License: Apache-2.0 Imports: 77 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConditionPostgresDataInitialized is the type used in a condition to indicate whether or not the
	// PostgresCluster's PostgreSQL data directory has been initialized (e.g. via a restore)
	ConditionPostgresDataInitialized = "PostgresDataInitialized"

	// ConditionManualBackupSuccessful is the type used in a condition to indicate whether or not
	// the manual backup for the current backup ID (as provided via annotation) was successful
	ConditionManualBackupSuccessful = "PGBackRestManualBackupSuccessful"

	// ConditionReplicaCreate is the type used in a condition to indicate whether or not
	// pgBackRest can be utilized for replica creation
	ConditionReplicaCreate = "PGBackRestReplicaCreate"

	// ConditionReplicaRepoReady is the type used in a condition to indicate whether or not
	// the pgBackRest repository for creating replicas is ready
	ConditionReplicaRepoReady = "PGBackRestReplicaRepoReady"

	// ConditionRepoHostReady is the type used in a condition to indicate whether or not a
	// pgBackRest repository host PostgresCluster is ready
	ConditionRepoHostReady = "PGBackRestRepoHostReady"

	// ConditionPGBackRestRestoreProgressing is the type used in a condition to indicate that
	// and in-place pgBackRest restore is in progress
	ConditionPGBackRestRestoreProgressing = "PGBackRestoreProgressing"

	// EventRepoHostNotFound is used to indicate that a pgBackRest repository was not
	// found when reconciling
	EventRepoHostNotFound = "RepoDeploymentNotFound"

	// EventRepoHostCreated is the event reason utilized when a pgBackRest repository host is
	// created
	EventRepoHostCreated = "RepoHostCreated"

	// EventUnableToCreateStanzas is the event reason utilized when pgBackRest is unable to create
	// stanzas for the repositories in a PostgreSQL cluster
	EventUnableToCreateStanzas = "UnableToCreateStanzas"

	// EventStanzasCreated is the event reason utilized when a pgBackRest stanza create command
	// completes successfully
	EventStanzasCreated = "StanzasCreated"

	// EventUnableToCreatePGBackRestCronJob is the event reason utilized when a pgBackRest backup
	// CronJob fails to create successfully
	EventUnableToCreatePGBackRestCronJob = "UnableToCreatePGBackRestCronJob"

	// ReasonReadyForRestore is the reason utilized within ConditionPGBackRestRestoreProgressing
	// to indicate that the restore Job can proceed because the cluster is now ready to be
	// restored (i.e. it has been properly prepared for a restore).
	ReasonReadyForRestore = "ReadyForRestore"
)
View Source
const (
	// K8SPG-422: we need to keep these constants exported
	Full         = "full"
	Differential = "diff"
	Incremental  = "incr"
)

backup types

View Source
const (
	// ControllerName is the name of the PostgresCluster controller
	ControllerName = "postgrescluster-controller"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance struct {
	Name   string
	Pods   []*corev1.Pod
	Runner *appsv1.StatefulSet
	Spec   *v1beta1.PostgresInstanceSetSpec
}

Instance represents a single PostgreSQL instance of a PostgresCluster.

func (Instance) IsAvailable

func (i Instance) IsAvailable() (available bool, known bool)

IsAvailable is used to choose which instances to redeploy during rolling update. It combines information from metadata and status similar to the notion of "available" in corev1.Deployment and "healthy" in appsv1.StatefulSet.

func (Instance) IsPrimary

func (i Instance) IsPrimary() (primary bool, known bool)

IsPrimary returns whether or not this instance is the Patroni leader.

func (Instance) IsReady

func (i Instance) IsReady() (ready bool, known bool)

IsReady returns whether or not this instance is ready to receive PostgreSQL connections.

func (Instance) IsRunning

func (i Instance) IsRunning(container string) (running bool, known bool)

IsRunning returns whether or not container is running.

func (Instance) IsTerminating

func (i Instance) IsTerminating() (terminating bool, known bool)

IsTerminating returns whether or not this instance is in the process of not running.

func (Instance) IsWritable

func (i Instance) IsWritable() (writable, known bool)

IsWritable returns whether or not a PostgreSQL connection could write to its database.

func (Instance) PodMatchesPodTemplate

func (i Instance) PodMatchesPodTemplate() (matches bool, known bool)

PodMatchesPodTemplate returns whether or not the Pod for this instance matches its specified PodTemplate. When it does not match, the Pod needs to be redeployed.

type Reconciler

type Reconciler struct {
	Client          client.Client
	DiscoveryClient *discovery.DiscoveryClient
	IsOpenShift     bool
	Owner           client.FieldOwner
	PodExec         func(
		ctx context.Context, namespace, pod, container string,
		stdin io.Reader, stdout, stderr io.Writer, command ...string,
	) error
	Recorder     record.EventRecorder
	Registration registration.Registration
	Tracer       trace.Tracer
}

Reconciler holds resources for the PostgresCluster reconciler

func (*Reconciler) BackupsEnabled

func (r *Reconciler) BackupsEnabled(
	ctx context.Context,
	postgresCluster *v1beta1.PostgresCluster,
) (
	backupsSpecFound bool,
	backupsReconciliationAllowed bool,
	err error,
)

BackupsEnabled checks the state of the backups (i.e., if backups are in the spec, if a repo-host StatefulSet exists, if the annotation permitting backup deletion exists) and determines whether reconciliation is allowed. Reconciliation of backup-related Kubernetes objects is paused if

  • a user created a cluster with backups;
  • the cluster is updated to remove backups;
  • the annotation authorizing that removal is missing.

This function also returns whether the spec has a defined backups or not.

func (*Reconciler) GroupVersionKindExists

func (r *Reconciler) GroupVersionKindExists(groupVersion, kind string) (*bool, error)

GroupVersionKindExists checks to see whether a given Kind for a given GroupVersion exists in the Kubernetes API Server.

func (*Reconciler) ObserveBackupUniverse

func (r *Reconciler) ObserveBackupUniverse(ctx context.Context,
	postgresCluster *v1beta1.PostgresCluster,
) (
	backupsSpecFound bool,
	repoHostStatefulSetNotFound bool,
	backupsRemovalAnnotationFound bool,
	err error,
)

ObserveBackupUniverse returns

  • whether the spec has backups defined;
  • whether the repo-host statefulset exists;
  • whether the cluster has the annotation authorizing backup removal.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(
	ctx context.Context, request reconcile.Request) (reconcile.Result, error,
)

Reconcile reconciles a ConfigMap in a namespace managed by the PostgreSQL Operator

func (*Reconciler) SetupWithManager

func (r *Reconciler) SetupWithManager(mgr manager.Manager) error

SetupWithManager adds the PostgresCluster controller to the provided runtime manager

type RepoResources

type RepoResources struct {
	// contains filtered or unexported fields
}

RepoResources is used to store various resources for pgBackRest repositories and repository hosts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL