{"modulePath":"github.com/CrunchyData/postgres-operator","version":"v4.3.4+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package operator\n\n## Constants\n\n```go\nconst (\n\t// PGHAConfigInitSetting determines whether or not initialization logic should be run in the\n\t// crunchy-postgres-ha (or GIS equivilaent) container\n\tPGHAConfigInitSetting = \"init\"\n\t// PGHAConfigReplicaBootstrapRepoType defines an override for the type of repo (local, S3, etc.)\n\t// that should be utilized when bootstrapping a replica (i.e. it override the\n\t// PGBACKREST_REPO_TYPE env var in the environment).  Allows for dynamic changing of the\n\t// backrest repo type without requiring container restarts (as would be required to update\n\t// PGBACKREST_REPO_TYPE).\n\tPGHAConfigReplicaBootstrapRepoType = \"replica-bootstrap-repo-type\"\n)\n```\nthe following constants define the settings in the PGHA configMap that is created for each PG cluster\n\n```go\nconst AFFINITY_NOTINOperator = \"NotIn\"\n```\n\n```go\nconst AffinityInOperator = \"In\"\n```\nconsolidate with cluster.affinityTemplateFields\n\n```go\nconst PGHAConfigMapSuffix = \"pgha-config\"\n```\nPGHAConfigMapSuffix defines the suffix for the name of the PGHA configMap created for each PG cluster\n\n## Variables\n\n```go\nvar CRUNCHY_DEBUG bool\n```\n\n```go\nvar ContainerImageOverrides = map[string]string{}\n```\nContainerImageOverrides contains a list of container images that are overridden by the RELATED\\_IMAGE\\_\\* environmental variables that can be set by people deploying the Operator\n\n```go\nvar EventTCPAddress = \"localhost:4150\"\n```\n\n```go\nvar InstallationName string\n```\n\n```go\nvar NAMESPACE string\n```\n\n```go\nvar Pgo config.PgoConfig\n```\n\n```go\nvar PgoNamespace string\n```\n\n## Functions\n\n```go\nfunc AddWALVolumeAndMountsToBackRest(podSpec *core_v1.PodSpec, walVolume StorageResult)\n```\nAddWALVolumeAndMountsToBackRest modifies a pgBackRest podSpec to include walVolume.\n\n```go\nfunc AddWALVolumeAndMountsToPostgreSQL(podSpec *core_v1.PodSpec, walVolume StorageResult, instanceName string)\n```\nAddWALVolumeAndMountsToPostgreSQL modifies a PostgreSQL podSpec to include walVolume.\n\n```go\nfunc CreatePGHAConfigMap(clientset *kubernetes.Clientset, cluster *crv1.Pgcluster,\n\tnamespace string) error\n```\nCreatePGHAConfigMap 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.\n\n```go\nfunc GetAffinity(nodeLabelKey, nodeLabelValue string, affoperator string) string\n```\nGetAffinity ...\n\n```go\nfunc GetBackrestDeployment(clientset *kubernetes.Clientset, cluster *crv1.Pgcluster) (*apps_v1.Deployment, error)\n```\nGetBackrestDeployment finds the pgBackRest repository Deployments for a PostgreQL cluster\n\n```go\nfunc GetBadgerAddon(clientset *kubernetes.Clientset, namespace string, cluster *crv1.Pgcluster, pgbadger_target string) string\n```\n\n```go\nfunc GetCollectAddon(clientset *kubernetes.Clientset, namespace string, spec *crv1.PgclusterSpec) string\n```\n\n```go\nfunc GetCollectVolume(clientset *kubernetes.Clientset, cl *crv1.Pgcluster, namespace string) string\n```\nsets the proper collect secret in the deployment spec if collect is enabled\n\n```go\nfunc GetConfVolume(clientset *kubernetes.Clientset, cl *crv1.Pgcluster, namespace string) string\n```\nconsolidate with cluster.GetConfVolume\n\n```go\nfunc GetInstanceDeployments(clientset *kubernetes.Clientset, cluster *crv1.Pgcluster) (*apps_v1.DeploymentList, error)\n```\nGetInstanceDeployments finds the Deployments that represent PostgreSQL instances\n\n```go\nfunc GetLabelsFromMap(labels map[string]string) string\n```\nneeds to be consolidated with cluster.GetLabelsFromMap GetLabelsFromMap ...\n\n```go\nfunc GetPgbackrestEnvVars(cluster *crv1.Pgcluster, backrestEnabled, depName, port, storageType string) string\n```\nconsolidate with cluster.GetPgbackrestEnvVars\n\n```go\nfunc GetPgbackrestS3EnvVars(cluster crv1.Pgcluster, clientset *kubernetes.Clientset,\n\tns string) string\n```\nGetPgbackrestS3EnvVars 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 \u0026 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.\n\n```go\nfunc GetPgmonitorEnvVars(metricsEnabled, collectSecret string) string\n```\nGetPgmonitorEnvVars 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.\n\n```go\nfunc GetPodAntiAffinity(cluster *crv1.Pgcluster, deploymentType crv1.PodAntiAffinityDeployment, podAntiAffinityType crv1.PodAntiAffinityType) string\n```\nGetPodAntiAffinity returns the populated pod anti-affinity json that should be attached to the various pods comprising the pg cluster\n\n```go\nfunc GetPodAntiAffinityType(cluster *crv1.Pgcluster, deploymentType crv1.PodAntiAffinityDeployment, podAntiAffinityType crv1.PodAntiAffinityType) crv1.PodAntiAffinityType\n```\nGetPodAntiAffinityType 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.\n\nIn other words, the pod anti-affinity is determined by this heuristic, in priority order:\n\n 1. If it's pgBackRest/pgBouncer the value set by the user (available in the cluster spec)\n 2. If it's pgBackRest/pgBouncer the value set in pgo.yaml\n 3. The value set in \"Default\" in the cluster spec\n 4. The value set for PodAntiAffinity in pgo.yaml\n\n```go\nfunc GetPodSecurityContext(supplementalGroups []int64) string\n```\nGetPodSecurityContext 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.\n\nFollowing 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\n\n```go\nfunc GetRepoType(backrestStorageType string) string\n```\nGetRepoType returns the proper repo type to set in container based on the backrest storage type provided\n\n```go\nfunc GetResourcesJSON(resources, limits v1.ResourceList) string\n```\nGetResourcesJSON 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\n\n```go\nfunc GetSyncReplication(specSyncReplication *bool) bool\n```\nGetSyncReplication 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.\n\n```go\nfunc GetTablespaceNamePVCMap(clusterName string, tablespaceStorageTypeMap map[string]string) map[string]string\n```\nGetTablespaceNamePVCMap returns a map of the tablespace name to the PVC name\n\n```go\nfunc GetTablespaceNames(tablespaceMounts map[string]crv1.PgStorageSpec) string\n```\nGetTablespaceNames 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\n\n```go\nfunc GetTablespacePVCName(clusterName string, tablespaceName string) string\n```\nGetTablespacePVCName returns the formatted name that is used for a PVC for a tablespace\n\n```go\nfunc GetTablespaceStorageTypeMap(tablespaceMounts map[string]crv1.PgStorageSpec) map[string]string\n```\nGetTablespaceStorageTypeMap returns a map of \"tablespaceName =\u003e storageType\"\n\n```go\nfunc GetTablespaceVolumeMountsJSON(tablespaceStorageTypeMap map[string]string) string\n```\nGetTablespaceVolumeMountsJSON Creates an appendable list for the volumeMounts that are used to mount table spacs and returns them in a JSON-ish string\n\n```go\nfunc GetTablespaceVolumeName(tablespaceName string) string\n```\nGetTableSpaceVolumeName returns the name that is used to identify the volume that is used to mount the tablespace\n\n```go\nfunc GetTablespaceVolumesJSON(clusterName string, tablespaceStorageTypeMap map[string]string) string\n```\nGetTablespaceVolumes Creates an appendable list for the volumes section of a Kubernetes pod\n\n```go\nfunc Initialize(clientset *kubernetes.Clientset)\n```\n\n```go\nfunc IsLocalAndS3Storage(backrestStorageType string) bool\n```\nIsLocalAndS3Storage a boolean indicating whether or not local and s3 storage should be enabled for pgBackRest based on the backrestStorageType string provided\n\n```go\nfunc NamespaceOperatingMode() ns.NamespaceOperatingMode\n```\nNamespaceOperatingMode returns the namespace operating mode for the current Operator installation, which is stored in the \"namespaceOperatingMode\" variable\n\n```go\nfunc OverrideClusterContainerImages(containers []v1.Container)\n```\nOverrideClusterContainerImages is a helper function that provides the appropriate hooks to override any of the container images that might be deployed with a PostgreSQL cluster\n\n```go\nfunc SetContainerImageOverride(containerImageName string, container *v1.Container)\n```\nSetContainerImageOverride determines if there is an override available for a container image, and sets said value on the Kubernetes Container image definition\n\n```go\nfunc SetupNamespaces(clientset *kubernetes.Clientset) ([]string, error)\n```\nSetupNamespaces 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.\n\n```go\nfunc UpdatePGHAConfigInitFlag(clientset *kubernetes.Clientset, initVal bool, clusterName,\n\tnamespace string) error\n```\nUpdatePGHAConfigInitFlag 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.\n\n## Types\n\n```go\ntype DeploymentTemplateFields struct {\n\tName                string\n\tClusterName         string\n\tPort                string\n\tCCPImagePrefix      string\n\tCCPImageTag         string\n\tCCPImage            string\n\tDatabase            string\n\tDeploymentLabels    string\n\tPodLabels           string\n\tDataPathOverride    string\n\tArchiveMode         string\n\tPVCName             string\n\tRootSecretName      string\n\tUserSecretName      string\n\tPrimarySecretName   string\n\tSecurityContext     string\n\tContainerResources  string\n\tNodeSelector        string\n\tConfVolume          string\n\tCollectAddon        string\n\tCollectVolume       string\n\tBadgerAddon         string\n\tPgbackrestEnvVars   string\n\tPgbackrestS3EnvVars string\n\tPgmonitorEnvVars    string\n\tScopeLabel          string\n\t//next 2 are for the replica deployment only\n\tReplicas                 string\n\tPrimaryHost              string\n\tIsInit                   bool\n\tEnableCrunchyadm         bool\n\tReplicaReinitOnStartFail bool\n\tPodAntiAffinity          string\n\tSyncReplication          bool\n\tStandby                  bool\n\t// A comma-separated list of tablespace names...this could be an array, but\n\t// given how this would ultimately be interpreted in a shell script somewhere\n\t// down the line, it's easier for the time being to do it this way. In the\n\t// future, we should consider having an array\n\tTablespaces            string\n\tTablespaceVolumes      string\n\tTablespaceVolumeMounts string\n\t// The following fields set the TLS requirements as well as provide\n\t// information on how to configure TLS in a PostgreSQL cluster\n\t// TLSEnabled enables TLS in a cluster if set to true. Only works in actuality\n\t// if CASecret and TLSSecret are set\n\tTLSEnabled bool\n\t// TLSOnly is set to true if the PostgreSQL cluster should only accept TLS\n\t// connections\n\tTLSOnly bool\n\t// TLSSecret is the name of the Secret that has the PostgreSQL server's TLS\n\t// keypair\n\tTLSSecret string\n\t// CASecret is the name of the Secret that has the trusted CA that the\n\t// PostgreSQL server is using\n\tCASecret string\n}\n```\nDeploymentTemplateFields ...\n\n```go\ntype PgbackrestEnvVarsTemplateFields struct {\n\tPgbackrestStanza            string\n\tPgbackrestDBPath            string\n\tPgbackrestRepo1Path         string\n\tPgbackrestRepo1Host         string\n\tPgbackrestRepo1Type         string\n\tPgbackrestLocalAndS3Storage bool\n\tPgbackrestPGPort            string\n}\n```\n\n```go\ntype PgbackrestS3EnvVarsTemplateFields struct {\n\tPgbackrestS3Bucket     string\n\tPgbackrestS3Endpoint   string\n\tPgbackrestS3Region     string\n\tPgbackrestS3Key        string\n\tPgbackrestS3KeySecret  string\n\tPgbackrestS3SecretName string\n}\n```\n\n```go\ntype PgmonitorEnvVarsTemplateFields struct {\n\tCollectSecret string\n}\n```\n\n```go\ntype StorageResult struct {\n\tPersistentVolumeClaimName string\n\tSupplementalGroups        []int64\n}\n```\nStorageResult is a resolved PgStorageSpec. The zero value is an emptyDir.\n\n```go\nfunc (s StorageResult) InlineVolumeSource() string\n```\nInlineVolumeSource returns the key and value of a k8s.io/api/core/v1.VolumeSource.\n\n```go\nfunc (s StorageResult) VolumeSource() v1.VolumeSource\n```\nVolumeSource returns the VolumeSource equivalent of s.\n\n","path":"github.com/CrunchyData/postgres-operator/operator","name":"operator","synopsis":"","isRedistributable":true}
