kubernetes

package
v0.10.0-rc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package kubernetes ...

Package kubernetes ...

Package kubernetes ...

Package kubernetes ...

Package kubernetes provides functionality for kubernetes.

Package kubernetes ...

Package kubernetes ...

Package kubernetes ...

Package kubernetes ...

Index

Constants

View Source
const (
	// ClusterTypeUnknown is for unknown type.
	ClusterTypeUnknown ClusterType = "unknown"
	// ClusterTypeMinikube is for minikube.
	ClusterTypeMinikube ClusterType = "minikube"
	// ClusterTypeEKS is for EKS.
	ClusterTypeEKS ClusterType = "eks"
	// ClusterTypeGeneric is a generic type.
	ClusterTypeGeneric ClusterType = "generic"

	// EverestOperatorDeploymentName is the name of the deployment for everest operator.
	EverestOperatorDeploymentName = "everest-operator-controller-manager"

	// EverestDBNamespacesEnvVar is the name of the environment variable that
	// contains the list of monitored namespaces.
	EverestDBNamespacesEnvVar = "DB_NAMESPACES"

	// OLMNamespace is the namespace where OLM is installed.
	OLMNamespace = "everest-olm"

	// APIVersionCoreosV1 constant for some API requests.
	APIVersionCoreosV1 = "operators.coreos.com/v1"
)

Variables

View Source
var (
	// ErrEmptyVersionTag Got an empty version tag from GitHub API.
	ErrEmptyVersionTag = errors.New("got an empty version tag from Github")
)
View Source
var ErrOperatorNotInstalled = fmt.Errorf("operatorNotInstalled")

ErrOperatorNotInstalled is returned when an operator is not installed.

Functions

func IsContainerInState

func IsContainerInState(containerStatuses []corev1.ContainerStatus, state ContainerState) bool

IsContainerInState returns true if container is in give state, otherwise false.

func IsNodeInCondition

func IsNodeInCondition(node corev1.Node, conditionType corev1.NodeConditionType) bool

IsNodeInCondition returns true if node's condition given as an argument has status "True". Otherwise it returns false.

Types

type ClusterType

type ClusterType string

ClusterType defines type of cluster.

type ContainerState

type ContainerState string

ContainerState describes container's state - waiting, running, terminated.

const (
	// ContainerStateWaiting represents a state when container requires some
	// operations being done in order to complete start up.
	ContainerStateWaiting ContainerState = "waiting"
	// ContainerStateTerminated indicates that container began execution and
	// then either ran to completion or failed for some reason.
	ContainerStateTerminated ContainerState = "terminated"
)

type InstallOperatorRequest

type InstallOperatorRequest struct {
	Namespace              string
	Name                   string
	OperatorGroup          string
	CatalogSource          string
	CatalogSourceNamespace string
	Channel                string
	InstallPlanApproval    olmv1alpha1.Approval
	StartingCSV            string
	TargetNamespaces       []string
	SubscriptionConfig     *olmv1alpha1.SubscriptionConfig
}

InstallOperatorRequest holds the fields to make an operator install request.

type Kubernetes

type Kubernetes struct {
	// contains filtered or unexported fields
}

Kubernetes is a client for Kubernetes.

func New

func New(kubeconfigPath string, l *zap.SugaredLogger) (*Kubernetes, error)

New returns new Kubernetes object.

func NewEmpty

func NewEmpty(l *zap.SugaredLogger) *Kubernetes

NewEmpty returns new Kubernetes object.

func NewInCluster

func NewInCluster(l *zap.SugaredLogger) (*Kubernetes, error)

NewInCluster creates a new kubernetes client using incluster authentication.

func (*Kubernetes) ApplyObject

func (k *Kubernetes) ApplyObject(obj runtime.Object) error

ApplyObject applies object.

func (*Kubernetes) ApproveInstallPlan added in v0.10.0

func (k *Kubernetes) ApproveInstallPlan(ctx context.Context, namespace, installPlanName string) (bool, error)

ApproveInstallPlan approves an install plan.

func (*Kubernetes) ClusterName

func (k *Kubernetes) ClusterName() string

ClusterName returns the name of the k8s cluster.

func (*Kubernetes) Config

func (k *Kubernetes) Config() *rest.Config

Config returns *rest.Config.

func (*Kubernetes) CreateBackupStorage

func (k *Kubernetes) CreateBackupStorage(ctx context.Context, storage *everestv1alpha1.BackupStorage) error

CreateBackupStorage returns backup storages by provided name.

func (*Kubernetes) CreateClusterRole

func (k *Kubernetes) CreateClusterRole(name string, rules []rbac.PolicyRule) error

CreateClusterRole creates a new cluster role.

func (*Kubernetes) CreateClusterRoleBinding

func (k *Kubernetes) CreateClusterRoleBinding(namespace, name, roleName, serviceAccountName string) error

CreateClusterRoleBinding binds a cluster role to a service account.

func (*Kubernetes) CreateDatabaseCluster

func (k *Kubernetes) CreateDatabaseCluster(cluster *everestv1alpha1.DatabaseCluster) error

CreateDatabaseCluster creates database cluster.

func (*Kubernetes) CreateMonitoringConfig

