configuration

package
v1.25.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package configuration contains the configuration of the operator, reading if from environment variables and from the ConfigMap

Index

Constants

View Source
const (
	// DefaultOperatorPullSecretName is implicitly copied into newly created clusters.
	DefaultOperatorPullSecretName = "cnpg-pull-secret" // #nosec

	// CertificateDuration is the default value for the lifetime of the generated certificates
	CertificateDuration = 90

	// ExpiringCheckThreshold is the default threshold to consider a certificate as expiring
	ExpiringCheckThreshold = 7

	// DefaultKubernetesClusterDomain is the default value used as
	// Kubernetes cluster domain.
	DefaultKubernetesClusterDomain = "cluster.local"
)
View Source
const DefaultPluginSocketDir = "/plugins"

DefaultPluginSocketDir is the default directory where the plugin sockets are located.

Variables

View Source
var Current = NewConfiguration()

Current is the configuration used by the operator

Functions

This section is empty.

Types

type Data

type Data struct {
	// WebhookCertDir is the directory where the certificates for the webhooks
	// need to written. This is different between plain Kubernetes and OpenShift
	WebhookCertDir string `json:"webhookCertDir" env:"WEBHOOK_CERT_DIR"`

	// PluginSocketDir is the directory where the plugins sockets are to be
	// found
	PluginSocketDir string `json:"pluginSocketDir" env:"PLUGIN_SOCKET_DIR"`

	// WatchNamespace is the namespace where the operator should watch and
	// is configurable via environment variables in the OpenShift console.
	// Multiple namespaces can be specified separated by comma
	WatchNamespace string `json:"watchNamespace" env:"WATCH_NAMESPACE"`

	// OperatorNamespace is the namespace where the operator is installed
	OperatorNamespace string `json:"operatorNamespace" env:"OPERATOR_NAMESPACE"`

	// OperatorPullSecretName is the pull secret used to download the
	// pull secret name
	OperatorPullSecretName string `json:"operatorPullSecretName" env:"PULL_SECRET_NAME"`

	// OperatorImageName is the name of the image of the operator, that is
	// used to bootstrap Pods
	OperatorImageName string `json:"operatorImageName" env:"OPERATOR_IMAGE_NAME"`

	// PostgresImageName is the name of the image of PostgreSQL that is
	// used by default for new clusters
	PostgresImageName string `json:"postgresImageName" env:"POSTGRES_IMAGE_NAME"`

	// InheritedAnnotations is a list of annotations that every resource could inherit from
	// the owning Cluster
	InheritedAnnotations []string `json:"inheritedAnnotations" env:"INHERITED_ANNOTATIONS"`

	// InheritedLabels is a list of labels that every resource could inherit from
	// the owning Cluster
	InheritedLabels []string `json:"inheritedLabels" env:"INHERITED_LABELS"`

	// MonitoringQueriesConfigmap is the name of the configmap in the operator namespace which contain
	// the monitoring queries. The queries will be read from the data key: "queries".
	MonitoringQueriesConfigmap string `json:"monitoringQueriesConfigmap" env:"MONITORING_QUERIES_CONFIGMAP"`

	// MonitoringQueriesSecret is the name of the secret in the operator namespace which contain
	// the monitoring queries. The queries will be read from the data key: "queries".
	MonitoringQueriesSecret string `json:"monitoringQueriesSecret" env:"MONITORING_QUERIES_SECRET"`

	// EnableInstanceManagerInplaceUpdates enables the instance manager to apply in-place updates,
	// replacing the executable in a pod without restarting
	EnableInstanceManagerInplaceUpdates bool `json:"enableInstanceManagerInplaceUpdates" env:"ENABLE_INSTANCE_MANAGER_INPLACE_UPDATES"` //nolint

	// EnableAzurePVCUpdates enables the live update of PVC in Azure environment
	EnableAzurePVCUpdates bool `json:"enableAzurePVCUpdates" env:"ENABLE_AZURE_PVC_UPDATES"`

	// This is the lifetime of the generated certificates
	CertificateDuration int `json:"certificateDuration" env:"CERTIFICATE_DURATION"`

	// Threshold to consider a certificate as expiring
	ExpiringCheckThreshold int `json:"expiringCheckThreshold" env:"EXPIRING_CHECK_THRESHOLD"`

	// CreateAnyService is true when the user wants the operator to create
	// the <cluster-name>-any service. Defaults to false.
	CreateAnyService bool `json:"createAnyService" env:"CREATE_ANY_SERVICE"`

	// The duration (in seconds) to wait between the roll-outs of different
	// clusters during an operator upgrade. This setting controls the
	// timing of upgrades across clusters, spreading them out to reduce
	// system impact. The default value is 0, which means no delay between
	// PostgreSQL cluster upgrades.
	ClustersRolloutDelay int `json:"clustersRolloutDelay" env:"CLUSTERS_ROLLOUT_DELAY"`

	// The duration (in seconds) to wait between roll-outs of individual
	// PostgreSQL instances within the same cluster during an operator
	// upgrade. The default value is 0, meaning no delay between upgrades
	// of instances in the same PostgreSQL cluster.
	InstancesRolloutDelay int `json:"instancesRolloutDelay" env:"INSTANCES_ROLLOUT_DELAY"`

	// IncludePlugins is a comma-separated list of plugins to always be
	// included in the Cluster reconciliation
	IncludePlugins string `json:"includePlugins" env:"INCLUDE_PLUGINS"`

	// KubernetesClusterDomain defines the domain suffix for service FQDNs
	// within the Kubernetes cluster. If left unset, it defaults to `cluster.local`.
	KubernetesClusterDomain string `json:"kubernetesClusterDomain" env:"KUBERNETES_CLUSTER_DOMAIN"`
}

Data is the struct containing the configuration of the operator. Usually the operator code will use the "Current" configuration.

func NewConfiguration

func NewConfiguration() *Data

NewConfiguration create a new CNPG configuration by reading the environment variables

func (*Data) GetClustersRolloutDelay added in v1.25.0

func (config *Data) GetClustersRolloutDelay() time.Duration

GetClustersRolloutDelay gets the delay between roll-outs of different clusters

func (*Data) GetIncludePlugins added in v1.25.0

func (config *Data) GetIncludePlugins() []string

GetIncludePlugins gets the list of plugins to be always included in the operator reconciliation

func (*Data) GetInstancesRolloutDelay added in v1.25.0

func (config *Data) GetInstancesRolloutDelay() time.Duration

GetInstancesRolloutDelay gets the delay between roll-outs of pods belonging to the same cluster

func (*Data) IsAnnotationInherited

func (config *Data) IsAnnotationInherited(name string) bool

IsAnnotationInherited checks if an annotation with a certain name should be inherited from the Cluster specification to the generated objects

func (*Data) IsLabelInherited

func (config *Data) IsLabelInherited(name string) bool

IsLabelInherited checks if a label with a certain name should be inherited from the Cluster specification to the generated objects

func (*Data) ReadConfigMap

func (config *Data) ReadConfigMap(data map[string]string)

ReadConfigMap reads the configuration from the environment and the passed in data map

func (*Data) WatchedNamespaces

func (config *Data) WatchedNamespaces() []string

WatchedNamespaces get the list of additional watched namespaces. The result is a list of namespaces specified in the WATCHED_NAMESPACE where each namespace is separated by comma

Jump to

Keyboard shortcuts

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