Documentation ¶
Overview ¶
Package cluster holds the cluster CRD logic and definitions A cluster is comprised of a primary service, replica service, primary deployment, and replica deployment
Package cluster holds the cluster CRD logic and definitions A cluster is comprised of a primary service, replica service, primary deployment, and replica deployment
Package cluster holds the cluster CRD logic and definitions A cluster is comprised of a primary service, replica service, primary deployment, and replica deployment
Package cluster holds the cluster CRD logic and definitions A cluster is comprised of a primary service, replica service, primary deployment, and replica deployment
Package cluster holds the cluster CRD logic and definitions A cluster is comprised of a primary service, replica service, primary deployment, and replica deployment
Package cluster holds the cluster CRD logic and definitions A cluster is comprised of a primary service, replica service, primary deployment, and replica deployment
Index ¶
- Constants
- Variables
- func AddBootstrapRepo(clientset kubernetes.Interface, cluster *crv1.Pgcluster) (repoCreated bool, err error)
- func AddClusterBase(clientset kubeapi.Interface, cl *crv1.Pgcluster, namespace string)
- func AddClusterBootstrap(clientset kubeapi.Interface, cluster *crv1.Pgcluster) error
- func AddPgAdmin(clientset kubeapi.Interface, restconfig *rest.Config, cluster *crv1.Pgcluster, ...) error
- func AddPgAdminFromPgTask(clientset kubeapi.Interface, restconfig *rest.Config, task *crv1.Pgtask)
- func AddPgbouncer(clientset kubernetes.Interface, restconfig *rest.Config, ...) error
- func AddUpgrade(clientset kubeapi.Interface, upgrade *crv1.Pgtask, namespace string)
- func BootstrapPgAdminUsers(clientset kubernetes.Interface, restconfig *rest.Config, ...) error
- func Clone(clientset kubeapi.Interface, restConfig *rest.Config, namespace string, ...)
- func CreateRmdataJob(clientset kubernetes.Interface, cl *crv1.Pgcluster, namespace string, ...) error
- func CreateService(clientset kubernetes.Interface, fields *ServiceTemplateFields, ...) error
- func DeleteCluster(clientset kubernetes.Interface, cl *crv1.Pgcluster, namespace string) error
- func DeleteClusterBase(clientset kubernetes.Interface, cl *crv1.Pgcluster, namespace string)
- func DeletePgAdmin(clientset kubeapi.Interface, restconfig *rest.Config, cluster *crv1.Pgcluster) error
- func DeletePgAdminFromPgTask(clientset kubeapi.Interface, restconfig *rest.Config, task *crv1.Pgtask)
- func DeletePgbouncer(clientset kubernetes.Interface, restconfig *rest.Config, ...) error
- func DeleteReplica(clientset kubernetes.Interface, cl *crv1.Pgreplica, namespace string) error
- func DisableStandby(clientset kubernetes.Interface, cluster crv1.Pgcluster) error
- func EnableStandby(clientset kubernetes.Interface, cluster crv1.Pgcluster) error
- func Failover(identifier string, clientset kubeapi.Interface, clusterName string, ...) error
- func FailoverBase(namespace string, clientset kubeapi.Interface, task *crv1.Pgtask, ...)
- func PatchpgtaskFailoverStatus(clientset pgo.Interface, oldCrd *crv1.Pgtask, namespace string) error
- func PublishCloneEvent(eventType string, namespace string, task *crv1.Pgtask, errorMessage string)
- func PublishUpgradeEvent(eventType string, namespace string, task *crv1.Pgtask, errorMessage string)
- func RemovePrimaryOnRoleChangeTag(clientset kubernetes.Interface, restconfig *rest.Config, ...) error
- func RotatePgBouncerPassword(clientset kubernetes.Interface, restconfig *rest.Config, ...) error
- func ScaleBase(clientset kubeapi.Interface, replica *crv1.Pgreplica, namespace string)
- func ScaleDownBase(clientset kubeapi.Interface, replica *crv1.Pgreplica, namespace string)
- func SetReplicaNumber(pgcluster *crv1.Pgcluster, numReplicas string)
- func ShutdownCluster(clientset kubeapi.Interface, cluster crv1.Pgcluster) error
- func StartupCluster(clientset kubernetes.Interface, cluster crv1.Pgcluster) error
- func UninstallPgBouncer(clientset kubernetes.Interface, restconfig *rest.Config, ...) error
- func UpdateAnnotations(clientset kubernetes.Interface, restConfig *rest.Config, ...) error
- func UpdateCloneWorkflow(clientset pgo.Interface, namespace, workflowID, status string) error
- func UpdatePgBouncerAnnotations(clientset kubernetes.Interface, cluster *crv1.Pgcluster, ...) error
- func UpdatePgbouncer(clientset kubernetes.Interface, oldCluster, newCluster *crv1.Pgcluster) error
- func UpdateResources(clientset kubernetes.Interface, restConfig *rest.Config, ...) error
- func UpdateTablespaces(clientset kubernetes.Interface, restConfig *rest.Config, ...) error
- type PgbouncerConfFields
- type PgbouncerPasswdFields
- type RmdataJob
- type ScaleClusterInfo
- type ServiceTemplateFields
Constants ¶
const ReplicaSuffix = "-replica"
ReplicaSuffix ...
Variables ¶
var ( // ErrStandbyNotAllowed contains the error message returned when an API call is not // permitted because it involves a cluster that is in standby mode ErrStandbyNotAllowed = errors.New("Action not permitted because standby mode is enabled") // ErrStandbyNotEnabled defines the error that is thrown when // standby mode is not enabled but a standby action was attempted ErrStandbyNotEnabled = errors.New("Standby mode not enabled") // ErrClusterNotShutdown defines the error that is thrown when an action cannot // proceed because the cluster is not in standby mode ErrClusterNotShutdown = errors.New("Cluster not in shutdown status") )
Functions ¶
func AddBootstrapRepo ¶
func AddBootstrapRepo(clientset kubernetes.Interface, cluster *crv1.Pgcluster) (repoCreated bool, err error)
AddBootstrapRepo creates a pgBackRest repository and associated service to use when bootstrapping a cluster from an existing data source. If an existing repo is detected and is being used to bootstrap another cluster, then an error is returned. If an existing repo is detected and is not associated with a bootstrap job (but rather an active cluster), then no action is taken and the function resturns. Also, in addition to returning an error in the event an error is encountered, the function also returns a 'repoCreated' bool that specifies whether or not a repo was actually created.
func AddClusterBase ¶
func AddClusterBootstrap ¶
AddClusterBootstrap creates the resources needed to bootstrap a new cluster from an existing data source. Specifically, this function creates the bootstrap job that will be run to bootstrap the cluster, along with supporting resources (e.g. ConfigMaps and volumes).
func AddPgAdmin ¶
func AddPgAdmin( clientset kubeapi.Interface, restconfig *rest.Config, cluster *crv1.Pgcluster, storageClass *crv1.PgStorageSpec) error
AddPgAdmin contains the various functions that are used to add a pgAdmin Deployment to a PostgreSQL cluster
Any returned error is logged in the calling function
func AddPgAdminFromPgTask ¶
AddPgAdminFromPgTask is a method that helps to bring up the pgAdmin deployment that sits alongside a PostgreSQL cluster
func AddPgbouncer ¶
func AddPgbouncer(clientset kubernetes.Interface, restconfig *rest.Config, cluster *crv1.Pgcluster) error
AddPgbouncer contains the various functions that are used to add a pgBouncer Deployment to a PostgreSQL cluster
Any returned error is logged in the calling function
func AddUpgrade ¶
AddUpgrade implements the upgrade workflow in accordance with the received pgtask the general process is outlined below: 1) get the existing pgcluster CRD instance that matches the name provided in the pgtask 2) Patch the existing services 3) Determine the current Primary PVC 4) Scale down existing replicas and store the number for recreation 5) Delete the various resources that will need to be recreated 6) Recreate the BackrestRepo secret, since the key encryption algorithm has been updated 7) Update the existing pgcluster CRD instance to match the current version 8) Submit the pgcluster CRD for recreation
func BootstrapPgAdminUsers ¶
func Clone ¶
func Clone(clientset kubeapi.Interface, restConfig *rest.Config, namespace string, task *crv1.Pgtask)
Clone allows for one to clone the data from an existing cluster to a new cluster in the Operator. It works by doing the following:
1. Create some PVCs that will be utilized by the new cluster 2. Syncing (i.e. using rsync) the pgBackRest repository from the old cluster to the new cluster 3. perform a pgBackRest delta restore to the new PVC 4. Create a new cluster by using the old cluster as a template and providing the specifications to the new cluster, with a few "opinionated" items (e.g. copying over the secrets)
func CreateRmdataJob ¶
func CreateService ¶
func CreateService(clientset kubernetes.Interface, fields *ServiceTemplateFields, namespace string) error
CreateService ...
func DeleteCluster ¶
DeleteCluster ...
func DeleteClusterBase ¶
func DeleteClusterBase(clientset kubernetes.Interface, cl *crv1.Pgcluster, namespace string)
DeleteClusterBase ...
func DeletePgAdmin ¶
func DeletePgAdmin(clientset kubeapi.Interface, restconfig *rest.Config, cluster *crv1.Pgcluster) error
DeletePgAdmin contains the various functions that are used to delete a pgAdmin Deployment for a PostgreSQL cluster
Any errors that are returned should be logged in the calling function, though some logging occurs in this function as well
func DeletePgAdminFromPgTask ¶
func DeletePgAdminFromPgTask(clientset kubeapi.Interface, restconfig *rest.Config, task *crv1.Pgtask)
DeletePgAdminFromPgTask is effectively a legacy method that helps to delete the pgAdmin deployment that sits alongside a PostgreSQL cluster
func DeletePgbouncer ¶
func DeletePgbouncer(clientset kubernetes.Interface, restconfig *rest.Config, cluster *crv1.Pgcluster) error
DeletePgbouncer contains the various functions that are used to delete a pgBouncer Deployment for a PostgreSQL cluster
Note that "uninstall" deletes all of the objects that are added to the PostgreSQL database, such as the "pgbouncer" user. This is not normally neded to be done as pgbouncer user is disabled, but if the user wishes to be thorough they can do this
Any errors that are returned should be logged in the calling function, though some logging occurs in this function as well
func DeleteReplica ¶
DeleteReplica ...
func DisableStandby ¶
func DisableStandby(clientset kubernetes.Interface, cluster crv1.Pgcluster) error
DisableStandby disables standby mode for the cluster
func EnableStandby ¶
func EnableStandby(clientset kubernetes.Interface, cluster crv1.Pgcluster) error
EnableStandby enables standby mode for the cluster
func FailoverBase ¶
func FailoverBase(namespace string, clientset kubeapi.Interface, task *crv1.Pgtask, restconfig *rest.Config)
FailoverBase ... gets called first on a failover
func PublishCloneEvent ¶
PublishCloneEvent lets one publish an event related to the clone process
func PublishUpgradeEvent ¶
func PublishUpgradeEvent(eventType string, namespace string, task *crv1.Pgtask, errorMessage string)
PublishUpgradeEvent lets one publish an event related to the upgrade process
func RemovePrimaryOnRoleChangeTag ¶
func RemovePrimaryOnRoleChangeTag(clientset kubernetes.Interface, restconfig *rest.Config, clusterName, namespace string) error
RemovePrimaryOnRoleChangeTag sets the 'primary_on_role_change' tag to null in the Patroni DCS, effectively removing the tag. This is accomplished by exec'ing into the primary PG pod, and sending a patch request to update the appropriate data (i.e. the 'primary_on_role_change' tag) in the DCS.
func RotatePgBouncerPassword ¶
func RotatePgBouncerPassword(clientset kubernetes.Interface, restconfig *rest.Config, cluster *crv1.Pgcluster) error
RotatePgBouncerPassword rotates the password for a pgBouncer PostgreSQL user, which involves updating the password in the PostgreSQL cluster as well as the users secret that is available in the pgbouncer Pod
func ScaleDownBase ¶
ScaleDownBase ...
func SetReplicaNumber ¶
SetReplicaNumber sets the pgcluster's replica value based off of the number of pgreplicas discovered during the deletion process. This is necessary because the pgcluser will only include the number of replicas created when the pgcluster was first generated (e.g. pgo create cluster hippo --replica-count=2) but will not included any replicas created using the 'pgo scale' command
func ShutdownCluster ¶
ShutdownCluster is responsible for shutting down a cluster that is currently running. This includes changing the replica count for all clusters to 0, and then updating the pgcluster with a shutdown status.
func StartupCluster ¶
func StartupCluster(clientset kubernetes.Interface, cluster crv1.Pgcluster) error
StartupCluster is responsible for starting a cluster that was previsouly shutdown. This includes changing the replica count for all clusters to 1, and then updating the pgcluster with a shutdown status.
func UninstallPgBouncer ¶
func UninstallPgBouncer(clientset kubernetes.Interface, restconfig *rest.Config, cluster *crv1.Pgcluster) error
UninstallPgBouncer uninstalls the "pgbouncer" user and other management objects from the PostgreSQL cluster
func UpdateAnnotations ¶
func UpdateAnnotations(clientset kubernetes.Interface, restConfig *rest.Config, cluster *crv1.Pgcluster, annotations map[string]string) error
UpdateAnnotations updates the annotations in the "template" portion of a PostgreSQL deployment
func UpdateCloneWorkflow ¶
UpdateCloneWorkflow updates a Workflow with the current state of the clone task
func UpdatePgBouncerAnnotations ¶
func UpdatePgBouncerAnnotations(clientset kubernetes.Interface, cluster *crv1.Pgcluster, annotations map[string]string) error
UpdatePgBouncerAnnotations updates the annotations in the "template" portion of a pgBouncer deployment
func UpdatePgbouncer ¶
func UpdatePgbouncer(clientset kubernetes.Interface, oldCluster, newCluster *crv1.Pgcluster) error
UpdatePgbouncer contains the various functions that are used to perform updates to the pgBouncer deployment for a cluster, such as rotating a password
Any errors that are returned should be logged in the calling function, though some logging occurs in this function as well
func UpdateResources ¶
func UpdateResources(clientset kubernetes.Interface, restConfig *rest.Config, cluster *crv1.Pgcluster) error
UpdateResources updates the PostgreSQL instance Deployments to reflect the update resources (i.e. CPU, memory)
func UpdateTablespaces ¶
func UpdateTablespaces(clientset kubernetes.Interface, restConfig *rest.Config, cluster *crv1.Pgcluster, newTablespaces map[string]crv1.PgStorageSpec) error
UpdateTablespaces updates the PostgreSQL instance Deployments to update what tablespaces are mounted. Though any new tablespaces are present in the CRD, to attempt to do less work this function takes a map of the new tablespaces that are being added, so we only have to check and create the PVCs that are being mounted at this time
To do this, iterate through the tablespace mount map that is present in the new cluster.
Types ¶
type PgbouncerConfFields ¶
type PgbouncerPasswdFields ¶
type ScaleClusterInfo ¶
type ScaleClusterInfo struct { PrimaryDeployment string ReplicaDeployments []string PGBackRestRepoDeployment string PGBouncerDeployment string }
ScaleClusterInfo contains information about a cluster obtained when scaling the various deployments for a cluster. This includes the name of the primary deployment, all replica deployments, along with the names of the services enabled for the cluster.
func ScaleClusterDeployments ¶
func ScaleClusterDeployments(clientset kubernetes.Interface, cluster crv1.Pgcluster, replicas int, scalePrimary, scaleReplicas, scaleBackRestRepo, scalePGBouncer bool) (clusterInfo ScaleClusterInfo, err error)
ScaleClusterDeployments scales all deployments for a cluster to the number of replicas specified using the 'replicas' parameter. This is typically used to scale-up or down the primary deployment and any supporting services (pgBackRest and pgBouncer) when shutting down or starting up the cluster due to a scale or scale-down request.