Documentation
¶
Overview ¶
Package common contains common utilities for the everest-operator.
Index ¶
- Constants
- Variables
- func BackupStoragePrefix(db *everestv1alpha1.DatabaseCluster) string
- func CreateOrUpdate(ctx context.Context, c client.Client, obj client.Object, patchSecretData bool) error
- func CreateOrUpdateSecretData(ctx context.Context, c client.Client, ...) error
- func GetBackupStorage(ctx context.Context, c client.Client, name, namespace string) (*everestv1alpha1.BackupStorage, error)
- func GetBackupStorageIndexInPGBackrestRepo(backupStorage *everestv1alpha1.BackupStorage, ...) int
- func GetDBMonitoringConfig(ctx context.Context, c client.Client, monitoringNs string, ...) (*everestv1alpha1.MonitoringConfig, error)
- func GetDatabaseEngine(ctx context.Context, c client.Client, name, namespace string) (*everestv1alpha1.DatabaseEngine, error)
- func GetOperatorVersion(ctx context.Context, c client.Client, name types.NamespacedName) (*version.Version, error)
- func GetSecretFromMonitoringConfig(ctx context.Context, c client.Client, ...) (string, error)
- func HandleDBBackupsCleanup(ctx context.Context, c client.Client, ...) (bool, error)
- func IsDatabaseClusterRestoreRunning(ctx context.Context, c client.Client, engineType everestv1alpha1.EngineType, ...) (bool, error)
- func IsOwnedBy(child, parent metav1.Object) bool
- func ListDatabaseClusterBackups(ctx context.Context, c client.Client, dbName, dbNs string) (*everestv1alpha1.DatabaseClusterBackupList, error)
- func ListDatabaseClusterRestores(ctx context.Context, c client.Client, dbName, dbNs string) (*everestv1alpha1.DatabaseClusterRestoreList, error)
- func PITRBucketName(db *everestv1alpha1.DatabaseCluster, bucket string) string
- func PITRStorageName(storageName string) string
- func ReconcileBackupStorageSecret(ctx context.Context, c client.Client, systemNs string, ...) error
- func ReconcileDBRestoreFromDataSource(ctx context.Context, c client.Client, ...) error
- func UpdateSecretData(ctx context.Context, c client.Client, ...) error
- func ValidatePitrRestoreSpec(dataSource everestv1alpha1.DataSource) error
- type ClusterType
Constants ¶
const ( // DefaultPMMClientImage is the default image for PMM client. DefaultPMMClientImage = "percona/pmm-client:2" // DBClusterRestoreDBClusterNameField is the field in the DatabaseClusterRestore CR. DBClusterRestoreDBClusterNameField = ".spec.dbClusterName" // DBClusterBackupDBClusterNameField is the field in the DatabaseClusterBackup CR. DBClusterBackupDBClusterNameField = ".spec.dbClusterName" // TopologyKeyHostname is the topology key for hostname. TopologyKeyHostname = "kubernetes.io/hostname" // PXCDeploymentName is the name of the Percona XtraDB Cluster operator deployment. PXCDeploymentName = "percona-xtradb-cluster-operator" // PSMDBDeploymentName is the name of the Percona Server for MongoDB operator deployment. PSMDBDeploymentName = "percona-server-mongodb-operator" // PGDeploymentName is the name of the Percona PostgreSQL operator deployment. PGDeploymentName = "percona-postgresql-operator" // PXCAPIGroup is the API group for Percona XtraDB Cluster. PXCAPIGroup = "pxc.percona.com" // PSMDBAPIGroup is the API group for Percona Server for MongoDB. PSMDBAPIGroup = "psmdb.percona.com" // PGAPIGroup is the API group for Percona PostgreSQL. PGAPIGroup = "pgv2.percona.com" // PerconaXtraDBClusterKind is the kind for Percona XtraDB Cluster. PerconaXtraDBClusterKind = "PerconaXtraDBCluster" // PerconaServerMongoDBKind is the kind for Percona Server for MongoDB. PerconaServerMongoDBKind = "PerconaServerMongoDB" // PerconaPGClusterKind is the kind for Percona PostgreSQL. PerconaPGClusterKind = "PerconaPGCluster" // ClusterTypeEKS represents the EKS cluster type. ClusterTypeEKS ClusterType = "eks" // ClusterTypeMinikube represents the Minikube cluster type. ClusterTypeMinikube ClusterType = "minikube" // LabelBackupStorageName is the label for backup storage name. LabelBackupStorageName = "percona.com/backup-storage-name" // EverestSecretsPrefix is the prefix for secrets created by Everest. EverestSecretsPrefix = "everest-secrets-" // DBBBackupStorageCleanupFinalizer is the finalizer for cleaning up DatabaseClusterBackup storage. DBBBackupStorageCleanupFinalizer = "everest.percona.com/dbb-storage-cleanup" // DBBackupCleanupFinalizer is the finalizer for cleaning up DatabaseClusterBackup. DBBackupCleanupFinalizer = "everest.percona.com/dbb-cleanup" )
Variables ¶
var ( // ErrPitrTypeIsNotSupported is an error for unsupported PITR type. ErrPitrTypeIsNotSupported = errors.New("unknown PITR type") // ErrPitrTypeLatest is an error for 'latest' being an unsupported PITR type. ErrPitrTypeLatest = errors.New("'latest' type is not supported by Everest yet") // ErrPitrEmptyDate is an error for missing PITR date. ErrPitrEmptyDate = errors.New("no date provided for PITR of type 'date'") // ErrPSMDBOneStorageRestriction is an error for using more than one storage for psmdb clusters. ErrPSMDBOneStorageRestriction = errors.New("using more than one storage is not allowed for psmdb clusters") )
var ExposeAnnotationsMap = map[ClusterType]map[string]string{ ClusterTypeEKS: { "service.beta.kubernetes.io/aws-load-balancer-type": "nlb", }, }
ExposeAnnotationsMap is a map of annotations needed for exposing the database cluster.
Functions ¶
func BackupStoragePrefix ¶
func BackupStoragePrefix(db *everestv1alpha1.DatabaseCluster) string
BackupStoragePrefix returns the prefix for the backup storage.
func CreateOrUpdate ¶
func CreateOrUpdate( ctx context.Context, c client.Client, obj client.Object, patchSecretData bool, ) error
CreateOrUpdate creates or updates a resource. With patchSecretData the new secret Data is applied on top of the original secret's Data.
func CreateOrUpdateSecretData ¶
func CreateOrUpdateSecretData( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, secretName string, data map[string][]byte, ) error
CreateOrUpdateSecretData creates or updates the data of a secret. When updating, it only changes the values of the keys specified in the data map. All other keys are left untouched, so it's not possible to delete a key.
func GetBackupStorage ¶
func GetBackupStorage( ctx context.Context, c client.Client, name, namespace string, ) (*everestv1alpha1.BackupStorage, error)
GetBackupStorage returns a BackupStorage object with the specified name and namespace.
func GetBackupStorageIndexInPGBackrestRepo ¶
func GetBackupStorageIndexInPGBackrestRepo( backupStorage *everestv1alpha1.BackupStorage, repos []crunchyv1beta1.PGBackRestRepo, ) int
GetBackupStorageIndexInPGBackrestRepo returns the index of the backup storage in the pgbackrest repo list.
func GetDBMonitoringConfig ¶
func GetDBMonitoringConfig( ctx context.Context, c client.Client, monitoringNs string, database *everestv1alpha1.DatabaseCluster, ) (*everestv1alpha1.MonitoringConfig, error)
GetDBMonitoringConfig returns the MonitoringConfig object for the given DatabaseCluster object.
func GetDatabaseEngine ¶
func GetDatabaseEngine(ctx context.Context, c client.Client, name, namespace string) (*everestv1alpha1.DatabaseEngine, error)
GetDatabaseEngine gets the DatabaseEngine object with the specified name and namespace.
func GetOperatorVersion ¶
func GetOperatorVersion( ctx context.Context, c client.Client, name types.NamespacedName, ) (*version.Version, error)
GetOperatorVersion returns the version of the operator running in the cluster for the specified deployment name and namespace.
func GetSecretFromMonitoringConfig ¶
func GetSecretFromMonitoringConfig( ctx context.Context, c client.Client, monitoring *everestv1alpha1.MonitoringConfig, ns string, ) (string, error)
GetSecretFromMonitoringConfig gets the secret data from the MonitoringConfig.
func HandleDBBackupsCleanup ¶
func HandleDBBackupsCleanup( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, ) (bool, error)
HandleDBBackupsCleanup handles the cleanup of the dbbackup objects. Returns true if cleanup is complete.
func IsDatabaseClusterRestoreRunning ¶
func IsDatabaseClusterRestoreRunning( ctx context.Context, c client.Client, engineType everestv1alpha1.EngineType, dbName, dbNs string, ) (bool, error)
IsDatabaseClusterRestoreRunning returns true if a restore is running for the specified database, otherwise false.
func IsOwnedBy ¶
IsOwnedBy checks if the child object is owned by the parent object. Returns true if child has an owner reference to the parents.
func ListDatabaseClusterBackups ¶
func ListDatabaseClusterBackups( ctx context.Context, c client.Client, dbName, dbNs string, ) (*everestv1alpha1.DatabaseClusterBackupList, error)
ListDatabaseClusterBackups returns a list of DatabaseClusterBackup objects for the DatabaseCluster with the specified name and namespace.
func ListDatabaseClusterRestores ¶
func ListDatabaseClusterRestores( ctx context.Context, c client.Client, dbName, dbNs string, ) (*everestv1alpha1.DatabaseClusterRestoreList, error)
ListDatabaseClusterRestores lists the DatabaseClusterRestores for the database specified by the name and namespace.
func PITRBucketName ¶
func PITRBucketName(db *everestv1alpha1.DatabaseCluster, bucket string) string
PITRBucketName returns the name of the bucket for the point-in-time recovery backups.
func PITRStorageName ¶
PITRStorageName returns the name of the storage for the point-in-time recovery backups.
func ReconcileBackupStorageSecret ¶
func ReconcileBackupStorageSecret( ctx context.Context, c client.Client, systemNs string, backupStorage *everestv1alpha1.BackupStorage, database *everestv1alpha1.DatabaseCluster, ) error
ReconcileBackupStorageSecret reconciles the backup storage secret.
func ReconcileDBRestoreFromDataSource ¶
func ReconcileDBRestoreFromDataSource( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, ) error
ReconcileDBRestoreFromDataSource reconciles the DatabaseClusterRestore object based on the DataSource field of the DatabaseCluster.
func UpdateSecretData ¶
func UpdateSecretData( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, secretName string, data map[string][]byte, ) error
UpdateSecretData updates the data of a secret. It only changes the values of the keys specified in the data map. All other keys are left untouched, so it's not possible to delete a key.
func ValidatePitrRestoreSpec ¶
func ValidatePitrRestoreSpec(dataSource everestv1alpha1.DataSource) error
ValidatePitrRestoreSpec validates the PITR restore spec.
Types ¶
type ClusterType ¶
type ClusterType string
ClusterType represents the type of the cluster.
func GetClusterType ¶
GetClusterType returns the type of the cluster on which this operator is running.