provisioner

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultKubernetesVersion = "0.0.0"
)

DefaultKubernetesVersion is the default value for a kubernetes cluster version value.

View Source
const EKSProvisionerType = "eks"

EKSProvisionerType is provisioner type for EKS clusters.

View Source
const KopsProvisionerType = "kops"

KopsProvisionerType is provisioner type for Kops clusters.

Variables

View Source
var ErrJobBackoffLimitReached = errors.New("job reached backoff limit")

ErrJobBackoffLimitReached indicates that job failed all possible attempts and there is no reason for retrying.

Functions

func NewEKSKubeconfig added in v0.64.0

func NewEKSKubeconfig(cluster *eks.Cluster, aws aws.AWS) (clientcmdapi.Config, error)

NewEKSKubeconfig creates kubeconfig for EKS cluster.

Types

type BackupOperator added in v0.44.0

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

BackupOperator provides methods to run, check and cleanup backup jobs.

func NewBackupOperator added in v0.44.0

func NewBackupOperator(image, region string, jobTTLSeconds int32) *BackupOperator

NewBackupOperator creates new BackupOperator.

func (BackupOperator) CheckBackupStatus added in v0.44.0

func (o BackupOperator) CheckBackupStatus(jobsClient v1.JobInterface, backup *model.InstallationBackup, logger log.FieldLogger) (int64, error)

CheckBackupStatus checks status of backup job, returns job start time, when the job finished or -1 if it is still running.

func (BackupOperator) CheckRestoreStatus added in v0.45.0

func (o BackupOperator) CheckRestoreStatus(jobsClient v1.JobInterface, backup *model.InstallationBackup, logger log.FieldLogger) (int64, error)

CheckRestoreStatus checks status of restore job, returns job start time, when the job finished or -1 if it is still running.

func (BackupOperator) CleanupBackupJob added in v0.44.0

func (o BackupOperator) CleanupBackupJob(jobsClient v1.JobInterface, backup *model.InstallationBackup, logger log.FieldLogger) error

CleanupBackupJob removes backup job from the cluster if it exists.

func (BackupOperator) CleanupRestoreJob added in v0.45.0

func (o BackupOperator) CleanupRestoreJob(jobsClient v1.JobInterface, backup *model.InstallationBackup, logger log.FieldLogger) error

CleanupRestoreJob removes restore job from the cluster if it exists.

func (BackupOperator) TriggerBackup added in v0.44.0

func (o BackupOperator) TriggerBackup(
	jobsClient v1.JobInterface,
	backup *model.InstallationBackup,
	installation *model.Installation,
	fileStoreCfg *model.FilestoreConfig,
	dbSecret string,
	logger log.FieldLogger) (*model.S3DataResidence, error)

TriggerBackup creates new backup job and waits for it to start.

func (BackupOperator) TriggerRestore added in v0.45.0

func (o BackupOperator) TriggerRestore(
	jobsClient v1.JobInterface,
	backup *model.InstallationBackup,
	installation *model.Installation,
	fileStoreCfg *model.FilestoreConfig,
	dbSecret string,
	logger log.FieldLogger) error

TriggerRestore creates new restore job and waits for it to start.

type ClusterInstallationProvisioner added in v0.38.0

type ClusterInstallationProvisioner interface {
	CreateClusterInstallation(cluster *model.Cluster, installation *model.Installation, installationDNS []*model.InstallationDNS, clusterInstallation *model.ClusterInstallation) error
	EnsureCRMigrated(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation) (bool, error)
	HibernateClusterInstallation(cluster *model.Cluster, installation *model.Installation, clusterInstallation *model.ClusterInstallation) error
	UpdateClusterInstallation(cluster *model.Cluster, installation *model.Installation, installationDNS []*model.InstallationDNS, clusterInstallation *model.ClusterInstallation) error
	VerifyClusterInstallationMatchesConfig(cluster *model.Cluster, installation *model.Installation, clusterInstallation *model.ClusterInstallation) (bool, error)
	DeleteOldClusterInstallationLicenseSecrets(cluster *model.Cluster, installation *model.Installation, clusterInstallation *model.ClusterInstallation) error
	DeleteClusterInstallation(cluster *model.Cluster, installation *model.Installation, clusterInstallation *model.ClusterInstallation) error
	IsResourceReadyAndStable(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation) (bool, bool, error)
	RefreshSecrets(cluster *model.Cluster, installation *model.Installation, clusterInstallation *model.ClusterInstallation) error
	PrepareClusterUtilities(cluster *model.Cluster, installation *model.Installation, store model.ClusterUtilityDatabaseStoreInterface, awsClient aws.AWS) error
}