func (k *Kubernetes) CreateMonitoringConfig(ctx context.Context, storage *everestv1alpha1.MonitoringConfig) error

CreateMonitoringConfig returns monitoring configs by provided name.

func (*Kubernetes) CreateNamespace

func (k *Kubernetes) CreateNamespace(name string) error

CreateNamespace creates a new namespace.

func (*Kubernetes) CreateOperatorGroup

func (k *Kubernetes) CreateOperatorGroup(ctx context.Context, name, namespace string, targetNamespaces []string) error

CreateOperatorGroup creates operator group in the given namespace.

func (*Kubernetes) CreatePMMSecret

func (k *Kubernetes) CreatePMMSecret(namespace, secretName string, secrets map[string][]byte) error

CreatePMMSecret creates pmm secret in kubernetes.

func (*Kubernetes) CreateRestore

func (k *Kubernetes) CreateRestore(restore *everestv1alpha1.DatabaseClusterRestore) error

CreateRestore creates a restore.

func (*Kubernetes) CreateRole

func (k *Kubernetes) CreateRole(namespace, name string, rules []rbac.PolicyRule) error

CreateRole creates a new role.

func (*Kubernetes) CreateRoleBinding

func (k *Kubernetes) CreateRoleBinding(namespace, name, roleName, serviceAccountName string) error

CreateRoleBinding binds a role to a service account.

func (*Kubernetes) CreateSecret

func (k *Kubernetes) CreateSecret(ctx context.Context, secret *corev1.Secret) (*corev1.Secret, error)

CreateSecret creates a secret.

func (*Kubernetes) CreateServiceAccount

func (k *Kubernetes) CreateServiceAccount(name, namespace string) error

CreateServiceAccount creates a new service account.

func (*Kubernetes) CreateServiceAccountToken

func (k *Kubernetes) CreateServiceAccountToken(serviceAccountName, secretName, namespace string) error

CreateServiceAccountToken creates a new secret with service account token.

func (*Kubernetes) DeleteAllMonitoringResources

func (k *Kubernetes) DeleteAllMonitoringResources(ctx context.Context, namespace string) error

DeleteAllMonitoringResources deletes all resources related to monitoring from k8s cluster. If namespace is empty, a default namespace is used.

func (*Kubernetes) DeleteBackupStorage

func (k *Kubernetes) DeleteBackupStorage(ctx context.Context, namespace, name string) error

DeleteBackupStorage returns backup storages by provided name.

func (*Kubernetes) DeleteClusterServiceVersion

func (k *Kubernetes) DeleteClusterServiceVersion(
	ctx context.Context,
	key types.NamespacedName,
) error

DeleteClusterServiceVersion deletes a ClusterServiceVersion.

func (*Kubernetes) DeleteDatabaseCluster

func (k *Kubernetes) DeleteDatabaseCluster(ctx context.Context, namespace, name string) error

DeleteDatabaseCluster deletes database cluster.

func (*Kubernetes) DeleteEverest

func (k *Kubernetes) DeleteEverest(ctx context.Context, namespace string, version *goversion.Version) error

DeleteEverest downloads the manifest file and deletes it from provisioned k8s cluster.

func (*Kubernetes) DeleteMonitoringConfig

func (k *Kubernetes) DeleteMonitoringConfig(ctx context.Context, namespace, name string) error

DeleteMonitoringConfig returns monitoring configs by provided name.

func (*Kubernetes) DeleteNamespace

func (k *Kubernetes) DeleteNamespace(ctx context.Context, name string) error

DeleteNamespace deletes a namespace.

func (*Kubernetes) DeleteObject

func (k *Kubernetes) DeleteObject(obj runtime.Object) error

DeleteObject deletes an object.

func (*Kubernetes) DeleteSecret

func (k *Kubernetes) DeleteSecret(ctx context.Context, namespace, name string) error

DeleteSecret deletes a secret.

func (*Kubernetes) GenerateKubeConfigWithToken

func (k *Kubernetes) GenerateKubeConfigWithToken(user string, secret *corev1.Secret) (string, error)

GenerateKubeConfigWithToken returns a kubeconfig with the token as provided in the secret.

func (*Kubernetes) GetAllClusterResources

func (k *Kubernetes) GetAllClusterResources(
	ctx context.Context, clusterType ClusterType, volumes *corev1.PersistentVolumeList,
) (uint64, uint64, uint64, error)

GetAllClusterResources goes through all cluster nodes and sums their allocatable resources.

func (*Kubernetes) GetBackupStorage

func (k *Kubernetes) GetBackupStorage(ctx context.Context, namespace, name string) (*everestv1alpha1.BackupStorage, error)

GetBackupStorage returns backup storages by provided name.

func (*Kubernetes) GetClusterServiceVersion

func (k *Kubernetes) GetClusterServiceVersion(
	ctx context.Context,
	key types.NamespacedName,
) (*olmv1alpha1.ClusterServiceVersion, error)

GetClusterServiceVersion retrieves a ClusterServiceVersion by namespaced name.

func (*Kubernetes) GetClusterType

func (k *Kubernetes) GetClusterType(ctx context.Context) (ClusterType, error)

GetClusterType tries to guess the underlying kubernetes cluster based on storage class.

