operator

package
v4.3.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PGHAConfigInitSetting determines whether or not initialization logic should be run in the
	// crunchy-postgres-ha (or GIS equivilaent) container
	PGHAConfigInitSetting = "init"
	// PGHAConfigReplicaBootstrapRepoType defines an override for the type of repo (local, S3, etc.)
	// that should be utilized when bootstrapping a replica (i.e. it override the
	// PGBACKREST_REPO_TYPE env var in the environment).  Allows for dynamic changing of the
	// backrest repo type without requiring container restarts (as would be required to update
	// PGBACKREST_REPO_TYPE).
	PGHAConfigReplicaBootstrapRepoType = "replica-bootstrap-repo-type"
)

the following constants define the settings in the PGHA configMap that is created for each PG cluster

View Source
const AFFINITY_NOTINOperator = "NotIn"
View Source
const AffinityInOperator = "In"

consolidate with cluster.affinityTemplateFields

View Source
const PGHAConfigMapSuffix = "pgha-config"

PGHAConfigMapSuffix defines the suffix for the name of the PGHA configMap created for each PG cluster

Variables

View Source
var CRUNCHY_DEBUG bool
View Source
var ContainerImageOverrides = map[string]string{}

ContainerImageOverrides contains a list of container images that are overridden by the RELATED_IMAGE_* environmental variables that can be set by people deploying the Operator

View Source
var EventTCPAddress = "localhost:4150"
View Source
var InstallationName string
View Source
var NAMESPACE string
View Source
var PgoNamespace string

Functions

func AddWALVolumeAndMountsToBackRest

func AddWALVolumeAndMountsToBackRest(podSpec *core_v1.PodSpec, walVolume StorageResult)

AddWALVolumeAndMountsToBackRest modifies a pgBackRest podSpec to include walVolume.

func AddWALVolumeAndMountsToPostgreSQL

func AddWALVolumeAndMountsToPostgreSQL(podSpec *core_v1.PodSpec, walVolume StorageResult, instanceName string)

AddWALVolumeAndMountsToPostgreSQL modifies a PostgreSQL podSpec to include walVolume.

func CreatePGHAConfigMap

func CreatePGHAConfigMap(clientset *kubernetes.Clientset, cluster *crv1.Pgcluster,
	namespace string) error

CreatePGHAConfigMap creates a configMap that will be utilized to store configuration settings for a PostgreSQL cluster. Currently this configMap simply defines an "init" setting, which is utilized by the crunchy-postgres-ha container (or GIS equivalent) to determine whether or not initialization logic should be executed when the container is run. This ensures that the original primary in a PostgreSQL cluster does not attempt to run any initialization logic more than once, such as following a restart of the container. In the future this configMap can also be leveraged to manage other configuration settings for the PostgreSQL cluster and its associated containers.

func GetAffinity

func GetAffinity(nodeLabelKey, nodeLabelValue string, affoperator string) string

GetAffinity ...

func GetBackrestDeployment

func GetBackrestDeployment(clientset *kubernetes.Clientset, cluster *crv1.Pgcluster) (*apps_v1.Deployment, error)

GetBackrestDeployment finds the pgBackRest repository Deployments for a PostgreQL cluster

func GetBadgerAddon

func GetBadgerAddon(clientset *kubernetes.Clientset, namespace string, cluster *crv1.Pgcluster, pgbadger_target string) string

func GetCollectAddon

func GetCollectAddon(clientset *kubernetes.Clientset, namespace string, spec *crv1.PgclusterSpec) string

func GetCollectVolume

func GetCollectVolume(clientset *kubernetes.Clientset, cl *crv1.Pgcluster, namespace string) string

sets the proper collect secret in the deployment spec if collect is enabled

func GetConfVolume

func GetConfVolume(clientset *kubernetes.Clientset, cl *crv1.Pgcluster, namespace string) string

consolidate with cluster.GetConfVolume

func GetInstanceDeployments

func GetInstanceDeployments(clientset *kubernetes.Clientset, cluster *crv1.Pgcluster) (*apps_v1.DeploymentList, error)

GetInstanceDeployments finds the Deployments that represent PostgreSQL instances

func GetLabelsFromMap

func GetLabelsFromMap(labels map[string]string) string

needs to be consolidated with cluster.GetLabelsFromMap GetLabelsFromMap ...

func GetPgbackrestEnvVars

func GetPgbackrestEnvVars(cluster *crv1.Pgcluster, backrestEnabled, depName, port, storageType string) string

consolidate with cluster.GetPgbackrestEnvVars

func GetPgbackrestS3EnvVars

func GetPgbackrestS3EnvVars(cluster crv1.Pgcluster, clientset *kubernetes.Clientset,
	ns string) string