ClusterInstallationProvisioner is an interface for provisioning and managing ClusterInstallations.

type CommonProvisioner added in v0.64.0

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

CommonProvisioner groups functions common to different provisioners.

type EKSProvisioner added in v0.64.0

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

EKSProvisioner provisions clusters using AWS EKS.

func NewEKSProvisioner added in v0.64.0

func NewEKSProvisioner(
	store model.InstallationDatabaseStoreInterface,
	clusterUpdateStore clusterUpdateStore,
	params ProvisioningParams,
	resourceUtil *utils.ResourceUtil,
	awsClient aws.AWS,
	logger log.FieldLogger) *EKSProvisioner

NewEKSProvisioner creates new EKSProvisioner.

func (*EKSProvisioner) CheckBackupStatus added in v0.64.0

func (provisioner *EKSProvisioner) CheckBackupStatus(backupMeta *model.InstallationBackup, cluster *model.Cluster) (int64, error)

CheckBackupStatus checks backup state.

func (*EKSProvisioner) CheckClusterCreated added in v0.64.0

func (provisioner *EKSProvisioner) CheckClusterCreated(cluster *model.Cluster, awsClient aws.AWS) (bool, error)

CheckClusterCreated checks if cluster creation finished.

func (*EKSProvisioner) CheckRestoreStatus added in v0.64.0

func (provisioner *EKSProvisioner) CheckRestoreStatus(backupMeta *model.InstallationBackup, cluster *model.Cluster) (int64, error)

CheckRestoreStatus checks restore status.

func (*EKSProvisioner) CleanupBackupJob added in v0.64.0

func (provisioner *EKSProvisioner) CleanupBackupJob(backup *model.InstallationBackup, cluster *model.Cluster) error

CleanupBackupJob cleans up backup job.

func (*EKSProvisioner) CleanupRestoreJob added in v0.64.0

func (provisioner *EKSProvisioner) CleanupRestoreJob(backup *model.InstallationBackup, cluster *model.Cluster) error

CleanupRestoreJob cleans up restore job.

func (*EKSProvisioner) ClusterInstallationProvisioner added in v0.64.0

func (provisioner *EKSProvisioner) ClusterInstallationProvisioner(version string) ClusterInstallationProvisioner

ClusterInstallationProvisioner returns ClusterInstallationProvisioner based on EKS provisioner.

func (*EKSProvisioner) CreateCluster added in v0.64.0

func (provisioner *EKSProvisioner) CreateCluster(cluster *model.Cluster, awsClient aws.AWS) error

CreateCluster creates the EKS cluster.

func (*EKSProvisioner) CreateClusterInstallation added in v0.64.0

func (provisioner *EKSProvisioner) CreateClusterInstallation(cluster *model.Cluster, installation *model.Installation, installationDNS []*model.InstallationDNS, clusterInstallation *model.ClusterInstallation) error

CreateClusterInstallation creates ClusterInstallation.

func (*EKSProvisioner) DeleteCluster added in v0.64.0

func (provisioner *EKSProvisioner) DeleteCluster(cluster *model.Cluster, awsClient aws.AWS) (bool, error)

DeleteCluster deletes EKS cluster.

func (*EKSProvisioner) DeleteClusterInstallation added in v0.64.0

func (provisioner *EKSProvisioner) DeleteClusterInstallation(cluster *model.Cluster, installation *model.Installation, clusterInstallation *model.ClusterInstallation) error

DeleteClusterInstallation deletes ClusterInstallation.

