Documentation ¶
Index ¶
- Constants
- Variables
- func CreateBackrestPVCSnippet(backRestPVCName string) string
- func CreateBackrestRepoSecrets(clientset *kubernetes.Clientset, backrestRepoConfig BackrestRepoConfig) error
- func CreateBackupPVCSnippet(backupPVCName string) string
- func CreatePVCSnippet(storageType string, PVCName string) string
- func CreateSecContext(fsGroup string, suppGroup string) string
- func CreateSecret(clientset *kubernetes.Clientset, ...) error
- func CreateUserSecret(clientset *kubernetes.Clientset, ...) error
- func DrainDeployment(clientset *kubernetes.Clientset, name string, namespace string) error
- func ExecPolicy(clientset *kubernetes.Clientset, restclient *rest.RESTClient, ...) error
- func GeneratePassword(length int) string
- func GenerateRandString(length int) string
- func GeneratedPasswordLength(configuredPasswordLength string) int
- func GetLabels(name, clustername string, replica bool) string
- func GetMD5HashForAuthFile(text string) string
- func GetPasswordFromSecret(clientset *kubernetes.Clientset, namespace string, secretName string) (string, string, error)
- func GetPod(clientset *kubernetes.Clientset, deploymentName, namespace string) (*v1.Pod, error)
- func GetPolicySQL(restclient *rest.RESTClient, namespace, policyName string) (string, error)
- func GetPreferredNodes(clientset *kubernetes.Clientset, selector, namespace string) ([]string, error)
- func GetSecretPassword(clientset *kubernetes.Clientset, db, suffix, Namespace string) (string, error)
- func IsAutofailEnabled(cluster *crv1.Pgcluster) bool
- func IsStringOneOf(testVal string, acceptedVals ...string) bool
- func IsValidBackrestStorageType(storageType string) bool
- func NewClient(cfg *rest.Config) (*rest.RESTClient, *runtime.Scheme, error)
- func Patch(restclient *rest.RESTClient, path string, value string, resource string, ...) error
- func PatchClusterCRD(restclient *rest.RESTClient, labelMap map[string]string, ...) error
- func RandStringBytesRmndr(n int) string
- func ScaleDeployment(clientset *kubernetes.Clientset, deploymentName, namespace string, ...) error
- func ToggleAutoFailover(clientset *kubernetes.Clientset, enable bool, pghaScope, namespace string) error
- func UpdatePolicyLabels(clientset *kubernetes.Clientset, clusterName string, namespace string, ...) error
- func UpdateUserSecret(clientset *kubernetes.Clientset, ...) error
- func ValidateBackrestStorageTypeOnBackupRestore(newBackRestStorageType, currentBackRestStorageType string, restore bool) error
- func ValidatePolicy(restclient *rest.RESTClient, namespace string, policyName string) error
- func WaitUntilDeploymentIsDeleted(clientset *kubernetes.Clientset, depname string, timeout time.Duration, ...) error
- func WaitUntilPod(clientset *kubernetes.Clientset, lo meta_v1.ListOptions, podPhase v1.PodPhase, ...) error
- func WaitUntilPodIsDeleted(clientset *kubernetes.Clientset, podname string, timeout time.Duration, ...) error
- type AWSS3Secret
- type BackrestRepoConfig
- type CloneClusterSecrets
- type CloneTask
- type InstanceReplicationInfo
- type ReplicationStatusRequest
- type ReplicationStatusResponse
- type ThingSpec
Constants ¶
const ( // DefaultGeneratedPasswordLength is the length of what a generated password // is if it's not set in the pgo.yaml file, and to create some semblance of // consistency DefaultGeneratedPasswordLength = 24 )
Variables ¶
var ( // ErrMissingConfigAnnotation represents an error thrown when the 'config' annotation is found // to be missing from the 'config' configMap created to store cluster-wide configuration ErrMissingConfigAnnotation error = errors.New("'config' annotation missing from cluster " + "configutation") )
Functions ¶
func CreateBackrestPVCSnippet ¶
CreateBackrestPVCSnippet
func CreateBackrestRepoSecrets ¶
func CreateBackrestRepoSecrets(clientset *kubernetes.Clientset, backrestRepoConfig BackrestRepoConfig) error
CreateBackrestRepoSecrets creates the secrets required to manage the pgBackRest repo container
func CreateBackupPVCSnippet ¶
CreateBackupPVCSnippet generates the PVC definition fragment
func CreatePVCSnippet ¶
CreatePVCSnippet generates the PVC json snippet
func CreateSecContext ¶
CreateSecContext will generate the JSON security context fragment for a storage type
func CreateSecret ¶
func CreateSecret(clientset *kubernetes.Clientset, db, secretName, username, password, namespace string) error
CreateSecret create the secret, user, and primary secrets
func CreateUserSecret ¶
func CreateUserSecret(clientset *kubernetes.Clientset, clustername, username, password, namespace string, passwordLength int) error
CreateUserSecret will create a new secret holding a user credential
func DrainDeployment ¶
func DrainDeployment(clientset *kubernetes.Clientset, name string, namespace string) error
DrainDeployment will drain a deployment to 0 pods
func ExecPolicy ¶
func ExecPolicy(clientset *kubernetes.Clientset, restclient *rest.RESTClient, restconfig *rest.Config, namespace string, policyName string, serviceName string) error
ExecPolicy execute a sql policy against a cluster
func GeneratePassword ¶
GeneratePassword generate a password of a given length
func GenerateRandString ¶
GenerateRandString generate a rand lowercase string of a given length
func GeneratedPasswordLength ¶
GeneratedPasswordLength returns the value for what the length of a randomly generated password should be. It first determines if the user provided this value via a configuration file, and if not and/or the value is invalid, uses the default value
func GetPasswordFromSecret ¶
func GetPasswordFromSecret(clientset *kubernetes.Clientset, namespace string, secretName string) (string, string, error)
GetPasswordFromSecret will fetch the username, password from a user secret
func GetPolicySQL ¶
func GetPolicySQL(restclient *rest.RESTClient, namespace, policyName string) (string, error)
GetPolicySQL returns the SQL string from a policy
func GetPreferredNodes ¶
func GetPreferredNodes(clientset *kubernetes.Clientset, selector, namespace string) ([]string, error)
func GetSecretPassword ¶
func GetSecretPassword(clientset *kubernetes.Clientset, db, suffix, Namespace string) (string, error)
GetSecretPassword ...
func IsAutofailEnabled ¶
IsAutofailEnabled - returns true if autofail label is set to true, false if not.
func IsStringOneOf ¶
IsStringOneOf tests to see string testVal is included in the list of strings provided using acceptedVals
func IsValidBackrestStorageType ¶
IsValidBackrestStorageType determines if the storage source string contains valid pgBackRest storage type values
func Patch ¶
func Patch(restclient *rest.RESTClient, path string, value string, resource string, name string, namespace string) error
Patch will patch a particular resource
func PatchClusterCRD ¶
func PatchClusterCRD(restclient *rest.RESTClient, labelMap map[string]string, oldCrd *crv1.Pgcluster, namespace string) error
PatchClusterCRD patches the pgcluster CRD
func ScaleDeployment ¶
func ScaleDeployment(clientset *kubernetes.Clientset, deploymentName, namespace string, replicaCount int) error
ScaleDeployment will increase the number of pods in a deployment
func ToggleAutoFailover ¶
func ToggleAutoFailover(clientset *kubernetes.Clientset, enable bool, pghaScope, namespace string) error
ToggleAutoFailover enables or disables autofailover for a cluster. Disabling autofailover means "pausing" Patroni, which will result in Patroni stepping aside from managing the cluster. This will effectively cause Patroni to stop responding to failures or other database activities, e.g. it will not attempt to start the database when stopped to perform maintenance
func UpdatePolicyLabels ¶
func UpdatePolicyLabels(clientset *kubernetes.Clientset, clusterName string, namespace string, newLabels map[string]string) error
UpdatePolicyLabels ...
func UpdateUserSecret ¶
func UpdateUserSecret(clientset *kubernetes.Clientset, clustername, username, password, namespace string, passwordLength int) error
UpdateUserSecret updates a user secret with a new password
func ValidateBackrestStorageTypeOnBackupRestore ¶
func ValidateBackrestStorageTypeOnBackupRestore(newBackRestStorageType, currentBackRestStorageType string, restore bool) error
ValidateBackrestStorageTypeOnBackupRestore checks to see if the pgbackrest storage type provided when performing either pgbackrest backup or restore is valid. This includes ensuring the value provided is a valid storage type (e.g. "s3" and/or "local"). This also includes ensuring the storage type specified (e.g. "s3" or "local") is enabled in the current cluster. And finally, validation is ocurring for a restore, the ensure only one storage type is selected.
func ValidatePolicy ¶
func ValidatePolicy(restclient *rest.RESTClient, namespace string, policyName string) error
ValidatePolicy tests to see if a policy exists
func WaitUntilDeploymentIsDeleted ¶
func WaitUntilDeploymentIsDeleted(clientset *kubernetes.Clientset, depname string, timeout time.Duration, namespace string) error
WaitUntilDeploymentIsDeleted timeout := time.Minute
func WaitUntilPod ¶
func WaitUntilPod(clientset *kubernetes.Clientset, lo meta_v1.ListOptions, podPhase v1.PodPhase, timeout time.Duration, namespace string) error
WaitUntilPod ... podPhase is v1.PodRunning timeout := time.Minute
func WaitUntilPodIsDeleted ¶
func WaitUntilPodIsDeleted(clientset *kubernetes.Clientset, podname string, timeout time.Duration, namespace string) error
WaitUntilPodIsDeleted timeout := time.Minute
Types ¶
type AWSS3Secret ¶
type AWSS3Secret struct { AWSS3Key string `yaml:"aws-s3-key"` AWSS3KeySecret string `yaml:"aws-s3-key-secret"` }
AWSS3Secret is a representation of the yaml structure found in aws-s3-credentials.yaml for providing an AWS S3 key and key secret
func GetS3CredsFromBackrestRepoSecret ¶
func GetS3CredsFromBackrestRepoSecret(clientset *kubernetes.Clientset, clusterName, namespace string) (s3Secret AWSS3Secret, err error)
GetS3CredsFromBackrestRepoSecret retrieves the AWS S3 credentials, i.e. the key and key secret, from a specific cluster's backrest repo secret
type BackrestRepoConfig ¶
type BackrestRepoConfig struct { BackrestS3Key string BackrestS3KeySecret string ClusterName string ClusterNamespace string OperatorNamespace string }
BackrestRepoConfig represents the configuration required to created backrest repo secrets
type CloneClusterSecrets ¶
type CloneClusterSecrets struct { // any additional selectors that can be added to the query that is made AdditionalSelectors []string // The Kubernetes Clientset used to make API calls to Kubernetes` ClientSet *kubernetes.Clientset // The Namespace that the clusters are in Namespace string // The name of the PostgreSQL cluster that the secrets are originating from SourceClusterName string // The name of the PostgreSQL cluster that we are copying the secrets to TargetClusterName string }
CloneClusterSecrets will copy the secrets from a cluster into the secrets of another cluster
func (CloneClusterSecrets) Clone ¶
func (cs CloneClusterSecrets) Clone() error
Clone performs the actual clone of the secrets between PostgreSQL clusters
type CloneTask ¶
type CloneTask struct { PGOUser string SourceClusterName string TargetClusterName string TaskStepLabel string TaskType string Timestamp time.Time WorkflowID string BackrestStorageSource string }
CloneTask allows you to create a Pgtask CRD with the appropriate options
type InstanceReplicationInfo ¶
type InstanceReplicationInfo struct { Name string Node string ReplicationLag int Status string Timeline int }
InstanceReplicationInfo is the user friendly information for the current status of key replication metrics for a PostgreSQL instance
type ReplicationStatusResponse ¶
type ReplicationStatusResponse struct {
Instances []InstanceReplicationInfo
}
func ReplicationStatus ¶
func ReplicationStatus(request ReplicationStatusRequest) (ReplicationStatusResponse, error)
ReplicationStatus is responsible for retrieving and returning the replication information about the status of the replicas in a PostgreSQL cluster. It executes into a single replica pod and leverages the functionality of Patroni for getting the key metrics that are appropriate to help the user understand the current state of their replicas.
Statistics include: the current node the replica is on, if it is up, the replication lag, etc.