GetPgbackrestS3EnvVars retrieves the values for the various configuration settings require to configure pgBackRest for AWS S3, including a bucket, endpoint, region, key and key secret. The bucket, endpoint & region are obtained from the associated parameters in the pgcluster CR, while the key and key secret are obtained from the backrest repository secret. Once these values have been obtained, they are used to populate a template containing the various pgBackRest environment variables required to enable S3 support. After the template has been executed with the proper values, the result is then returned a string for inclusion in the PG and pgBackRest deployments.

func GetPgmonitorEnvVars

func GetPgmonitorEnvVars(metricsEnabled string) string

func GetPodAntiAffinity

func GetPodAntiAffinity(cluster *crv1.Pgcluster, deploymentType crv1.PodAntiAffinityDeployment, podAntiAffinityType crv1.PodAntiAffinityType) string

GetPodAntiAffinity returns the populated pod anti-affinity json that should be attached to the various pods comprising the pg cluster

func GetPodAntiAffinityType

func GetPodAntiAffinityType(cluster *crv1.Pgcluster, deploymentType crv1.PodAntiAffinityDeployment, podAntiAffinityType crv1.PodAntiAffinityType) crv1.PodAntiAffinityType

GetPodAntiAffinityType returns the type of pod anti-affinity to use. This is based on the deployment type (cluster, pgBackRest, pgBouncer), the value in the cluster spec, and the defaults available in pgo.yaml.

In other words, the pod anti-affinity is determined by this heuristic, in priority order:

  1. If it's pgBackRest/pgBouncer the value set by the user (available in the cluster spec)
  2. If it's pgBackRest/pgBouncer the value set in pgo.yaml
  3. The value set in "Default" in the cluster spec
  4. The value set for PodAntiAffinity in pgo.yaml

func GetRepoType

func GetRepoType(backrestStorageType string) string

GetRepoType returns the proper repo type to set in container based on the backrest storage type provided

func GetResourcesJSON

func GetResourcesJSON(resources v1.ResourceList, enableMemoryLimit bool) string

GetResourcesJSON is a pseudo-legacy method that creates JSON that applies the CPU and Memory settings. The settings are only included if: a) they exist b) they are nonzero

func GetSyncReplication

func GetSyncReplication(specSyncReplication *bool) bool

GetSyncReplication returns true if synchronous replication has been enabled using either the pgcluster CR specification or the pgo.yaml configuration file. Otherwise, if synchronous mode has not been enabled, it returns false.

func GetTablespaceNamePVCMap

func GetTablespaceNamePVCMap(clusterName string, tablespaceStorageTypeMap map[string]string) map[string]string

GetTablespaceNamePVCMap returns a map of the tablespace name to the PVC name

func GetTablespaceNames

func GetTablespaceNames(tablespaceMounts map[string]crv1.PgStorageSpec) string

GetTablespaceNames generates a comma-separated list of the format "tablespaceName1,tablespceName2" so that the PVC containing a tablespace can be properly mounted in the container, and the tablespace can be referenced by the specified human readable name. We use a comma-separated list to make it "easier" to work with the shell scripts that currently setup the container

func GetTablespacePVCName

func GetTablespacePVCName(clusterName string, tablespaceName string) string

GetTablespacePVCName returns the formatted name that is used for a PVC for a tablespace

func GetTablespaceStorageTypeMap

func GetTablespaceStorageTypeMap(tablespaceMounts map[string]crv1.PgStorageSpec) map[string]string

GetTablespaceStorageTypeMap returns a map of "tablespaceName => storageType"

func GetTablespaceVolumeMountsJSON

func GetTablespaceVolumeMountsJSON(tablespaceStorageTypeMap map[string]string) string

GetTablespaceVolumeMountsJSON Creates an appendable list for the volumeMounts that are used to mount table spacs and returns them in a JSON-ish string

func GetTablespaceVolumeName

func GetTablespaceVolumeName(tablespaceName string) string

GetTableSpaceVolumeName returns the name that is used to identify the volume that is used to mount the tablespace

func GetTablespaceVolumesJSON

func GetTablespaceVolumesJSON(clusterName string, tablespaceStorageTypeMap map[string]string) string

GetTablespaceVolumes Creates an appendable list for the volumes section of a Kubernetes pod

func Initialize

func Initialize(clientset *kubernetes.Clientset)

func IsLocalAndS3Storage

func IsLocalAndS3Storage(backrestStorageType string) bool

IsLocalAndS3Storage a boolean indicating whether or not local and s3 storage should be enabled for pgBackRest based on the backrestStorageType string provided

func NamespaceOperatingMode

func NamespaceOperatingMode() ns.NamespaceOperatingMode

NamespaceOperatingMode returns the namespace operating mode for the current Operator installation, which is stored in the "namespaceOperatingMode" variable

func OverrideClusterContainerImages

