Documentation
¶
Overview ¶
Package configuration contains the configuration of the operator, reading if from environment variables and from the ConfigMap
Index ¶
- Constants
- Variables
- type Data
- func (config *Data) GetClustersRolloutDelay() time.Duration
- func (config *Data) GetIncludePlugins() []string
- func (config *Data) GetInstancesRolloutDelay() time.Duration
- func (config *Data) GetMutatingWebhookConfigurationName() string
- func (config *Data) GetValidatingWebhookConfigurationName() string
- func (config *Data) IsAnnotationInherited(name string) bool
- func (config *Data) IsLabelInherited(name string) bool
- func (config *Data) ReadConfigMap(data map[string]string)
- func (config *Data) WatchedNamespaces() []string
Constants ¶
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" // DefaultMutatingWebhookConfigurationName is the default name of the mutating webhook configuration DefaultMutatingWebhookConfigurationName = "cnpg-mutating-webhook-configuration" // DefaultValidatingWebhookConfigurationName is the default name of the validating webhook configuration DefaultValidatingWebhookConfigurationName = "cnpg-validating-webhook-configuration" )
const DefaultPluginSocketDir = "/plugins"
DefaultPluginSocketDir is the default directory where the plugin sockets are located.
Variables ¶
var Current = NewConfiguration()
Current is the configuration used by the operator
var DefaultDrainTaints = []string{
"node.kubernetes.io/unschedulable",
"ToBeDeletedByClusterAutoscaler",
"karpenter.sh/disrupted",
"karpenter.sh/disruption",
}
DefaultDrainTaints is the default list of taints the operator will watch and treat as Unschedule
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"`
// MetricsCertDir is the directory where the certificates for the metrics
// server are stored. If set, the metrics server will use TLS.
MetricsCertDir string `json:"metricsCertDir" env:"METRICS_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"`
// PgbouncerImageName is the name of the image of PgBouncer that is
// used by default for new poolers
PgbouncerImageName string `json:"pgbouncerImageName" env:"PGBOUNCER_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
// 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"`
// StandbyTCPUserTimeout configuration parameter allows you to
// specify a custom TCP user timeout for the standby PostgreSQL
// server's connection to the primary server. This timeout is
// added as a tcp_user_timeout option to the primary_conninfo
// string, which is used by the standby server to connect to the
// primary server in CloudNativePG.
// When nil, the instance manager will use a default value of 5000ms.
// Set to 0 explicitly to use the system's default.
StandbyTCPUserTimeout *int `json:"standbyTcpUserTimeout" env:"STANDBY_TCP_USER_TIMEOUT"`
// 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"`
// EnableWebhookNamespaceSuffix when true appends "-<OperatorNamespace>" to the default
// webhook configuration names, allowing multiple namespaced operator instances to coexist
// on the same cluster. The operator will fail to start if this is enabled without OperatorNamespace.
EnableWebhookNamespaceSuffix bool `json:"enableWebhookNamespaceSuffix" env:"ENABLE_WEBHOOK_NAMESPACE_SUFFIX"`
// DrainTaints is a list of taints the operator will watch and treat as Unschedule
DrainTaints []string `json:"drainTaints" env:"DRAIN_TAINTS"`
// ManageWebhookConfigurations is true when the operator should inject the
// CA bundle into the mutating and validating webhook configurations. It can
// be disabled when the webhook configurations are managed externally (e.g.
// by cert-manager's CA injector or by GitOps).
ManageWebhookConfigurations bool `json:"manageWebhookConfigurations" env:"MANAGE_WEBHOOK_CONFIGURATIONS"`
}
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
GetClustersRolloutDelay gets the delay between roll-outs of different clusters
func (*Data) GetIncludePlugins ¶ added in v1.25.0
GetIncludePlugins gets the list of plugins to be always included in the operator reconciliation
func (*Data) GetInstancesRolloutDelay ¶ added in v1.25.0
GetInstancesRolloutDelay gets the delay between roll-outs of pods belonging to the same cluster
func (*Data) GetMutatingWebhookConfigurationName ¶ added in v1.30.0
GetMutatingWebhookConfigurationName returns the name of the MutatingWebhookConfiguration. When EnableWebhookNamespaceSuffix is true and OperatorNamespace is set, it appends the operator namespace to avoid collisions between multiple operator instances.
func (*Data) GetValidatingWebhookConfigurationName ¶ added in v1.30.0
GetValidatingWebhookConfigurationName returns the name of the ValidatingWebhookConfiguration. When EnableWebhookNamespaceSuffix is true and OperatorNamespace is set, it appends the operator namespace to avoid collisions between multiple operator instances.
func (*Data) IsAnnotationInherited ¶
IsAnnotationInherited checks if an annotation with a certain name should be inherited from the Cluster specification to the generated objects
func (*Data) IsLabelInherited ¶
IsLabelInherited checks if a label with a certain name should be inherited from the Cluster specification to the generated objects
func (*Data) ReadConfigMap ¶
ReadConfigMap reads the configuration from the environment and the passed in data map
func (*Data) WatchedNamespaces ¶
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