func (*Kubernetes) GetConsumedCPUAndMemory

func (k *Kubernetes) GetConsumedCPUAndMemory(ctx context.Context, namespace string) (
	cpuMillis uint64, memoryBytes uint64, err error,
)

GetConsumedCPUAndMemory returns consumed CPU and Memory in given namespace. If namespace is empty, it tries to get them from all namespaces.

func (*Kubernetes) GetConsumedDiskBytes

func (k *Kubernetes) GetConsumedDiskBytes(
	_ context.Context, clusterType ClusterType, volumes *corev1.PersistentVolumeList,
) (uint64, error)

GetConsumedDiskBytes returns consumed bytes. The strategy differs based on k8s cluster type.

func (*Kubernetes) GetDBNamespaces

func (k *Kubernetes) GetDBNamespaces(ctx context.Context, namespace string) ([]string, error)

GetDBNamespaces returns a list of namespaces that are monitored by the Everest operator.

func (*Kubernetes) GetDBaaSOperatorVersion

func (k *Kubernetes) GetDBaaSOperatorVersion(ctx context.Context) (string, error)

GetDBaaSOperatorVersion parses DBaaS operator version from operator deployment.

func (*Kubernetes) GetDatabaseCluster

func (k *Kubernetes) GetDatabaseCluster(ctx context.Context, namespace, name string) (*everestv1alpha1.DatabaseCluster, error)

GetDatabaseCluster returns database clusters by provided name.

func (*Kubernetes) GetDatabaseClusterBackup

func (k *Kubernetes) GetDatabaseClusterBackup(ctx context.Context, namespace, name string) (*everestv1alpha1.DatabaseClusterBackup, error)

GetDatabaseClusterBackup returns database cluster backup by name.

func (*Kubernetes) GetDatabaseClusterRestore

func (k *Kubernetes) GetDatabaseClusterRestore(ctx context.Context, namespace, name string) (*everestv1alpha1.DatabaseClusterRestore, error)

GetDatabaseClusterRestore returns database cluster restore by name.

func (*Kubernetes) GetDatabaseEngine

func (k *Kubernetes) GetDatabaseEngine(ctx context.Context, namespace, name string) (*everestv1alpha1.DatabaseEngine, error)

GetDatabaseEngine returns database clusters by provided name.

func (*Kubernetes) GetDefaultStorageClassName

func (k *Kubernetes) GetDefaultStorageClassName(ctx context.Context) (string, error)

GetDefaultStorageClassName returns first storageClassName from kubernetes cluster.

func (*Kubernetes) GetDeployment

func (k *Kubernetes) GetDeployment(ctx context.Context, name, namespace string) (*appsv1.Deployment, error)

GetDeployment returns k8s deployment by provided name and namespace.

func (*Kubernetes) GetEvents

func (k *Kubernetes) GetEvents(ctx context.Context, pod string) ([]string, error)

GetEvents returns pod's events as a slice of strings.

func (*Kubernetes) GetEverestID

func (k *Kubernetes) GetEverestID(ctx context.Context) (string, error)

GetEverestID returns the ID of the namespace where everest is deployed.

func (*Kubernetes) GetLogs

func (k *Kubernetes) GetLogs(
	ctx context.Context,
	containerStatuses []corev1.ContainerStatus,
	pod,
	container string,
) ([]string, error)

GetLogs returns logs.

func (*Kubernetes) GetMonitoringConfig

func (k *Kubernetes) GetMonitoringConfig(ctx context.Context, namespace, name string) (*everestv1alpha1.MonitoringConfig, error)

GetMonitoringConfig returns monitoring configs by provided name.

func (*Kubernetes) GetMonitoringConfigsBySecretName

func (k *Kubernetes) GetMonitoringConfigsBySecretName(
	ctx context.Context, namespace, secretName string,
) ([]*everestv1alpha1.MonitoringConfig, error)

GetMonitoringConfigsBySecretName returns a list of monitoring configs which use the provided secret name.

func (*Kubernetes) GetNamespace

func (k *Kubernetes) GetNamespace(ctx context.Context, name string) (*corev1.Namespace, error)

GetNamespace returns a namespace.

func (*Kubernetes) GetPSMDBOperatorVersion

func (k *Kubernetes) GetPSMDBOperatorVersion(ctx context.Context) (string, error)

GetPSMDBOperatorVersion parses PSMDB operator version from operator deployment.

func (*Kubernetes) GetPXCOperatorVersion

func (k *Kubernetes) GetPXCOperatorVersion(ctx context.Context) (string, error)

GetPXCOperatorVersion parses PXC operator version from operator deployment.

func (*Kubernetes) GetPersistentVolumes

func (k *Kubernetes) GetPersistentVolumes(ctx context.Context) (*corev1.PersistentVolumeList, error)

GetPersistentVolumes returns list of persistent volumes.

func (*Kubernetes) GetPods

func (k *Kubernetes) GetPods(ctx context.Context, namespace string, labelSelector *metav1.LabelSelector) (*corev1.PodList, error)

GetPods returns list of pods.

func (*Kubernetes) GetSecret

func (k *Kubernetes) GetSecret(ctx context.Context, namespace, name string) (*corev1.Secret, error)

