config

package
v4.4.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PGHADCSConfigName represents the name of the DCS configuration stored in the
	// "<clustername>-pgha-config" configMap, which is "<clustername>-dcs-config"
	PGHADCSConfigName = "%s-dcs-config"
)

Variables

View Source
var (
	// ErrMissingClusterConfig is the error thrown when configuration is missing from a configMap
	ErrMissingClusterConfig error = errors.New("Configuration is missing from configMap")
)

Functions

func GetLocalDBConfigNames

func GetLocalDBConfigNames(kubeclientset kubernetes.Interface, clusterName,
	namespace string) ([]string, error)

GetLocalDBConfigNames returns the names of the local configuration for each database server in the cluster as stored in the <clusterName>-pgha-config configMap per naming conventions.

Types

type Callbacks

type Callbacks struct {
	OnReload     string `json:"on_reload,omitempty"`
	OnRestart    string `json:"on_restart,omitempty"`
	OnRoleChange string `json:"on_role_change,omitempty"`
	OnStart      string `json:"on_start,omitempty"`
	OnStop       string `json:"on_stop,omitempty"`
}

Callbacks defines the various Patroni callbacks

type CreateReplicaMethod

type CreateReplicaMethod struct {
	Command  string `json:"command,omitempty"`
	KeepData bool   `json:"keep_data,omitempty"`
	NoParams bool   `json:"no_params,omitempty"`
	NoMaster int    `json:"no_master,omitempty"`
}

CreateReplicaMethod represents a Patroni replica creation method

type DCS

type DCS struct {
	// contains filtered or unexported fields
}

DCS configures the DCS configuration settings for a specific PG cluster.

func NewDCS

func NewDCS(configMap *corev1.ConfigMap, kubeclientset kubernetes.Interface,
	clusterScope string) *DCS

NewDCS creates a new DCS config struct using the configMap provided. The DCSConfig will include a configMap that will be used to configure the DCS for a specific cluster.

func (*DCS) GetDCSConfig

func (d *DCS) GetDCSConfig() (*DCSConfig, map[string]json.RawMessage, error)

GetDCSConfig returns the current DCS configuration included in the ClusterConfig's configMap, i.e. the contents of the "<clustername-dcs-config>" configuration unmarshalled into a DCSConfig struct.

func (*DCS) Sync

func (d *DCS) Sync() error

Sync attempts to apply all configuration in the the DCSConfig's configMap. If the DCS configuration is missing from the configMap, then and attempt is made to add it by refreshing the DCS configuration.

func (*DCS) Update

func (d *DCS) Update(dcsConfig *DCSConfig) error

Update updates the contents of the DCS configuration stored within the configMap included in the DCS.

type DCSConfig

type DCSConfig struct {
	LoopWait              int                `json:"loop_wait,omitempty"`
	TTL                   int                `json:"ttl,omitempty"`
	RetryTimeout          int                `json:"retry_timeout,omitempty"`
	MaximumLagOnFailover  int                `json:"maximum_lag_on_failover,omitempty"`
	MasterStartTimeout    int                `json:"master_start_timeout,omitempty"`
	SynchronousMode       bool               `json:"synchronous_mode,omitempty"`
	SynchronousModeStrict bool               `json:"synchronous_mode_strict,omitempty"`
	PostgreSQL            *PostgresDCS       `json:"postgresql,omitempty"`
	StandbyCluster        *StandbyDCS        `json:"standby_cluster,omitempty"`
	Slots                 map[string]SlotDCS `json:"slots,omitempty"`
}

DCSConfig represents the cluster-wide configuration that is stored in the Distributed Configuration Store (DCS).

type LocalDB

type LocalDB struct {
	// contains filtered or unexported fields
}

LocalDB configures the local configuration settings for a specific database server within a PG cluster.

func NewLocalDB

func NewLocalDB(configMap *corev1.ConfigMap, restConfig *rest.Config,
	kubeclientset kubernetes.Interface, pgoRESTClient *rest.RESTClient) (*LocalDB, error)

NewLocalDB creates a new LocalDB, which includes a configMap that contains the local configuration settings for the database servers within a specific PG cluster. Additionally the LocalDB includes the client(s) and other applicable resources needed to access and modify various resources within the Kubernetes cluster in support of configuring the included database servers.

func (*LocalDB) Sync

func (l *LocalDB) Sync() error

