Documentation ¶
Index ¶
- type Cluster
- func (c *Cluster) Create() error
- func (c *Cluster) Delete()
- func (c *Cluster) ExecCommand(podName *spec.NamespacedName, command ...string) (string, error)
- func (c *Cluster) GetCurrentProcess() spec.Process
- func (c *Cluster) GetEndpointMaster() *v1.Endpoints
- func (c *Cluster) GetEndpointReplica() *v1.Endpoints
- func (c *Cluster) GetPodDisruptionBudget() *policybeta1.PodDisruptionBudget
- func (c *Cluster) GetServiceMaster() *v1.Service
- func (c *Cluster) GetServiceReplica() *v1.Service
- func (c *Cluster) GetSpec() (*spec.Postgresql, error)
- func (c *Cluster) GetStatefulSet() *v1beta1.StatefulSet
- func (c *Cluster) GetStatus() *spec.ClusterStatus
- func (c *Cluster) Lock()
- func (c *Cluster) MigrateMasterPod(podName spec.NamespacedName) error
- func (c *Cluster) MigrateReplicaPod(podName spec.NamespacedName, fromNodeName string) error
- func (c *Cluster) NeedsRepair() (bool, spec.PostgresStatus)
- func (c *Cluster) ReceivePodEvent(event spec.PodEvent)
- func (c *Cluster) Run(stopCh <-chan struct{})
- func (c *Cluster) Switchover(curMaster *v1.Pod, candidate spec.NamespacedName) error
- func (c *Cluster) Sync(newSpec *spec.Postgresql) error
- func (c *Cluster) Unlock()
- func (c *Cluster) Update(oldSpec, newSpec *spec.Postgresql) error
- type Config
- type OAuthTokenGetter
- type PostgresRole
- type SecretOauthTokenGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct { spec.Postgresql Config KubeClient k8sutil.KubernetesClient //TODO: move clients to the better place? // contains filtered or unexported fields }
Cluster describes postgresql cluster
func New ¶
func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec spec.Postgresql, logger *logrus.Entry) *Cluster
New creates a new cluster. This function should be called from a controller.
func (*Cluster) Delete ¶
func (c *Cluster) Delete()
Delete deletes the cluster and cleans up all objects associated with it (including statefulsets). The deletion order here is somewhat significant, because Patroni, when running with the Kubernetes DCS, reuses the master's endpoint to store the leader related metadata. If we remove the endpoint before the pods, it will be re-created by the current master pod and will remain, obstructing the creation of the new cluster with the same name. Therefore, the endpoints should be deleted last.
func (*Cluster) ExecCommand ¶
ExecCommand executes arbitrary command inside the pod
func (*Cluster) GetCurrentProcess ¶
GetCurrentProcess provides name of the last process of the cluster
func (*Cluster) GetEndpointMaster ¶
GetEndpointMaster returns cluster's kubernetes master Endpoint
func (*Cluster) GetEndpointReplica ¶
GetEndpointReplica returns cluster's kubernetes master Endpoint
func (*Cluster) GetPodDisruptionBudget ¶
func (c *Cluster) GetPodDisruptionBudget() *policybeta1.PodDisruptionBudget
GetPodDisruptionBudget returns cluster's kubernetes PodDisruptionBudget
func (*Cluster) GetServiceMaster ¶
GetServiceMaster returns cluster's kubernetes master Service
func (*Cluster) GetServiceReplica ¶
GetServiceReplica returns cluster's kubernetes replica Service
func (*Cluster) GetStatefulSet ¶
func (c *Cluster) GetStatefulSet() *v1beta1.StatefulSet
GetStatefulSet returns cluster's kubernetes StatefulSet
func (*Cluster) GetStatus ¶
func (c *Cluster) GetStatus() *spec.ClusterStatus
GetStatus provides status of the cluster
func (*Cluster) MigrateMasterPod ¶
func (c *Cluster) MigrateMasterPod(podName spec.NamespacedName) error
MigrateMasterPod migrates master pod via failover to a replica
func (*Cluster) MigrateReplicaPod ¶
func (c *Cluster) MigrateReplicaPod(podName spec.NamespacedName, fromNodeName string) error
MigrateReplicaPod recreates pod on a new node
func (*Cluster) NeedsRepair ¶
func (c *Cluster) NeedsRepair() (bool, spec.PostgresStatus)
NeedsRepair returns true if the cluster should be included in the repair scan (based on its in-memory status).
func (*Cluster) ReceivePodEvent ¶
ReceivePodEvent is called back by the controller in order to add the cluster's pod event to the queue.
func (*Cluster) Run ¶
func (c *Cluster) Run(stopCh <-chan struct{})
Run starts the pod event dispatching for the given cluster.
func (*Cluster) Switchover ¶
Switchover does a switchover (via Patroni) to a candidate pod
type Config ¶
type Config struct { OpConfig config.Config RestConfig *rest.Config InfrastructureRoles map[string]spec.PgUser // inherited from the controller PodServiceAccount *v1.ServiceAccount PodServiceAccountRoleBinding *rbacv1beta1.RoleBinding }
Config contains operator-wide clients and configuration used from a cluster. TODO: remove struct duplication.
type OAuthTokenGetter ¶
type OAuthTokenGetter interface {
// contains filtered or unexported methods
}
OAuthTokenGetter provides the method for fetching OAuth tokens
type PostgresRole ¶
type PostgresRole string
PostgresRole describes role of the node
const ( // Master role Master PostgresRole = "master" // Replica role Replica PostgresRole = "replica" )
type SecretOauthTokenGetter ¶
type SecretOauthTokenGetter struct { OAuthTokenSecretName spec.NamespacedName // contains filtered or unexported fields }
SecretOauthTokenGetter enables fetching OAuth tokens by reading Kubernetes secrets