GetSecret returns a secret by name.

func (*Kubernetes) GetServerVersion

func (k *Kubernetes) GetServerVersion() (*version.Info, error)

GetServerVersion returns server version.

func (*Kubernetes) GetStorageClasses

func (k *Kubernetes) GetStorageClasses(ctx context.Context) (*storagev1.StorageClassList, error)

GetStorageClasses returns list of storage classes.

func (*Kubernetes) GetWorkerNodes

func (k *Kubernetes) GetWorkerNodes(ctx context.Context) ([]corev1.Node, error)

GetWorkerNodes returns list of cluster workers nodes.

func (*Kubernetes) InstallEverest

func (k *Kubernetes) InstallEverest(ctx context.Context, namespace string, version *goversion.Version) error

InstallEverest downloads the manifest file and applies it against provisioned k8s cluster.

func (*Kubernetes) InstallOLMOperator

func (k *Kubernetes) InstallOLMOperator(ctx context.Context, upgrade bool) error

InstallOLMOperator installs OLM operator.

func (*Kubernetes) InstallOperator

func (k *Kubernetes) InstallOperator(ctx context.Context, req InstallOperatorRequest) error

InstallOperator installs an operator via OLM.

func (*Kubernetes) InstallPerconaCatalog

func (k *Kubernetes) InstallPerconaCatalog(ctx context.Context, version *goversion.Version) error

InstallPerconaCatalog installs percona catalog and ensures that packages are available.

func (*Kubernetes) IsBackupStorageUsed

func (k *Kubernetes) IsBackupStorageUsed(ctx context.Context, namespace, backupStorageName string) (bool, error)

IsBackupStorageUsed checks that a backup storage by provided name is used across k8s cluster.

func (*Kubernetes) IsMonitoringConfigUsed

func (k *Kubernetes) IsMonitoringConfigUsed(ctx context.Context, namespace, monitoringConfigName string) (bool, error)

IsMonitoringConfigUsed checks that a backup storage by provided name is used across k8s cluster.

func (*Kubernetes) ListBackupStorages

func (k *Kubernetes) ListBackupStorages(ctx context.Context, namespace string) (*everestv1alpha1.BackupStorageList, error)

ListBackupStorages returns list of managed backup storages.

func (*Kubernetes) ListClusterServiceVersion

func (k *Kubernetes) ListClusterServiceVersion(
	ctx context.Context,
	namespace string,
) (*olmv1alpha1.ClusterServiceVersionList, error)

ListClusterServiceVersion list all CSVs for the given namespace.

func (*Kubernetes) ListDatabaseClusterBackups

func (k *Kubernetes) ListDatabaseClusterBackups(ctx context.Context, namespace string, options metav1.ListOptions) (*everestv1alpha1.DatabaseClusterBackupList, error)

ListDatabaseClusterBackups returns database cluster backups.

func (*Kubernetes) ListDatabaseClusterRestores

func (k *Kubernetes) ListDatabaseClusterRestores(ctx context.Context, namespace string, options metav1.ListOptions) (*everestv1alpha1.DatabaseClusterRestoreList, error)

ListDatabaseClusterRestores returns database cluster restores.

func (*Kubernetes) ListDatabaseClusters

func (k *Kubernetes) ListDatabaseClusters(ctx context.Context, namespace string) (*everestv1alpha1.DatabaseClusterList, error)

ListDatabaseClusters returns list of managed database clusters.

func (*Kubernetes) ListDatabaseEngines

func (k *Kubernetes) ListDatabaseEngines(ctx context.Context, namespace string) (*everestv1alpha1.DatabaseEngineList, error)

ListDatabaseEngines returns list of managed database clusters.

func (*Kubernetes) ListEngineDeploymentNames

func (k *Kubernetes) ListEngineDeploymentNames(ctx context.Context, namespace string) ([]string, error)

ListEngineDeploymentNames returns a string array containing found engine deployments for the Everest.

func (*Kubernetes) ListMonitoringConfigs

func (k *Kubernetes) ListMonitoringConfigs(ctx context.Context, namespace string) (*everestv1alpha1.MonitoringConfigList, error)

ListMonitoringConfigs returns list of managed monitoring configs.

func (*Kubernetes) ListSecrets

func (k *Kubernetes) ListSecrets(ctx context.Context, namespace string) (*corev1.SecretList, error)

ListSecrets returns secret by name.

func (*Kubernetes) ListSubscriptions

func (k *Kubernetes) ListSubscriptions(ctx context.Context, namespace string) (*olmv1alpha1.SubscriptionList, error)

ListSubscriptions all the subscriptions in the namespace.

func (*Kubernetes) Namespace

func (k *Kubernetes) Namespace() string

Namespace returns the current namespace.

func (*Kubernetes) OperatorInstalledVersion added in v0.10.0

func (k *Kubernetes) OperatorInstalledVersion(ctx context.Context, namespace, name string) (*goversion.Version, error)

OperatorInstalledVersion returns the installed version of operator by name.

func (*Kubernetes) PatchDatabaseCluster

func (k *Kubernetes) PatchDatabaseCluster(cluster *everestv1alpha1.DatabaseCluster) error

