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) 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" )
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"` // 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 // 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. 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"` // DrainTaints is a list of taints the operator will watch and treat as Unschedule DrainTaints []string `json:"drainTaints" env:"DRAIN_TAINTS"` }
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) 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