func OverrideClusterContainerImages(containers []v1.Container)

OverrideClusterContainerImages is a helper function that provides the appropriate hooks to override any of the container images that might be deployed with a PostgreSQL cluster

func SetContainerImageOverride

func SetContainerImageOverride(containerImageName string, container *v1.Container)

SetContainerImageOverride determines if there is an override available for a container image, and sets said value on the Kubernetes Container image definition

func SetupNamespaces

func SetupNamespaces(clientset *kubernetes.Clientset) ([]string, error)

SetupNamespaces is responsible for the initial namespace configuration for the Operator install. This includes setting the proper namespace operating mode, creating and/or updating namespaces as needed (or as permitted by the current operator mode), and returning a valid list of namespaces for the current Operator install.

func UpdatePGHAConfigInitFlag

func UpdatePGHAConfigInitFlag(clientset *kubernetes.Clientset, initVal bool, clusterName,
	namespace string) error

UpdatePGHAConfigInitFlag sets the value for the "init" setting in the PGHA configMap for the PG cluster to the value specified via the "initVal" parameter. For instance, following the initialization of a PG cluster this function will be utilized to set the "init" value to false to ensure the primary does not attempt to run initialization logic in the event that it is restarted.

Types

type DeploymentTemplateFields

type DeploymentTemplateFields struct {
	Name                string
	ClusterName         string
	Port                string
	CCPImagePrefix      string
	CCPImageTag         string
	CCPImage            string
	Database            string
	DeploymentLabels    string
	PodLabels           string
	DataPathOverride    string
	ArchiveMode         string
	PVCName             string
	RootSecretName      string
	UserSecretName      string
	PrimarySecretName   string
	SecurityContext     string
	ContainerResources  string
	NodeSelector        string
	ConfVolume          string
	CollectAddon        string
	CollectVolume       string
	BadgerAddon         string
	PgbackrestEnvVars   string
	PgbackrestS3EnvVars string
	PgmonitorEnvVars    string
	ScopeLabel          string
	//next 2 are for the replica deployment only
	Replicas                 string
	PrimaryHost              string
	IsInit                   bool
	EnableCrunchyadm         bool
	ReplicaReinitOnStartFail bool
	PodAntiAffinity          string
	SyncReplication          bool
	Standby                  bool
	// A comma-separated list of tablespace names...this could be an array, but
	// given how this would ultimately be interpreted in a shell script somewhere
	// down the line, it's easier for the time being to do it this way. In the
	// future, we should consider having an array
	Tablespaces            string
	TablespaceVolumes      string
	TablespaceVolumeMounts string
	// The following fields set the TLS requirements as well as provide
	// information on how to configure TLS in a PostgreSQL cluster
	// TLSEnabled enables TLS in a cluster if set to true. Only works in actuality
	// if CASecret and TLSSecret are set
	TLSEnabled bool
	// TLSOnly is set to true if the PostgreSQL cluster should only accept TLS
	// connections
	TLSOnly bool
	// TLSSecret is the name of the Secret that has the PostgreSQL server's TLS
	// keypair
	TLSSecret string
	// CASecret is the name of the Secret that has the trusted CA that the
	// PostgreSQL server is using
	CASecret string
}

DeploymentTemplateFields ...

type PgbackrestEnvVarsTemplateFields

type PgbackrestEnvVarsTemplateFields struct {
	PgbackrestStanza            string
	PgbackrestDBPath            string
	PgbackrestRepo1Path         string
	PgbackrestRepo1Host         string
	PgbackrestRepo1Type         string
	PgbackrestLocalAndS3Storage bool
	PgbackrestPGPort            string
}

type PgbackrestS3EnvVarsTemplateFields

type PgbackrestS3EnvVarsTemplateFields struct {
	PgbackrestS3Bucket     string
	PgbackrestS3Endpoint   string
	PgbackrestS3Region     string
	PgbackrestS3Key        string
	PgbackrestS3KeySecret  string
	PgbackrestS3SecretName string
}

type PgmonitorEnvVarsTemplateFields

type PgmonitorEnvVarsTemplateFields struct {
	PgmonitorPassword string
}

type StorageResult

type StorageResult struct {
	PersistentVolumeClaimName string
	SupplementalGroups        []int64
}

StorageResult is a resolved PgStorageSpec. The zero value is an emptyDir.

func (StorageResult) InlineVolumeSource

func (s StorageResult) InlineVolumeSource() string

InlineVolumeSource returns the key and value of a k8s.io/api/core/v1.VolumeSource.

func (StorageResult) VolumeSource

func (s StorageResult) VolumeSource() v1.VolumeSource

VolumeSource returns the VolumeSource equivalent of s.

Directories

Path Synopsis
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 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

Jump to

Keyboard shortcuts

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