PatchDatabaseCluster patches CR of managed Database cluster.

func (*Kubernetes) ProvisionMonitoring

func (k *Kubernetes) ProvisionMonitoring(namespace string) error

ProvisionMonitoring provisions PMM monitoring.

func (*Kubernetes) RestartEverest

func (k *Kubernetes) RestartEverest(ctx context.Context, name, namespace string) error

RestartEverest restarts everest pod.

func (*Kubernetes) SetSecret

func (k *Kubernetes) SetSecret(secret *corev1.Secret) error

SetSecret creates or updates an existing secret.

func (*Kubernetes) UpdateBackupStorage

func (k *Kubernetes) UpdateBackupStorage(ctx context.Context, storage *everestv1alpha1.BackupStorage) error

UpdateBackupStorage returns backup storages by provided name.

func (*Kubernetes) UpdateClusterRoleBinding

func (k *Kubernetes) UpdateClusterRoleBinding(ctx context.Context, name string, namespaces []string) error

UpdateClusterRoleBinding updates namespaces list for the cluster role by provided name.

func (*Kubernetes) UpdateDatabaseClusterBackup added in v0.10.0

UpdateDatabaseClusterBackup updates database cluster backup.

func (*Kubernetes) UpdateDatabaseEngine added in v0.10.0

func (k *Kubernetes) UpdateDatabaseEngine(ctx context.Context, namespace string, engine *everestv1alpha1.DatabaseEngine) (*everestv1alpha1.DatabaseEngine, error)

UpdateDatabaseEngine updates the provided database engine.

func (*Kubernetes) UpdateMonitoringConfig

func (k *Kubernetes) UpdateMonitoringConfig(ctx context.Context, storage *everestv1alpha1.MonitoringConfig) error

UpdateMonitoringConfig returns monitoring configs by provided name.

func (*Kubernetes) UpdateSecret

func (k *Kubernetes) UpdateSecret(ctx context.Context, secret *corev1.Secret) (*corev1.Secret, error)

UpdateSecret updates a secret.

func (*Kubernetes) UpgradeOperator

func (k *Kubernetes) UpgradeOperator(ctx context.Context, namespace, name string) error

UpgradeOperator upgrades an operator to the next available version.

func (*Kubernetes) WaitForInstallPlan added in v0.10.0

func (k *Kubernetes) WaitForInstallPlan(ctx context.Context, namespace, operatorName string, version *goversion.Version) (*olmv1alpha1.InstallPlan, error)

WaitForInstallPlan waits until an install plan for the given operator and version is available.

func (*Kubernetes) WaitForInstallPlanCompleted added in v0.10.0

func (k *Kubernetes) WaitForInstallPlanCompleted(ctx context.Context, namespace, name string) error

WaitForInstallPlanCompleted waits until install plan phase is "complete".

func (*Kubernetes) WaitForRollout

func (k *Kubernetes) WaitForRollout(ctx context.Context, name, namespace string) error

WaitForRollout waits for rollout of a provided deployment in the provided namespace.

type KubernetesConnector added in v0.10.0

