Documentation
¶
Index ¶
- Constants
- func GetOperatorNamespace() string
- type CloneDescription
- type ClusterEvent
- type ClusterStatus
- type ControllerConfig
- type ControllerStatus
- type Diff
- type Duration
- type EventType
- type LogEntry
- type MaintenanceWindow
- type NamespacedName
- type Patroni
- type PgSyncUserRequest
- type PgUser
- type PgUserMap
- type PodEvent
- type PostgresSpec
- type PostgresStatus
- type Postgresql
- type PostgresqlList
- type PostgresqlParam
- type Process
- type QueueDump
- type ResourceDescription
- type Resources
- type RoleOrigin
- type Sidecar
- type UserFlags
- type UserSyncer
- type Volume
- type WorkerStatus
Constants ¶
const ( PGSyncUserAdd = iota PGsyncUserAlter PGSyncAlterSet // handle ALTER ROLE SET parameter = value )
Possible values for the sync user operation (removal of users is not supported yet)
Variables ¶
This section is empty.
Functions ¶
func GetOperatorNamespace ¶
func GetOperatorNamespace() string
GetOperatorNamespace assumes serviceaccount secret is mounted by kubernetes Placing this func here instead of pgk/util avoids circular import
Types ¶
type CloneDescription ¶
type CloneDescription struct {
ClusterName string `json:"cluster,omitempty"`
UID string `json:"uid,omitempty"`
EndTimestamp string `json:"timestamp,omitempty"`
}
CloneDescription describes which cluster the new should clone and up to which point in time
type ClusterEvent ¶
type ClusterEvent struct {
EventTime time.Time
UID types.UID
EventType EventType
OldSpec *Postgresql
NewSpec *Postgresql
WorkerID uint32
}
ClusterEvent carries the payload of the Cluster TPR events.
type ClusterStatus ¶
type ClusterStatus struct {
Team string
Cluster string
MasterService *v1.Service
ReplicaService *v1.Service
MasterEndpoint *v1.Endpoints
ReplicaEndpoint *v1.Endpoints
StatefulSet *v1beta1.StatefulSet
PodDisruptionBudget *policyv1beta1.PodDisruptionBudget
CurrentProcess Process
Worker uint32
Status PostgresStatus
Spec PostgresSpec
Error error
}
ClusterStatus describes status of the cluster
type ControllerConfig ¶
type ControllerConfig struct {
RestConfig *rest.Config `json:"-"`
InfrastructureRoles map[string]PgUser
NoDatabaseAccess bool
NoTeamsAPI bool
CRDReadyWaitInterval time.Duration
CRDReadyWaitTimeout time.Duration
ConfigMapName NamespacedName
Namespace string
}
ControllerConfig describes configuration of the controller
type ControllerStatus ¶
ControllerStatus describes status of the controller
type Duration ¶
func (*Duration) UnmarshalJSON ¶
type EventType ¶
type EventType string
EventType contains type of the events for the TPRs and Pods received from Kubernetes
type LogEntry ¶
type LogEntry struct {
Time time.Time
Level logrus.Level
ClusterName *NamespacedName `json:",omitempty"`
Worker *uint32 `json:",omitempty"`
Message string
}
LogEntry describes log entry in the RingLogger
type MaintenanceWindow ¶
type MaintenanceWindow struct {
Everyday bool
Weekday time.Weekday
StartTime time.Time // Start time
EndTime time.Time // End time
}
MaintenanceWindow describes the time window when the operator is allowed to do maintenance on a cluster.
func (*MaintenanceWindow) MarshalJSON ¶
func (m *MaintenanceWindow) MarshalJSON() ([]byte, error)
MarshalJSON converts a maintenance window definition to JSON.
func (*MaintenanceWindow) UnmarshalJSON ¶
func (m *MaintenanceWindow) UnmarshalJSON(data []byte) error
UnmarshalJSON converts a JSON to the maintenance window definition.
type NamespacedName ¶
type NamespacedName types.NamespacedName
NamespacedName describes the namespace/name pairs used in Kubernetes names.
func (*NamespacedName) Decode ¶
func (n *NamespacedName) Decode(value string) error
Decode converts a (possibly unqualified) string into the namespaced name object.
func (*NamespacedName) DecodeWorker ¶
func (n *NamespacedName) DecodeWorker(value, operatorNamespace string) error
DecodeWorker separates the decode logic to (unit) test from obtaining the operator namespace that depends on k8s mounting files at runtime
func (NamespacedName) MarshalJSON ¶
func (n NamespacedName) MarshalJSON() ([]byte, error)
MarshalJSON defines marshaling rule for the namespaced name type.
func (NamespacedName) String ¶
func (n NamespacedName) String() string
func (*NamespacedName) UnmarshalJSON ¶
func (n *NamespacedName) UnmarshalJSON(data []byte) error
type Patroni ¶
type Patroni struct {
InitDB map[string]string `json:"initdb"`
PgHba []string `json:"pg_hba"`
TTL uint32 `json:"ttl"`
LoopWait uint32 `json:"loop_wait"`
RetryTimeout uint32 `json:"retry_timeout"`
MaximumLagOnFailover float32 `json:"maximum_lag_on_failover"` // float32 because https://github.com/kubernetes/kubernetes/issues/30213
}
Patroni contains Patroni-specific configuration
type PgSyncUserRequest ¶
type PgSyncUserRequest struct {
Kind syncUserOperation
User PgUser
}
PgSyncUserRequest has information about a single request to sync a user.
type PgUser ¶
type PgUser struct {
Origin RoleOrigin `yaml:"-"`
Name string `yaml:"-"`
Password string `yaml:"-"`
Flags []string `yaml:"user_flags"`
MemberOf []string `yaml:"inrole"`
Parameters map[string]string `yaml:"db_parameters"`
}
PgUser contains information about a single user.
type PodEvent ¶
type PodEvent struct {
ResourceVersion string
PodName NamespacedName
PrevPod *v1.Pod
CurPod *v1.Pod
EventType EventType
}
PodEvent describes the event for a single Pod
type PostgresSpec ¶
type PostgresSpec struct {
PostgresqlParam `json:"postgresql"`
Volume `json:"volume,omitempty"`
Patroni `json:"patroni,omitempty"`
Resources `json:"resources,omitempty"`
TeamID string `json:"teamId"`
DockerImage string `json:"dockerImage,omitempty"`
// vars that enable load balancers are pointers because it is important to know if any of them is omitted from the Postgres manifest
// in that case the var evaluates to nil and the value is taken from the operator config
EnableMasterLoadBalancer *bool `json:"enableMasterLoadBalancer,omitempty"`
EnableReplicaLoadBalancer *bool `json:"enableReplicaLoadBalancer,omitempty"`
// deprecated load balancer settings maintained for backward compatibility
// see "Load balancers" operator docs
UseLoadBalancer *bool `json:"useLoadBalancer,omitempty"`
ReplicaLoadBalancer *bool `json:"replicaLoadBalancer,omitempty"`
// load balancers' source ranges are the same for master and replica services
AllowedSourceRanges []string `json:"allowedSourceRanges"`
NumberOfInstances int32 `json:"numberOfInstances"`
Users map[string]UserFlags `json:"users"`
MaintenanceWindows []MaintenanceWindow `json:"maintenanceWindows,omitempty"`
Clone CloneDescription `json:"clone"`
ClusterName string `json:"-"`
Databases map[string]string `json:"databases,omitempty"`
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
Sidecars []Sidecar `json:"sidecars,omitempty"`
PodPriorityClassName string `json:"pod_priority_class_name,omitempty"`
}
PostgresSpec defines the specification for the PostgreSQL TPR.
type PostgresStatus ¶
type PostgresStatus string
PostgresStatus contains status of the PostgreSQL cluster (running, creation failed etc.)
const ( ClusterStatusUnknown PostgresStatus = "" ClusterStatusCreating PostgresStatus = "Creating" ClusterStatusUpdating PostgresStatus = "Updating" ClusterStatusUpdateFailed PostgresStatus = "UpdateFailed" ClusterStatusSyncFailed PostgresStatus = "SyncFailed" ClusterStatusAddFailed PostgresStatus = "CreateFailed" ClusterStatusRunning PostgresStatus = "Running" ClusterStatusInvalid PostgresStatus = "Invalid" )
possible values for PostgreSQL cluster statuses
func (PostgresStatus) String ¶
func (status PostgresStatus) String() string
func (PostgresStatus) Success ¶
func (status PostgresStatus) Success() bool
type Postgresql ¶
type Postgresql struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec PostgresSpec `json:"spec"`
Status PostgresStatus `json:"status,omitempty"`
Error error `json:"-"`
}
Postgresql defines PostgreSQL Custom Resource Definition Object.
func (*Postgresql) Clone ¶
func (p *Postgresql) Clone() *Postgresql
Clone makes a deepcopy of the Postgresql structure. The Error field is nulled-out, as there is no guarantee that the actual implementation of the error interface will not contain any private fields not-reachable to deepcopy. This should be ok, since Error is never read from a Kubernetes object.
func (*Postgresql) DeepCopy ¶
func (p *Postgresql) DeepCopy() *Postgresql
func (*Postgresql) DeepCopyInto ¶
func (p *Postgresql) DeepCopyInto(out *Postgresql)
func (*Postgresql) DeepCopyObject ¶
func (p *Postgresql) DeepCopyObject() runtime.Object
func (*Postgresql) UnmarshalJSON ¶
func (p *Postgresql) UnmarshalJSON(data []byte) error
UnmarshalJSON converts a JSON into the PostgreSQL object.
type PostgresqlList ¶
type PostgresqlList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Postgresql `json:"items"`
}
PostgresqlList defines a list of PostgreSQL clusters.
func (*PostgresqlList) DeepCopy ¶
func (pl *PostgresqlList) DeepCopy() *PostgresqlList
func (*PostgresqlList) DeepCopyInto ¶
func (pl *PostgresqlList) DeepCopyInto(out *PostgresqlList)
func (*PostgresqlList) DeepCopyObject ¶
func (pl *PostgresqlList) DeepCopyObject() runtime.Object
func (*PostgresqlList) UnmarshalJSON ¶
func (pl *PostgresqlList) UnmarshalJSON(data []byte) error
UnmarshalJSON converts a JSON into the PostgreSQL List object.
type PostgresqlParam ¶
type PostgresqlParam struct {
PgVersion string `json:"version"`
Parameters map[string]string `json:"parameters"`
}
PostgresqlParam describes PostgreSQL version and pairs of configuration parameter name - values.
type QueueDump ¶
type QueueDump struct {
Keys []string
List []interface{}
}
QueueDump describes cache.FIFO queue
type ResourceDescription ¶
ResourceDescription describes CPU and memory resources defined for a cluster.
type Resources ¶
type Resources struct {
ResourceRequest ResourceDescription `json:"requests,omitempty"`
ResourceLimits ResourceDescription `json:"limits,omitempty"`
}
Resources describes requests and limits for the cluster resouces.
type RoleOrigin ¶
type RoleOrigin int
RoleOrigin contains the code of the origin of a role
const ( RoleOriginUnknown RoleOrigin = iota RoleOriginManifest RoleOriginInfrastructure RoleOriginTeamsAPI RoleOriginSystem )
The rolesOrigin constant values should be sorted by the role priority.
func (RoleOrigin) String ¶
func (r RoleOrigin) String() string
type Sidecar ¶
type Sidecar struct {
Resources `json:"resources,omitempty"`
Name string `json:"name,omitempty"`
DockerImage string `json:"image,omitempty"`
Ports []v1.ContainerPort `json:"ports,omitempty"`
Env []v1.EnvVar `json:"env,omitempty"`
}
Sidecar defines a container to be run in the same pod as the Postgres container.
type UserFlags ¶
type UserFlags []string
UserFlags defines flags (such as superuser, nologin) that could be assigned to individual users
type UserSyncer ¶
type UserSyncer interface {
ProduceSyncRequests(dbUsers PgUserMap, newUsers PgUserMap) (req []PgSyncUserRequest)
ExecuteSyncRequests(req []PgSyncUserRequest, db *sql.DB) error
}
UserSyncer defines an interface for the implementations to sync users from the manifest to the DB.
type WorkerStatus ¶
type WorkerStatus struct {
CurrentCluster NamespacedName
CurrentProcess Process
}
WorkerStatus describes status of the worker