Sync attempts to apply all local database server configuration settings in the the LocalDB's configMap to the various servers included in the LocalDB. If the configuration for a server is missing from the configMap, then and attempt is made to add it by refreshing that specific configuration. Also, any configurations within the configMap associated with servers that no longer exist are removed.

func (*LocalDB) Update

func (l *LocalDB) Update(configName string, localDBConfig LocalDBConfig) error

Update updates the contents of the configuration for a specific database server in the PG cluster, specifically within the configMap included in the LocalDB.

type LocalDBConfig

type LocalDBConfig struct {
	PostgreSQL PostgresLocalDB `json:"postgresql,omitempty"`
}

LocalDBConfig represents the local configuration for a specific PostgreSQL database server within a PostgreSQL cluster. Only user-facing configuration is exposed via this struct, and not any configuration that is controlled/managed by the Operator itself.

type PostgresDCS

type PostgresDCS struct {
	UsePGRewind  bool                   `json:"use_pg_rewind,omitempty"`
	UseSlots     bool                   `json:"use_slots,omitempty"`
	RecoveryConf map[string]interface{} `json:"recovery_conf,omitempty"`
	Parameters   map[string]interface{} `json:"parameters,omitempty"`
}

PostgresDCS represents the PostgreSQL settings that can be applied cluster-wide to a PostgreSQL cluster via the DCS.

type PostgresLocalDB

type PostgresLocalDB struct {
	// Authentication is the block for managing the Patroni managed accounts
	// (superuser, replication, rewind). While the PostgreSQL Operator manages
	// these overall, one may want to override them. We allow for this, but the
	// deployer should take care when overriding this value
	Authentication                         map[string]interface{} `json:"authentication,omitempty"`
	Callbacks                              *Callbacks             `json:"callbacks,omitempty"`
	CreateReplicaMethods                   []string               `json:"create_replica_methods,omitempty"`
	ConfigDir                              string                 `json:"config_dir,omitempty"`
	UseUnixSocket                          bool                   `json:"use_unix_socket,omitempty"`
	PGPass                                 string                 `json:"pgpass,omitempty"`
	RecoveryConf                           map[string]interface{} `json:"recovery_conf,omitempty"`
	CustomConf                             map[string]interface{} `json:"custom_conf,omitempty"`
	Parameters                             map[string]interface{} `json:"parameters,omitempty"`
	PGHBA                                  []string               `json:"pg_hba,omitempty"`
	PGIdent                                []string               `json:"pg_ident,omitempty"`
	PGCTLTimeout                           int                    `json:"pg_ctl_timeout,omitempty"`
	UsePGRewind                            bool                   `json:"use_pg_rewind,omitempty"`
	RemoveDataDirectoryOnRewindFailure     bool                   `json:"remove_data_directory_on_rewind_failure,omitempty"`
	RemoveDataDirectoryOnDivergedTimelines bool                   `json:"remove_data_directory_on_diverged_timelines,omitempty"`
	PGBackRest                             *CreateReplicaMethod   `json:"pgbackrest,omitempty"`
	PGBackRestStandby                      *CreateReplicaMethod   `json:"pgbackrest_standby,omitempty"`
}

PostgresLocalDB represents the PostgreSQL settings that can be applied to an individual PostgreSQL server within a PostgreSQL cluster.

type SlotDCS

type SlotDCS struct {
	Type     string `json:"type,omitempty"`
	Database string `json:"database,omitempty"`
	Plugin   string `json:"plugin,omitempty"`
}

SlotDCS represents slot settings that can be applied cluster-wide via the DCS.

type StandbyDCS

type StandbyDCS struct {
	Host                  string                 `json:"host,omitempty"`
	Port                  int                    `json:"port,omitempty"`
	PrimarySlotName       map[string]interface{} `json:"primary_slot_name,omitempty"`
	CreateReplicaMethods  []string               `json:"create_replica_methods,omitempty"`
	RestoreCommand        string                 `json:"restore_command,omitempty"`
	ArchiveCleanupCommand string                 `json:"archive_cleanup_command,omitempty"`
	RecoveryMinApplyDelay int                    `json:"recovery_min_apply_delay,omitempty"`
}

StandbyDCS represents standby cluster settings that can be applied cluster-wide via the DCS.

type Syncer

type Syncer interface {
	Sync() error
}

Syncer defines a resource that is able to sync its configuration stored configuration with a service, application, etc.

Jump to

Keyboard shortcuts

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