type KubernetesConnector interface {
	// GetDeployment returns k8s deployment by provided name and namespace.
	GetDeployment(ctx context.Context, name, namespace string) (*appsv1.Deployment, error)
	// WaitForInstallPlan waits until an install plan for the given operator and version is available.
	WaitForInstallPlan(ctx context.Context, namespace, operatorName string, version *goversion.Version) (*olmv1alpha1.InstallPlan, error)
	// ApproveInstallPlan approves an install plan.
	ApproveInstallPlan(ctx context.Context, namespace, installPlanName string) (bool, error)
	// WaitForInstallPlanCompleted waits until install plan phase is "complete".
	WaitForInstallPlanCompleted(ctx context.Context, namespace, name string) error
	// Config returns *rest.Config.
	Config() *rest.Config
	// Namespace returns the current namespace.
	Namespace() string
	// ClusterName returns the name of the k8s cluster.
	ClusterName() string
	// GetDefaultStorageClassName returns first storageClassName from kubernetes cluster.
	GetDefaultStorageClassName(ctx context.Context) (string, error)
	// GetEverestID returns the ID of the namespace where everest is deployed.
	GetEverestID(ctx context.Context) (string, error)
	// GetClusterType tries to guess the underlying kubernetes cluster based on storage class.
	GetClusterType(ctx context.Context) (ClusterType, error)
	// GetPSMDBOperatorVersion parses PSMDB operator version from operator deployment.
	GetPSMDBOperatorVersion(ctx context.Context) (string, error)
	// GetPXCOperatorVersion parses PXC operator version from operator deployment.
	GetPXCOperatorVersion(ctx context.Context) (string, error)
	// GetDBaaSOperatorVersion parses DBaaS operator version from operator deployment.
	GetDBaaSOperatorVersion(ctx context.Context) (string, error)
	// CreatePMMSecret creates pmm secret in kubernetes.
	CreatePMMSecret(namespace, secretName string, secrets map[string][]byte) error
	// CreateRestore creates a restore.
	CreateRestore(restore *everestv1alpha1.DatabaseClusterRestore) error
	// GetLogs returns logs.
	GetLogs(ctx context.Context, containerStatuses []corev1.ContainerStatus, pod, container string) ([]string, error)
	// GetEvents returns pod's events as a slice of strings.
	GetEvents(ctx context.Context, pod string) ([]string, error)
	// InstallOLMOperator installs OLM operator.
	InstallOLMOperator(ctx context.Context, upgrade bool) error
	// InstallPerconaCatalog installs percona catalog and ensures that packages are available.
	InstallPerconaCatalog(ctx context.Context, version *goversion.Version) error
	// CreateNamespace creates a new namespace.
	CreateNamespace(name string) error
	// InstallOperator installs an operator via OLM.
	InstallOperator(ctx context.Context, req InstallOperatorRequest) error
	// CreateOperatorGroup creates operator group in the given namespace.
	CreateOperatorGroup(ctx context.Context, name, namespace string, targetNamespaces []string) error
	// ListSubscriptions all the subscriptions in the namespace.
	ListSubscriptions(ctx context.Context, namespace string) (*olmv1alpha1.SubscriptionList, error)
	// UpgradeOperator upgrades an operator to the next available version.
	UpgradeOperator(ctx context.Context, namespace, name string) error
	// GetServerVersion returns server version.
	GetServerVersion() (*version.Info, error)
	// GetClusterServiceVersion retrieves a ClusterServiceVersion by namespaced name.
	GetClusterServiceVersion(ctx context.Context, key types.NamespacedName) (*olmv1alpha1.ClusterServiceVersion, error)
	// ListClusterServiceVersion list all CSVs for the given namespace.
	ListClusterServiceVersion(ctx context.Context, namespace string) (*olmv1alpha1.ClusterServiceVersionList, error)
	// DeleteClusterServiceVersion deletes a ClusterServiceVersion.
	DeleteClusterServiceVersion(ctx context.Context, key types.NamespacedName) error
	// DeleteObject deletes an object.
	DeleteObject(obj runtime.Object) error
	// ProvisionMonitoring provisions PMM monitoring.
	ProvisionMonitoring(namespace string) error
	// RestartEverest restarts everest pod.
	RestartEverest(ctx context.Context, name, namespace string) error
	// ListEngineDeploymentNames returns a string array containing found engine deployments for the Everest.
	ListEngineDeploymentNames(ctx context.Context, namespace string) ([]string, error)
	// ApplyObject applies object.
	ApplyObject(obj runtime.Object) error
	// InstallEverest downloads the manifest file and applies it against provisioned k8s cluster.
	InstallEverest(ctx context.Context, namespace string, version *goversion.Version) error
	// DeleteEverest downloads the manifest file and deletes it from provisioned k8s cluster.
	DeleteEverest(ctx context.Context, namespace string, version *goversion.Version) error
	// GetDBNamespaces returns a list of namespaces that are monitored by the Everest operator.
	GetDBNamespaces(ctx context.Context, namespace string) ([]string, error)
	// WaitForRollout waits for rollout of a provided deployment in the provided namespace.
	WaitForRollout(ctx context.Context, name, namespace string) error
	// UpdateClusterRoleBinding updates namespaces list for the cluster role by provided name.
	UpdateClusterRoleBinding(ctx context.Context, name string, namespaces []string) error
	// OperatorInstalledVersion returns the installed version of operator by name.
	OperatorInstalledVersion(ctx context.Context, namespace, name string) (*goversion.Version, error)
}

KubernetesConnector ...

type MockKubernetesConnector added in v0.10.0

type MockKubernetesConnector struct {
	mock.Mock
}

MockKubernetesConnector is an autogenerated mock type for the KubernetesConnector type

func NewMockKubernetesConnector added in v0.10.0

func NewMockKubernetesConnector(t interface {
	mock.TestingT
	Cleanup(func())
},
) *MockKubernetesConnector

NewMockKubernetesConnector creates a new instance of MockKubernetesConnector. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockKubernetesConnector) ApplyObject added in v0.10.0

func (_m *MockKubernetesConnector) ApplyObject(obj runtime.Object) error

ApplyObject provides a mock function with given fields: obj

func (*MockKubernetesConnector) ApproveInstallPlan added in v0.10.0

func (_m *MockKubernetesConnector) ApproveInstallPlan(ctx context.Context, namespace string, installPlanName string) (bool, error)

ApproveInstallPlan provides a mock function with given fields: ctx, namespace, installPlanName

func (*MockKubernetesConnector) ClusterName added in v0.10.0

func (_m *MockKubernetesConnector) ClusterName() string

ClusterName provides a mock function with given fields:

func (*MockKubernetesConnector) Config added in v0.10.0

func (_m *MockKubernetesConnector) Config() *rest.Config

Config provides a mock function with given fields:

func (*MockKubernetesConnector) CreateNamespace added in v0.10.0

func (_m *MockKubernetesConnector) CreateNamespace(name string) error

CreateNamespace provides a mock function with given fields: name

func (*MockKubernetesConnector) CreateOperatorGroup added in v0.10.0

func (_m *MockKubernetesConnector) CreateOperatorGroup(ctx context.Context, name string, namespace string, targetNamespaces []string) error

CreateOperatorGroup provides a mock function with given fields: ctx, name, namespace, targetNamespaces

