cluster

package
v4.3.0-beta.1+incompat... Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

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

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

View Source
const ReplicaSuffix = "-replica"

ReplicaSuffix ...

Variables

View Source
var (
	// 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")
	// 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")
)

Functions

func AddCluster

func AddCluster(clientset *kubernetes.Clientset, client *rest.RESTClient, cl *crv1.Pgcluster, namespace string, primaryPVCName string) error

AddCluster ...

func AddClusterBase

func AddClusterBase(clientset *kubernetes.Clientset, client *rest.RESTClient, cl *crv1.Pgcluster, namespace string)

func AddPgbouncer

func AddPgbouncer(clientset *kubernetes.Clientset, restclient *rest.RESTClient, 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 AddPgbouncerFromPgTask

func AddPgbouncerFromPgTask(clientset *kubernetes.Clientset, restclient *rest.RESTClient, restconfig *rest.Config, task *crv1.Pgtask)

AddPgbouncerFromPgTask is effectively a legacy method that helps to bring up the pgBouncer deployment that sits alongside a PostgreSQL cluster

func AddUpgrade

func AddUpgrade(clientset *kubernetes.Clientset, restclient *rest.RESTClient, upgrade *crv1.Pgtask, namespace string)

AddUpgrade implements the upgrade workflow for cluster minor upgrade

func Clone

func Clone(clientset *kubernetes.Clientset, client *rest.RESTClient, 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 CreatePgTaskforAddpgBouncer

func CreatePgTaskforAddpgBouncer(restclient *rest.RESTClient, cluster *crv1.Pgcluster, pgouser string) error

CreatePgTaskforAddpgBouncer creates a pgtask to process adding a pgBouncer

func CreatePgTaskforUpdatepgBouncer

func CreatePgTaskforUpdatepgBouncer(restclient *rest.RESTClient, cluster *crv1.Pgcluster, pgouser string, parameters map[string]string) error

CreatePgTaskforUpdatepgBouncer creates a pgtask to process for updating pgBouncer

The "parameters" attribute contains a list of parameters that can guide what will take place during an update, e.g.

- RotoatePassword="true" will rotate the pgBouncer PostgreSQL user password

func CreateRmdataJob

func CreateRmdataJob(clientset *kubernetes.Clientset, cl *crv1.Pgcluster, namespace string, removeData, removeBackup, isReplica, isBackup bool) error

CreateService ...

func CreateService

func CreateService(clientset *kubernetes.Clientset, fields *ServiceTemplateFields, namespace string) error

CreateService ...

func CreateTablespacePVC

func CreateTablespacePVC(clientset *kubernetes.Clientset, namespace, clusterName, tablespacePVCName string, storageSpec *crv1.PgStorageSpec) error

CreateTablespacePVC creates a PVC for a tablespace, whether its a part of a cluster creation, scale, or other workflows

func DeleteCluster

func DeleteCluster(clientset *kubernetes.Clientset, restclient *rest.RESTClient, cl *crv1.Pgcluster, namespace string) error

DeleteCluster ...

func DeleteClusterBase

func DeleteClusterBase(clientset *kubernetes.Clientset, restclient *rest.RESTClient, cl *crv1.Pgcluster, namespace string)

DeleteClusterBase ...

func DeletePgbouncer

func DeletePgbouncer(clientset *kubernetes.Clientset, restclient *rest.RESTClient, restconfig *rest.Config, cluster *crv1.Pgcluster, uninstall bool) 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 DeletePgbouncerFromPgTask

func DeletePgbouncerFromPgTask(clientset *kubernetes.Clientset, restclient *rest.RESTClient, restconfig *rest.Config, task *crv1.Pgtask)

DeletePgbouncerFromPgTask is effectively a legacy method that helps to delete the pgBouncer deployment that sits alongside a PostgreSQL cluster

func DeletePgreplicas

func DeletePgreplicas(restclient *rest.RESTClient, clusterName, namespace string)

DeletePgreplicas

func DeleteReplica

func DeleteReplica(clientset *kubernetes.Clientset, cl *crv1.Pgreplica, namespace string) error

DeleteReplica ...

func DisableStandby

func DisableStandby(clientset *kubernetes.Clientset, cluster crv1.Pgcluster) error

DisableStandby disables standby mode for the cluster

func EnableStandby

func EnableStandby(clientset *kubernetes.Clientset, cluster crv1.Pgcluster) error

EnableStandby enables standby mode for the cluster

func Failover

func Failover(identifier string, clientset *kubernetes.Clientset, client *rest.RESTClient, clusterName string, task *crv1.Pgtask, namespace string, restconfig *rest.Config) error

func FailoverBase

func FailoverBase(namespace string, clientset *kubernetes.Clientset, client *rest.RESTClient, task *crv1.Pgtask, restconfig *rest.Config)

FailoverBase ... gets called first on a failover

func PatchpgtaskFailoverStatus

func PatchpgtaskFailoverStatus(restclient *rest.RESTClient, oldCrd *crv1.Pgtask, namespace string) error

func ProcessNextUpgradeItem

func ProcessNextUpgradeItem(clientset *kubernetes.Clientset, restclient *rest.RESTClient, cluster crv1.Pgcluster, upgradeTaskName, namespace string)

ProcessNextUpgradeItem - processes the next deployment for a cluster being upgraded One deployment is done per call in the following order: replicas, backrest, primary If more than one replica is in the list, they are done one at a time, once per call with an item getting removed from the list each time. This method should get called after the pod goes ready from the previous item, which is handled by the pod controller.

func PublishCloneEvent

func PublishCloneEvent(eventType string, namespace string, task *crv1.Pgtask, errorMessage string)

PublishCloneEvent lets one publish an event related to the clone process

func RemovePrimaryOnRoleChangeTag

func RemovePrimaryOnRoleChangeTag(clientset *kubernetes.Clientset, 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 Scale

func Scale(clientset *kubernetes.Clientset, client *rest.RESTClient, replica *crv1.Pgreplica, namespace, pvcName string, cluster *crv1.Pgcluster) error

Scale ...

func ScaleBase

func ScaleBase(clientset *kubernetes.Clientset, client *rest.RESTClient, replica *crv1.Pgreplica, namespace string)

ScaleBase ...

func ScaleDownBase

func ScaleDownBase(clientset *kubernetes.Clientset, client *rest.RESTClient, replica *crv1.Pgreplica, namespace string)

ScaleDownBase ...

func ShutdownCluster

func ShutdownCluster(clientset *kubernetes.Clientset, restclient *rest.RESTClient,
	cluster crv1.Pgcluster) error

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.Clientset, 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 UpdateCloneWorkflow

func UpdateCloneWorkflow(client *rest.RESTClient, namespace, workflowID, status string) error

UpdateCloneWorkflow updates a Workflow with the current state of the clone task

func UpdatePgbouncer

func UpdatePgbouncer(clientset *kubernetes.Clientset, restclient *rest.RESTClient, restconfig *rest.Config, cluster *crv1.Pgcluster, parameters map[string]string) 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 UpdatePgbouncerFromPgTask

func UpdatePgbouncerFromPgTask(clientset *kubernetes.Clientset, restclient *rest.RESTClient, restconfig *rest.Config, task *crv1.Pgtask)

UpdatePgbouncerFromPgTask is effectively a legacy method (though modernized to fit this patterh) that checks basic information about the Pgtask that is being present, and delegates the actual work to UpdatePgBouncer

func UpgradeWithAutofailDisabled

func UpgradeWithAutofailDisabled(clientset *kubernetes.Clientset, restclient *rest.RESTClient,
	cluster crv1.Pgcluster, upgradeTaskName, namespace string)

UpgradeWithAutofailDisabled patches the primary and all replicas at the same time, and then immediately mark the upgrade as complete. When performing a minor upgrade with autofail disabled, once the upgrade is complete and new pods have been created for the primary and each replica, any "database" containers will remain in an unready state, i.e. readiness probes will fail for those containers. This is because when autofail is disabled (i.e. Patroni is "paused"), Patroni will not attempt to start the PG database on a primary or replica. Therefore, the user must re-enable autofail following a minor upgrade during which autofail was disabled in order to fully bring the cluster (which includes the primary and all replicas) back online.

func UpgradeWithAutofailEnabled

func UpgradeWithAutofailEnabled(clientset *kubernetes.Clientset, restclient *rest.RESTClient,
	cluster crv1.Pgcluster, upgradeTaskName, namespace string)

UpgradeWithAutofailEnabled is called when a minor upgrade is initiated for a PG cluster that has autofail enabled. Being that all replicas, and then the primary, are patched sequentially for a minor upgrade during which autofail is enabled for the cluster, this function simply calls the ProcessNextUpgradeItem function to trigger the upgrade the first Deployment in the sequence of primary and replica Deployments (ProcessNextUpgradeItem will then be called for any remaining Deployments from the Pod controller).

Types

type CreatePVC

type CreatePVC struct {
	Clientset *kubernetes.Clientset
	// ClusterName is the name of the PostgreSQL cluster to associate with the
	// PVC. Set ClusterName to PVCName if this is being restored to a differnet PVC
	ClusterName string
	Namespace   string
	PVCName     string
	PVCSize     string
	RESTClient  *rest.RESTClient
	Storage     crv1.PgStorageSpec
}

arguments required to create a new PVC

type PgbouncerConfFields

type PgbouncerConfFields struct {
	PG_PRIMARY_SERVICE_NAME string
	PG_PORT                 string
}

type PgbouncerPasswdFields

type PgbouncerPasswdFields struct {
	Username string
	Password string
}

type PgbouncerTemplateFields

type PgbouncerTemplateFields struct {
	Name                      string
	ClusterName               string
	PGBouncerSecret           string
	CCPImagePrefix            string
	CCPImageTag               string
	Port                      string
	PrimaryServiceName        string
	ContainerResources        string
	PodAntiAffinity           string
	PodAntiAffinityLabelName  string
	PodAntiAffinityLabelValue string
}

type RmdataJob

type RmdataJob struct {
	JobName        string
	ClusterName    string
	PGOImagePrefix string
	PGOImageTag    string
	//		SecurityContext string
	RemoveData         string
	RemoveBackup       string
	IsBackup           string
	IsReplica          string
	ContainerResources string
}

type ScaleClusterInfo

type ScaleClusterInfo struct {
	PrimaryDeployment  string
	ReplicaDeployments []string
	Services           []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.Clientset, cluster crv1.Pgcluster, replicas int,
	scalePrimary, scaleReplicas, scaleServices 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.

type ServiceTemplateFields

type ServiceTemplateFields struct {
	Name         string
	ServiceName  string
	ClusterName  string
	Port         string
	PGBadgerPort string
	ExporterPort string
	ServiceType  string
}

ServiceTemplateFields ...

Jump to

Keyboard shortcuts

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