Documentation ¶
Index ¶
- Constants
- func AdminRoleSecretName(instanceName string) string
- func IsMaster(pod *corev1.Pod) bool
- func MasterService(instanceName string) string
- func NewK8sClient(kubeconfig string) (runtimeClient.Client, error)
- func PatroniService(instanceName string) string
- func PvcName(instanceName string, index int) string
- func StandbyRoleSecretName(instanceName string) string
- func WithVolumeSize(s string) func(*Postgresql)
- type Client
- func (c Client) CheckParameter(ctx context.Context, parameter, expectedValue string) error
- func (c Client) CollectionExists(ctx context.Context, collection string) bool
- func (c Client) Delete(ctx context.Context, entity, data string) error
- func (c Client) Read(ctx context.Context, tableName string) (string, error)
- func (c Client) UserExists(ctx context.Context, username string) (bool, error)
- func (c Client) Write(ctx context.Context, tableName, data string) error
- type Postgresql
- func (pg Postgresql) AddPreferredPodAntiAffinityTerm(weight int, at corev1.PodAffinityTerm)
- func (pg Postgresql) AddRequiredPodAntiAffinityTerm(at corev1.PodAffinityTerm)
- func (pg Postgresql) CheckPatroniLabelsAssigned(ctx context.Context, c runtimeClient.Client) (bool, error)
- func (pg Postgresql) ClusterStatus() string
- func (pg Postgresql) GetClientObject() runtimeClient.Object
- func (pg Postgresql) GetMasterLabels() map[string]string
- func (pg Postgresql) GetReplicaLabels() map[string]string
- func (pg Postgresql) Pods(ctx context.Context, k8sClient runtimeClient.Client) ([]corev1.Pod, error)
- func (pg Postgresql) SetTolerations(ts ...corev1.Toleration)
- func (pg Postgresql) StatefulSet(ctx context.Context, k8sClient runtimeClient.Client) (*appsv1.StatefulSet, error)
Constants ¶
const ( DBKey = "database" DBUsernameKey = "username" DBPasswordKey = "password" )
Variables ¶
This section is empty.
Functions ¶
func AdminRoleSecretName ¶
func MasterService ¶
func NewK8sClient ¶
func NewK8sClient(kubeconfig string) (runtimeClient.Client, error)
func PatroniService ¶
func StandbyRoleSecretName ¶
func WithVolumeSize ¶
func WithVolumeSize(s string) func(*Postgresql)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is responsible for opening up connections to the DSI in order to test the dataservice's behavior. Connections are opened for each method call to ensure a new and untainted connection to the database. This is important since leaving a connection open would break restore functionality.
func (Client) CheckParameter ¶
func (Client) CollectionExists ¶
func (Client) UserExists ¶
type Postgresql ¶
type Postgresql struct {
*pgv1beta3.Postgresql
}
func New ¶
func New(namespace, name string, replicas int32, opts ...func(*Postgresql)) *Postgresql
func NewEmpty ¶
func NewEmpty() Postgresql
func (Postgresql) AddPreferredPodAntiAffinityTerm ¶
func (pg Postgresql) AddPreferredPodAntiAffinityTerm(weight int, at corev1.PodAffinityTerm)
func (Postgresql) AddRequiredPodAntiAffinityTerm ¶
func (pg Postgresql) AddRequiredPodAntiAffinityTerm(at corev1.PodAffinityTerm)
func (Postgresql) CheckPatroniLabelsAssigned ¶
func (pg Postgresql) CheckPatroniLabelsAssigned(ctx context.Context, c runtimeClient.Client, ) (bool, error)
func (Postgresql) ClusterStatus ¶
func (pg Postgresql) ClusterStatus() string
func (Postgresql) GetClientObject ¶
func (pg Postgresql) GetClientObject() runtimeClient.Object
GetClientObject exposes the embedded PostgreSQL object to methods/functions that expect that type. We also need to set the APIVersion and Kind since Kubernetes will remove these fields when marshalling API objects.
func (Postgresql) GetMasterLabels ¶
func (pg Postgresql) GetMasterLabels() map[string]string
func (Postgresql) GetReplicaLabels ¶
func (pg Postgresql) GetReplicaLabels() map[string]string
func (Postgresql) Pods ¶
func (pg Postgresql) Pods(ctx context.Context, k8sClient runtimeClient.Client, ) ([]corev1.Pod, error)
Pods uses `k8sClient` to retrieve all the pods that belong to `pg`. The retrieval is based entirely on metadata labels, and doesn't check whether the pods actually belong to `pg` or to an older DSI with same namespace, name and kind. TODO: Improve robustness by checking that the pods actually belong to DSI.
func (Postgresql) SetTolerations ¶
func (pg Postgresql) SetTolerations(ts ...corev1.Toleration)
func (Postgresql) StatefulSet ¶
func (pg Postgresql) StatefulSet(ctx context.Context, k8sClient runtimeClient.Client, ) (*appsv1.StatefulSet, error)
TODO: make the K8s client a field of pg rather than something to pass to its functions.