func (*MockKubernetesConnector) CreatePMMSecret added in v0.10.0

func (_m *MockKubernetesConnector) CreatePMMSecret(namespace string, secretName string, secrets map[string][]byte) error

CreatePMMSecret provides a mock function with given fields: namespace, secretName, secrets

func (*MockKubernetesConnector) CreateRestore added in v0.10.0

func (_m *MockKubernetesConnector) CreateRestore(restore *v1alpha1.DatabaseClusterRestore) error

CreateRestore provides a mock function with given fields: restore

func (*MockKubernetesConnector) DeleteClusterServiceVersion added in v0.10.0

func (_m *MockKubernetesConnector) DeleteClusterServiceVersion(ctx context.Context, key types.NamespacedName) error

DeleteClusterServiceVersion provides a mock function with given fields: ctx, key

func (*MockKubernetesConnector) DeleteEverest added in v0.10.0

func (_m *MockKubernetesConnector) DeleteEverest(ctx context.Context, namespace string, _a2 *version.Version) error

DeleteEverest provides a mock function with given fields: ctx, namespace, _a2

func (*MockKubernetesConnector) DeleteObject added in v0.10.0

func (_m *MockKubernetesConnector) DeleteObject(obj runtime.Object) error

DeleteObject provides a mock function with given fields: obj

func (*MockKubernetesConnector) GetClusterServiceVersion added in v0.10.0

GetClusterServiceVersion provides a mock function with given fields: ctx, key

func (*MockKubernetesConnector) GetClusterType added in v0.10.0

func (_m *MockKubernetesConnector) GetClusterType(ctx context.Context) (ClusterType, error)

GetClusterType provides a mock function with given fields: ctx

func (*MockKubernetesConnector) GetDBNamespaces added in v0.10.0

func (_m *MockKubernetesConnector) GetDBNamespaces(ctx context.Context, namespace string) ([]string, error)

GetDBNamespaces provides a mock function with given fields: ctx, namespace

func (*MockKubernetesConnector) GetDBaaSOperatorVersion added in v0.10.0

func (_m *MockKubernetesConnector) GetDBaaSOperatorVersion(ctx context.Context) (string, error)

GetDBaaSOperatorVersion provides a mock function with given fields: ctx

func (*MockKubernetesConnector) GetDefaultStorageClassName added in v0.10.0

func (_m *MockKubernetesConnector) GetDefaultStorageClassName(ctx context.Context) (string, error)

GetDefaultStorageClassName provides a mock function with given fields: ctx

func (*MockKubernetesConnector) GetDeployment added in v0.10.0

func (_m *MockKubernetesConnector) GetDeployment(ctx context.Context, name string, namespace string) (*v1.Deployment, error)

GetDeployment provides a mock function with given fields: ctx, name, namespace

func (*MockKubernetesConnector) GetEvents added in v0.10.0

func (_m *MockKubernetesConnector) GetEvents(ctx context.Context, pod string) ([]string, error)

GetEvents provides a mock function with given fields: ctx, pod

func (*MockKubernetesConnector) GetEverestID added in v0.10.0

func (_m *MockKubernetesConnector) GetEverestID(ctx context.Context) (string, error)

GetEverestID provides a mock function with given fields: ctx

func (*MockKubernetesConnector) GetLogs added in v0.10.0

func (_m *MockKubernetesConnector) GetLogs(ctx context.Context, containerStatuses []corev1.ContainerStatus, pod string, container string) ([]string, error)

GetLogs provides a mock function with given fields: ctx, containerStatuses, pod, container

func (*MockKubernetesConnector) GetPSMDBOperatorVersion added in v0.10.0

func (_m *MockKubernetesConnector) GetPSMDBOperatorVersion(ctx context.Context) (string, error)

GetPSMDBOperatorVersion provides a mock function with given fields: ctx

func (*MockKubernetesConnector) GetPXCOperatorVersion added in v0.10.0

func (_m *MockKubernetesConnector) GetPXCOperatorVersion(ctx context.Context) (string, error)

GetPXCOperatorVersion provides a mock function with given fields: ctx

func (*MockKubernetesConnector) GetServerVersion added in v0.10.0

func (_m *MockKubernetesConnector) GetServerVersion() (*pkgversion.Info, error)

GetServerVersion provides a mock function with given fields:

func (*MockKubernetesConnector) InstallEverest added in v0.10.0

func (_m *MockKubernetesConnector) InstallEverest(ctx context.Context, namespace string, _a2 *version.Version) error

InstallEverest provides a mock function with given fields: ctx, namespace, _a2

func (*MockKubernetesConnector) InstallOLMOperator added in v0.10.0

func (_m *MockKubernetesConnector) InstallOLMOperator(ctx context.Context, upgrade bool) error

InstallOLMOperator provides a mock function with given fields: ctx, upgrade

func (*MockKubernetesConnector) InstallOperator added in v0.10.0

func (_m *MockKubernetesConnector) InstallOperator(ctx context.Context, req InstallOperatorRequest) error

InstallOperator provides a mock function with given fields: ctx, req

func (*MockKubernetesConnector) InstallPerconaCatalog added in v0.10.0

