Documentation ¶
Index ¶
- Constants
- Variables
- func AddWALVolumeAndMountsToBackRest(podSpec *core_v1.PodSpec, walVolume StorageResult)
- func AddWALVolumeAndMountsToPostgreSQL(podSpec *core_v1.PodSpec, walVolume StorageResult, instanceName string)
- func CreatePGHAConfigMap(clientset kubernetes.Interface, cluster *crv1.Pgcluster, namespace string) error
- func GetAffinity(nodeLabelKey, nodeLabelValue string, affoperator string) string
- func GetBackrestDeployment(clientset kubernetes.Interface, cluster *crv1.Pgcluster) (*apps_v1.Deployment, error)
- func GetBadgerAddon(clientset kubernetes.Interface, namespace string, cluster *crv1.Pgcluster, ...) string
- func GetCollectAddon(clientset kubernetes.Interface, namespace string, spec *crv1.PgclusterSpec) string
- func GetCollectVolume(clientset kubernetes.Interface, cl *crv1.Pgcluster, namespace string) string
- func GetConfVolume(clientset kubernetes.Interface, cl *crv1.Pgcluster, namespace string) string
- func GetInstanceDeployments(clientset kubernetes.Interface, cluster *crv1.Pgcluster) (*apps_v1.DeploymentList, error)
- func GetLabelsFromMap(labels map[string]string) string
- func GetPgbackrestBootstrapEnvVars(restoreClusterName, depName string, restoreFromSecret *v1.Secret) (string, error)
- func GetPgbackrestBootstrapS3EnvVars(pgDataSourceRestoreFrom string, restoreFromSecret *v1.Secret) string
- func GetPgbackrestEnvVars(cluster *crv1.Pgcluster, backrestEnabled, depName, port, storageType string) string
- func GetPgbackrestS3EnvVars(cluster crv1.Pgcluster, clientset kubernetes.Interface, ns string) string
- func GetPgmonitorEnvVars(metricsEnabled, collectSecret string) string
- func GetPodAntiAffinity(cluster *crv1.Pgcluster, deploymentType crv1.PodAntiAffinityDeployment, ...) string
- func GetPodAntiAffinityType(cluster *crv1.Pgcluster, deploymentType crv1.PodAntiAffinityDeployment, ...) crv1.PodAntiAffinityType
- func GetPodSecurityContext(supplementalGroups []int64) string
- func GetRepoType(backrestStorageType string) string
- func GetResourcesJSON(resources, limits v1.ResourceList) string
- func GetS3VerifyTLSSetting(cluster *crv1.Pgcluster) string
- func GetSyncReplication(specSyncReplication *bool) bool
- func GetTablespaceNamePVCMap(clusterName string, tablespaceStorageTypeMap map[string]string) map[string]string
- func GetTablespaceNames(tablespaceMounts map[string]crv1.PgStorageSpec) string
- func GetTablespacePVCName(clusterName string, tablespaceName string) string
- func GetTablespaceStorageTypeMap(tablespaceMounts map[string]crv1.PgStorageSpec) map[string]string
- func GetTablespaceVolumeMountsJSON(tablespaceStorageTypeMap map[string]string) string
- func GetTablespaceVolumeName(tablespaceName string) string
- func GetTablespaceVolumesJSON(clusterName string, tablespaceStorageTypeMap map[string]string) string
- func Initialize(clientset kubernetes.Interface)
- func IsLocalAndS3Storage(backrestStorageType string) bool
- func NamespaceOperatingMode() ns.NamespaceOperatingMode
- func OverrideClusterContainerImages(containers []v1.Container)
- func SetContainerImageOverride(containerImageName string, container *v1.Container)
- func SetupNamespaces(clientset kubernetes.Interface) ([]string, error)
- func UpdatePGHAConfigInitFlag(clientset kubernetes.Interface, initVal bool, clusterName, namespace string) error
- type BootstrapJobTemplateFields
- type DeploymentTemplateFields
- type PgbackrestEnvVarsTemplateFields
- type PgbackrestS3EnvVarsTemplateFields
- type PgmonitorEnvVarsTemplateFields
- type StorageResult
Constants ¶
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
const AFFINITY_NOTINOperator = "NotIn"
const AffinityInOperator = "In"
consolidate with cluster.affinityTemplateFields
const PGHAConfigMapSuffix = "pgha-config"
PGHAConfigMapSuffix defines the suffix for the name of the PGHA configMap created for each PG cluster
Variables ¶
var CRUNCHY_DEBUG bool
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
var EventTCPAddress = "localhost:4150"
var InstallationName string
var NAMESPACE string
var Pgo config.PgoConfig
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.Interface, 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 ¶
GetAffinity ...
func GetBackrestDeployment ¶
func GetBackrestDeployment(clientset kubernetes.Interface, cluster *crv1.Pgcluster) (*apps_v1.Deployment, error)
GetBackrestDeployment finds the pgBackRest repository Deployments for a PostgreQL cluster
func GetBadgerAddon ¶
func GetCollectAddon ¶
func GetCollectAddon(clientset kubernetes.Interface, namespace string, spec *crv1.PgclusterSpec) string
func GetCollectVolume ¶
sets the proper collect secret in the deployment spec if collect is enabled
func GetConfVolume ¶
consolidate with cluster.GetConfVolume
func GetInstanceDeployments ¶
func GetInstanceDeployments(clientset kubernetes.Interface, cluster *crv1.Pgcluster) (*apps_v1.DeploymentList, error)
GetInstanceDeployments finds the Deployments that represent PostgreSQL instances
func GetLabelsFromMap ¶
needs to be consolidated with cluster.GetLabelsFromMap GetLabelsFromMap ...
func GetPgbackrestBootstrapEnvVars ¶
func GetPgbackrestBootstrapEnvVars(restoreClusterName, depName string, restoreFromSecret *v1.Secret) (string, error)
GetPgbackrestBootstrapEnvVars returns a string containing the pgBackRest environment variables for a bootstrap job
func GetPgbackrestBootstrapS3EnvVars ¶
func GetPgbackrestBootstrapS3EnvVars(pgDataSourceRestoreFrom string, restoreFromSecret *v1.Secret) string
GetPgbackrestBootstrapS3EnvVars retrieves the values for the various configuration settings required to configure pgBackRest for AWS S3, specifically for a bootstrap job (includes a bucket, endpoint, region, key and key secret. The bucket, endpoint & region are obtained from annotations in the pgbackrest secret from the cluster being restored from during the bootstrap job, while the key and key secret are then obtained from the data in this same 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 for the boostrap job. 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 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.Interface, 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 ¶
GetPgmonitorEnvVars populates the pgmonitor env var template, which contains any pgmonitor env vars that need to be included in the Deployment spec for a PG cluster.
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:
- If it's pgBackRest/pgBouncer the value set by the user (available in the cluster spec)
- If it's pgBackRest/pgBouncer the value set in pgo.yaml
- The value set in "Default" in the cluster spec
- The value set for PodAntiAffinity in pgo.yaml
func GetPodSecurityContext ¶
GetPodSecurityContext will generate the security context required for a Deployment by incorporating the standard fsGroup for the user that runs the container (typically the "postgres" user), and adds any supplemental groups that may need to be added, e.g. for NFS storage.
Following the legacy method, this returns a JSON string, which will be modified in the future. Mainly this is transitioning from the legacy function by adding the expected types
func GetRepoType ¶
GetRepoType returns the proper repo type to set in container based on the backrest storage type provided
func GetResourcesJSON ¶
func GetResourcesJSON(resources, limits v1.ResourceList) 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 GetS3VerifyTLSSetting ¶
GetS3VerifyTLSSetting parses the configured value as a boolean to ensure a valid option is used, then returns the pgBackRest S3 configuration value to either enable or disable TLS verification as the expected string value.
func GetSyncReplication ¶
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 ¶
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 ¶
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 ¶
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.Interface)
func IsLocalAndS3Storage ¶
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 ¶
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 ¶
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.Interface) ([]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.Interface, 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 BootstrapJobTemplateFields ¶
type BootstrapJobTemplateFields struct { DeploymentTemplateFields // RestoreFrom defines the name of a cluster to restore from when bootstrapping from an // existing data source RestoreFrom string // RestoreOpts defines the command line options that should be passed to the restore utility // (e.g. pgBackRest) when bootstrapping the cluster from an existing data source RestoreOpts string }
BootstrapJobTemplateFields defines the fields needed to populate the cluster bootstrap job template
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 Replicas 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 // ReplicationTLSSecret is the name of the Secret that has the TLS keypair // for performing certificate-based authentication between instances ReplicationTLSSecret string // CASecret is the name of the Secret that has the trusted CA that the // PostgreSQL server is using CASecret string }
DeploymentTemplateFields ...
type PgmonitorEnvVarsTemplateFields ¶
type PgmonitorEnvVarsTemplateFields struct {
CollectSecret string
}
type StorageResult ¶
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 |