func (*EKSProvisioner) DeleteOldClusterInstallationLicenseSecrets added in v0.64.0

func (provisioner *EKSProvisioner) DeleteOldClusterInstallationLicenseSecrets(cluster *model.Cluster, installation *model.Installation, clusterInstallation *model.ClusterInstallation) error

DeleteOldClusterInstallationLicenseSecrets deletes old installation license secret.

func (*EKSProvisioner) EnsureCRMigrated added in v0.64.0

func (provisioner *EKSProvisioner) EnsureCRMigrated(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation) (bool, error)

EnsureCRMigrated ensures CR is in correct version.

func (*EKSProvisioner) ExecClusterInstallationCLI added in v0.64.0

func (provisioner *EKSProvisioner) ExecClusterInstallationCLI(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation, args ...string) ([]byte, error, error)

ExecClusterInstallationCLI executes command on ClusterInstallation.

func (*EKSProvisioner) ExecClusterInstallationJob added in v0.64.0

func (provisioner *EKSProvisioner) ExecClusterInstallationJob(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation, args ...string) error

ExecClusterInstallationJob executes ClusterInstallation command as a job.

func (*EKSProvisioner) ExecMMCTL added in v0.64.0

func (provisioner *EKSProvisioner) ExecMMCTL(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation, args ...string) ([]byte, error)

ExecMMCTL executes mmctl command on ClusterInstallation.

func (*EKSProvisioner) ExecMattermostCLI added in v0.64.0

func (provisioner *EKSProvisioner) ExecMattermostCLI(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation, args ...string) ([]byte, error)

ExecMattermostCLI executes Mattermost cli on ClusterInstallation.

func (*EKSProvisioner) GetClusterResources added in v0.64.0

func (provisioner *EKSProvisioner) GetClusterResources(cluster *model.Cluster, onlySchedulable bool, logger log.FieldLogger) (*k8s.ClusterResources, error)

GetClusterResources returns resources for EKS cluster.

func (*EKSProvisioner) GetPublicLoadBalancerEndpoint added in v0.64.0

func (provisioner *EKSProvisioner) GetPublicLoadBalancerEndpoint(cluster *model.Cluster, namespace string) (string, error)

GetPublicLoadBalancerEndpoint returns endpoint of public load balancer.

func (*EKSProvisioner) HibernateClusterInstallation added in v0.64.0

func (provisioner *EKSProvisioner) HibernateClusterInstallation(cluster *model.Cluster, installation *model.Installation, clusterInstallation *model.ClusterInstallation) error

HibernateClusterInstallation hibernates the cluster installation.

func (*EKSProvisioner) IsResourceReadyAndStable added in v0.64.0

func (provisioner *EKSProvisioner) IsResourceReadyAndStable(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation) (bool, bool, error)

IsResourceReadyAndStable determines if the resource is ready and stable.

func (*EKSProvisioner) PrepareCluster added in v0.64.0

func (provisioner *EKSProvisioner) PrepareCluster(cluster *model.Cluster) bool

PrepareCluster is noop for EKSProvisioner.

func (*EKSProvisioner) PrepareClusterUtilities added in v0.64.0

func (provisioner *EKSProvisioner) PrepareClusterUtilities(cluster *model.Cluster, installation *model.Installation, store model.ClusterUtilityDatabaseStoreInterface, awsClient aws.AWS) error

PrepareClusterUtilities prepares cluster utilities.

func (*EKSProvisioner) ProvisionCluster added in v0.64.0

func (provisioner *EKSProvisioner) ProvisionCluster(cluster *model.Cluster, awsClient aws.AWS) error

ProvisionCluster provisions EKS cluster.

func (*EKSProvisioner) ProvisionerType added in v0.64.0

func (provisioner *EKSProvisioner) ProvisionerType() string

ProvisionerType returns type of the provisioner.

func (*EKSProvisioner) RefreshKopsMetadata added in v0.64.0

func (provisioner *EKSProvisioner) RefreshKopsMetadata(cluster *model.Cluster) error

RefreshKopsMetadata is a noop for EKSProvisioner.

func (*EKSProvisioner) RefreshSecrets added in v0.64.0

func (provisioner *EKSProvisioner) RefreshSecrets(cluster *model.Cluster, installation *model.Installation, clusterInstallation *model.ClusterInstallation) error

RefreshSecrets refreshes Installation secrets.

func (*EKSProvisioner) ResizeCluster added in v0.64.0

func (provisioner *EKSProvisioner) ResizeCluster(cluster *model.Cluster, awsClient aws.AWS) error

ResizeCluster resizes cluster - not implemented.

func (*EKSProvisioner) RotateClusterNodes added in v0.64.0

func (provisioner *EKSProvisioner) RotateClusterNodes(cluster *model.Cluster) error

RotateClusterNodes rotates cluster nodes - not implemented.

func (*EKSProvisioner) TriggerBackup added in v0.64.0

func (provisioner *EKSProvisioner) TriggerBackup(backupMeta *model.InstallationBackup, cluster *model.Cluster, installation *model.Installation) (*model.S3DataResidence, error)

TriggerBackup triggers backup.

func (*EKSProvisioner) TriggerRestore added in v0.64.0

func (provisioner *EKSProvisioner) TriggerRestore(installation *model.Installation, backup *model.InstallationBackup, cluster *model.Cluster) error

TriggerRestore triggers restore.

func (*EKSProvisioner) UpdateClusterInstallation added in v0.64.0

func (provisioner *EKSProvisioner) UpdateClusterInstallation(cluster *model.Cluster, installation *model.Installation, installationDNS []*model.InstallationDNS, clusterInstallation *model.ClusterInstallation) error

UpdateClusterInstallation updates ClusterInstsallation.

func (*EKSProvisioner) UpgradeCluster added in v0.64.0

func (provisioner *EKSProvisioner) UpgradeCluster(cluster *model.Cluster, awsClient aws.AWS) error

UpgradeCluster upgrades EKS cluster - not implemented.

func (*EKSProvisioner) VerifyClusterInstallationMatchesConfig added in v0.64.0

func (provisioner *EKSProvisioner) VerifyClusterInstallationMatchesConfig(cluster *model.Cluster, installation *model.Installation, clusterInstallation *model.ClusterInstallation) (bool, error)

VerifyClusterInstallationMatchesConfig verifies ClusterInstallation matches config - not implemented.

type HelmListOutput added in v0.14.0

type HelmListOutput []helmReleaseJSON

HelmListOutput is a struct for holding the unmarshaled representation of the output from helm list --output json

type KopsProvisioner

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

KopsProvisioner provisions clusters using kops+terraform.

func NewKopsProvisioner

func NewKopsProvisioner(
	provisioningParams ProvisioningParams,
	resourceUtil *utils.ResourceUtil,
	logger log.FieldLogger,
	store model.InstallationDatabaseStoreInterface,
	backupOperator *BackupOperator) *KopsProvisioner

NewKopsProvisioner creates a new KopsProvisioner.

func (*KopsProvisioner) CheckBackupStatus added in v0.44.0

func (provisioner *KopsProvisioner) CheckBackupStatus(backup *model.InstallationBackup, cluster *model.Cluster) (int64, error)

CheckBackupStatus checks status of running backup job, returns job start time, when the job finished or -1 if it is still running.

func (*KopsProvisioner) CheckClusterCreated added in v0.64.0

func (provisioner *KopsProvisioner) CheckClusterCreated(cluster *model.Cluster, awsClient aws.AWS) (bool, error)

CheckClusterCreated is a noop for KopsProvisioner.

func (*KopsProvisioner) CheckRestoreStatus added in v0.45.0

func (provisioner *KopsProvisioner) CheckRestoreStatus(backup *model.InstallationBackup, cluster *model.Cluster) (int64, error)

CheckRestoreStatus checks status of running backup job, returns job completion time, when the job finished or -1 if it is still running.

func (*KopsProvisioner) CleanupBackupJob added in v0.44.0

func (provisioner *KopsProvisioner) CleanupBackupJob(backup *model.InstallationBackup, cluster *model.Cluster) error

CleanupBackupJob deletes backup job from the cluster if it exists.

func (*KopsProvisioner) CleanupRestoreJob added in v0.45.0

func (provisioner *KopsProvisioner) CleanupRestoreJob(backup *model.InstallationBackup, cluster *model.Cluster) error

CleanupRestoreJob deletes restore job from the cluster if it exists.

func (*KopsProvisioner) ClusterInstallationProvisioner added in v0.38.0

func (provisioner *KopsProvisioner) ClusterInstallationProvisioner(crVersion string) ClusterInstallationProvisioner

ClusterInstallationProvisioner function returns an implementation of ClusterInstallationProvisioner interface based on specified Custom Resource version.

func (*KopsProvisioner) CreateCluster

func (provisioner *KopsProvisioner) CreateCluster(cluster *model.Cluster, awsClient aws.AWS) error

CreateCluster creates a cluster using kops and terraform.

func (*KopsProvisioner) DeleteCluster

func (provisioner *KopsProvisioner) DeleteCluster(cluster *model.Cluster, awsClient aws.AWS) (bool, error)

DeleteCluster deletes a previously created cluster using kops and terraform.

func (*KopsProvisioner) DeleteOldClusterInstallationLicenseSecrets added in v0.45.0

func (provisioner *KopsProvisioner) DeleteOldClusterInstallationLicenseSecrets(cluster *model.Cluster, installation *model.Installation, clusterInstallation *model.ClusterInstallation) error

DeleteOldClusterInstallationLicenseSecrets removes k8s secrets found matching the license naming scheme that are not the current license used by the installation.

func (*KopsProvisioner) ExecClusterInstallationCLI added in v0.27.0

func (provisioner *KopsProvisioner) ExecClusterInstallationCLI(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation, args ...string) ([]byte, error, error)

ExecClusterInstallationCLI execs the provided command on the defined cluster installation and returns both exec preparation errors as well as errors from the exec command itself.

func (*KopsProvisioner) ExecClusterInstallationJob added in v0.45.0

func (provisioner *KopsProvisioner) ExecClusterInstallationJob(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation, args ...string) error

ExecClusterInstallationJob creates job executing command on cluster installation.

func (*KopsProvisioner) ExecMMCTL added in v0.54.1

func (provisioner *KopsProvisioner) ExecMMCTL(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation, args ...string) ([]byte, error)

ExecMMCTL runs the given MMCTL command against the given cluster installation. Setup and exec errors both result in a single return error.

func (*KopsProvisioner) ExecMattermostCLI added in v0.2.0

func (provisioner *KopsProvisioner) ExecMattermostCLI(cluster *model.Cluster, clusterInstallation *model.ClusterInstallation, args ...string) ([]byte, error)

ExecMattermostCLI invokes the Mattermost CLI for the given cluster installation with the given args. Setup and exec errors both result in a single return error.

func (*KopsProvisioner) GetClusterResources added in v0.2.0

func (provisioner *KopsProvisioner) GetClusterResources(cluster *model.Cluster, onlySchedulable bool, logger logrus.FieldLogger) (*k8s.ClusterResources, error)

GetClusterResources returns a snapshot of resources of a given cluster.

func (*KopsProvisioner) GetPublicLoadBalancerEndpoint added in v0.23.0

func (provisioner *KopsProvisioner) GetPublicLoadBalancerEndpoint(cluster *model.Cluster, namespace string) (string, error)

GetPublicLoadBalancerEndpoint returns the public load balancer endpoint of the NGINX service.

func (*KopsProvisioner) PrepareCluster

func (provisioner *KopsProvisioner) PrepareCluster(cluster *model.Cluster) bool

PrepareCluster ensures a cluster object is ready for provisioning.

func (*KopsProvisioner) PrepareClusterUtilities added in v0.46.1

func (provisioner *KopsProvisioner) PrepareClusterUtilities(cluster *model.Cluster, installation *model.Installation, store model.ClusterUtilityDatabaseStoreInterface, awsClient aws.AWS) error

PrepareClusterUtilities performs any updates to cluster utilities that may be needed for clusterinstallations to function correctly.

func (*KopsProvisioner) ProvisionCluster

func (provisioner *KopsProvisioner) ProvisionCluster(cluster *model.Cluster, awsClient aws.AWS) error

ProvisionCluster installs all the baseline kubernetes resources needed for managing installations. This can be called on an already-provisioned cluster to re-provision with the newest version of the resources.

func (*KopsProvisioner) ProvisionerType added in v0.64.0

func (provisioner *KopsProvisioner) ProvisionerType() string

ProvisionerType returns type of the provisioner.

func (*KopsProvisioner) RefreshKopsMetadata added in v0.21.0

func (provisioner *KopsProvisioner) RefreshKopsMetadata(cluster *model.Cluster) error

RefreshKopsMetadata updates the kops metadata of a cluster with the current values of the running cluster.

func (*KopsProvisioner) ResizeCluster added in v0.19.0

func (provisioner *KopsProvisioner) ResizeCluster(cluster *model.Cluster, awsClient aws.AWS) error

ResizeCluster resizes a cluster.

func (*KopsProvisioner) RotateClusterNodes added in v0.43.0

func (provisioner *KopsProvisioner) RotateClusterNodes(cluster *model.Cluster) error

RotateClusterNodes rotates k8s cluster nodes using the Mattermost node rotator

func (*KopsProvisioner) Teardown added in v0.37.0

func (provisioner *KopsProvisioner) Teardown()

Teardown cleans up cached kops provisioner data.

func (*KopsProvisioner) TriggerBackup added in v0.44.0

func (provisioner *KopsProvisioner) TriggerBackup(backup *model.InstallationBackup, cluster *model.Cluster, installation *model.Installation) (*model.S3DataResidence, error)

TriggerBackup triggers backup job for specific installation on the cluster.

func (*KopsProvisioner) TriggerRestore added in v0.45.0

func (provisioner *KopsProvisioner) TriggerRestore(installation *model.Installation, backup *model.InstallationBackup, cluster *model.Cluster) error

TriggerRestore triggers restoration job for specific installation on the cluster.

func (*KopsProvisioner) UpgradeCluster

func (provisioner *KopsProvisioner) UpgradeCluster(cluster *model.Cluster, awsClient aws.AWS) error

UpgradeCluster upgrades a cluster to the latest recommended production ready k8s version.

type ProvisioningParams added in v0.44.0

type ProvisioningParams struct {
	S3StateStore            string
	AllowCIDRRangeList      []string
	VpnCIDRList             []string
	Owner                   string
	UseExistingAWSResources bool
	DeployMysqlOperator     bool
	DeployMinioOperator     bool
	NdotsValue              string
}

ProvisioningParams represent configuration used during various provisioning operations.

type Utility added in v0.11.0

type Utility interface {
	// CreateOrUpgrade is responsible for deploying the utility in the
	// cluster and then for updating it if it already exists when called
	CreateOrUpgrade() error

	// Destroy can be used if special care must be taken for deleting a
	// utility from a cluster
	Destroy() error

	// Migrate can be used if special care must be taken for migrating a
	// utility from a cluster
	Migrate() error

	// ActualVersion returns the utility's last reported actual version,
	// at the time of Create or Upgrade. This version will remain valid
	// unless something interacts with the cluster out of band, at which
	// time it will be invalid until Upgrade is called again
	ActualVersion() *model.HelmUtilityVersion

	// DesiredVersion returns the utility's target version, which has been
	// requested, but may not yet have been reconciled
	DesiredVersion() *model.HelmUtilityVersion

	// Name returns the canonical string-version name for the utility,
	// used throughout the application
	Name() string

	// ValuesPath returns the location where the values file(s) are
	// stored for this utility
	ValuesPath() string
}

A Utility is a service that runs one per cluster but is not part of k8s itself, nor is it part of a ClusterInstallation or an Installation

Jump to

Keyboard shortcuts

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