func (_m *MockKubernetesConnector) InstallPerconaCatalog(ctx context.Context, _a1 *version.Version) error

InstallPerconaCatalog provides a mock function with given fields: ctx, _a1

func (*MockKubernetesConnector) ListClusterServiceVersion added in v0.10.0

func (_m *MockKubernetesConnector) ListClusterServiceVersion(ctx context.Context, namespace string) (*operatorsv1alpha1.ClusterServiceVersionList, error)

ListClusterServiceVersion provides a mock function with given fields: ctx, namespace

func (*MockKubernetesConnector) ListEngineDeploymentNames added in v0.10.0

func (_m *MockKubernetesConnector) ListEngineDeploymentNames(ctx context.Context, namespace string) ([]string, error)

ListEngineDeploymentNames provides a mock function with given fields: ctx, namespace

func (*MockKubernetesConnector) ListSubscriptions added in v0.10.0

func (_m *MockKubernetesConnector) ListSubscriptions(ctx context.Context, namespace string) (*operatorsv1alpha1.SubscriptionList, error)

ListSubscriptions provides a mock function with given fields: ctx, namespace

func (*MockKubernetesConnector) Namespace added in v0.10.0

func (_m *MockKubernetesConnector) Namespace() string

Namespace provides a mock function with given fields:

func (*MockKubernetesConnector) OperatorInstalledVersion added in v0.10.0

func (_m *MockKubernetesConnector) OperatorInstalledVersion(ctx context.Context, namespace string, name string) (*version.Version, error)

OperatorInstalledVersion provides a mock function with given fields: ctx, namespace, name

func (*MockKubernetesConnector) ProvisionMonitoring added in v0.10.0

func (_m *MockKubernetesConnector) ProvisionMonitoring(namespace string) error

ProvisionMonitoring provides a mock function with given fields: namespace

func (*MockKubernetesConnector) RestartEverest added in v0.10.0

func (_m *MockKubernetesConnector) RestartEverest(ctx context.Context, name string, namespace string) error

RestartEverest provides a mock function with given fields: ctx, name, namespace

func (*MockKubernetesConnector) UpdateClusterRoleBinding added in v0.10.0

func (_m *MockKubernetesConnector) UpdateClusterRoleBinding(ctx context.Context, name string, namespaces []string) error

UpdateClusterRoleBinding provides a mock function with given fields: ctx, name, namespaces

func (*MockKubernetesConnector) UpgradeOperator added in v0.10.0

func (_m *MockKubernetesConnector) UpgradeOperator(ctx context.Context, namespace string, name string) error

UpgradeOperator provides a mock function with given fields: ctx, namespace, name

func (*MockKubernetesConnector) WaitForInstallPlan added in v0.10.0

func (_m *MockKubernetesConnector) WaitForInstallPlan(ctx context.Context, namespace string, operatorName string, _a3 *version.Version) (*operatorsv1alpha1.InstallPlan, error)

WaitForInstallPlan provides a mock function with given fields: ctx, namespace, operatorName, _a3

func (*MockKubernetesConnector) WaitForInstallPlanCompleted added in v0.10.0

func (_m *MockKubernetesConnector) WaitForInstallPlanCompleted(ctx context.Context, namespace string, name string) error

WaitForInstallPlanCompleted provides a mock function with given fields: ctx, namespace, name

func (*MockKubernetesConnector) WaitForRollout added in v0.10.0

func (_m *MockKubernetesConnector) WaitForRollout(ctx context.Context, name string, namespace string) error

WaitForRollout provides a mock function with given fields: ctx, name, namespace

type NodeFileSystemSummary

type NodeFileSystemSummary struct {
	UsedBytes uint64 `json:"usedBytes,omitempty"`
}

NodeFileSystemSummary holds a summary of Node's filesystem.

type NodeSummary

type NodeSummary struct {
	Node NodeSummaryNode `json:"node,omitempty"`
}

NodeSummary holds summary of the Node. One gets this by requesting Kubernetes API endpoint: /v1/nodes/<node-name>/proxy/stats/summary.

type NodeSummaryNode

type NodeSummaryNode struct {
	FileSystem NodeFileSystemSummary `json:"fs,omitempty"`
}

NodeSummaryNode holds information about Node inside Node's summary.

type OperatorServiceManager

type OperatorServiceManager interface {
	// SetKubeConfig receives a new config and establish a new connection to the K8 cluster.
	SetKubeConfig(kubeConfig string) error
	// InstallOLMOperator installs the OLM in the Kubernetes cluster.
	InstallOLMOperator(ctx context.Context) error
	// InstallOperator installs an operator via OLM.
	InstallOperator(ctx context.Context, req InstallOperatorRequest) error
	// ListSubscriptions all the subscriptions in the namespace.
	ListSubscriptions(ctx context.Context, namespace string) (*v1alpha1.SubscriptionList, error)
	// UpgradeOperator upgrades an operator to the next available version.
	UpgradeOperator(ctx context.Context, namespace, name string) error
}

OperatorServiceManager ...

Directories

Path Synopsis
Package client ...
Package client ...
customresources
Package customresources provides methods to work with custom everest k8s resources.
Package customresources provides methods to work with custom everest k8s resources.
database
Package database TODO
Package database TODO

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL