clustermanager

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultMaxWaitPerMachine is the default max time the cluster manager will wait per a machine.
	DefaultMaxWaitPerMachine = 10 * time.Minute

	// DefaultControlPlaneWait is the default time the cluster manager will wait for the control plane to be ready.
	DefaultControlPlaneWait = 60 * time.Minute

	// DefaultEtcdWait is the default time the cluster manager will wait for ectd to be ready.
	DefaultEtcdWait = 60 * time.Minute
	// DefaultUnhealthyMachineTimeout is the default timeout for an unhealthy machine health check.
	DefaultUnhealthyMachineTimeout = 5 * time.Minute
	// DefaultNodeStartupTimeout is the default timeout for a machine without a node to be considered to have failed machine health check.
	DefaultNodeStartupTimeout = 10 * time.Minute
)

Variables

This section is empty.

Functions

func DefaultRetrier added in v0.13.0

func DefaultRetrier() *retrier.Retrier

DefaultRetrier builds a retrier with the default configuration.

func EksaChangeDiff added in v0.7.0

func EksaChangeDiff(currentSpec, newSpec *cluster.Spec) *types.ChangeDiff

EksaChangeDiff computes the version diff in eksa components between two specs.

func NewClient added in v0.6.0

func NewClient(clusterClient ClusterClient) *client

Types

type AwsIamAuth added in v0.6.0

type AwsIamAuth interface {
	CreateAndInstallAWSIAMAuthCASecret(ctx context.Context, managementCluster *types.Cluster, workloadClusterName string) error
	InstallAWSIAMAuth(ctx context.Context, management, workload *types.Cluster, spec *cluster.Spec) error
	UpgradeAWSIAMAuth(ctx context.Context, cluster *types.Cluster, spec *cluster.Spec) error
}

type ClusterClient

type ClusterClient interface {
	KubernetesClient
	MoveManagement(ctx context.Context, org, target *types.Cluster) error
	WaitForClusterReady(ctx context.Context, cluster *types.Cluster, timeout string, clusterName string) error
	WaitForControlPlaneAvailable(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error
	WaitForControlPlaneReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error
	WaitForControlPlaneNotReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error
	WaitForManagedExternalEtcdReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error
	WaitForManagedExternalEtcdNotReady(ctx context.Context, cluster *types.Cluster, timeout string, newClusterName string) error
	GetWorkloadKubeconfig(ctx context.Context, clusterName string, cluster *types.Cluster) ([]byte, error)
	GetEksaGitOpsConfig(ctx context.Context, gitOpsConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.GitOpsConfig, error)
	GetEksaFluxConfig(ctx context.Context, fluxConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.FluxConfig, error)
	GetEksaOIDCConfig(ctx context.Context, oidcConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.OIDCConfig, error)
	GetEksaAWSIamConfig(ctx context.Context, awsIamConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.AWSIamConfig, error)
	DeleteCluster(ctx context.Context, managementCluster, clusterToDelete *types.Cluster) error
	DeleteGitOpsConfig(ctx context.Context, managementCluster *types.Cluster, gitOpsName, namespace string) error
	DeleteOIDCConfig(ctx context.Context, managementCluster *types.Cluster, oidcConfigName, oidcConfigNamespace string) error
	DeleteAWSIamConfig(ctx context.Context, managementCluster *types.Cluster, awsIamConfigName, awsIamConfigNamespace string) error
	DeleteEKSACluster(ctx context.Context, managementCluster *types.Cluster, eksaClusterName, eksaClusterNamespace string) error
	DeletePackageResources(ctx context.Context, managementCluster *types.Cluster, clusterName string) error
	InitInfrastructure(ctx context.Context, clusterSpec *cluster.Spec, cluster *types.Cluster, provider providers.Provider) error
	WaitForDeployment(ctx context.Context, cluster *types.Cluster, timeout string, condition string, target string, namespace string) error
	SaveLog(ctx context.Context, cluster *types.Cluster, deployment *types.Deployment, fileName string, writer filewriter.FileWriter) error
	GetMachines(ctx context.Context, cluster *types.Cluster, clusterName string) ([]types.Machine, error)
	GetClusters(ctx context.Context, cluster *types.Cluster) ([]types.CAPICluster, error)
	GetEksaCluster(ctx context.Context, cluster *types.Cluster, clusterName string) (*v1alpha1.Cluster, error)
	GetEksaVSphereDatacenterConfig(ctx context.Context, VSphereDatacenterName string, kubeconfigFile string, namespace string) (*v1alpha1.VSphereDatacenterConfig, error)
	UpdateEnvironmentVariablesInNamespace(ctx context.Context, resourceType, resourceName string, envMap map[string]string, cluster *types.Cluster, namespace string) error
	GetEksaVSphereMachineConfig(ctx context.Context, VSphereDatacenterName string, kubeconfigFile string, namespace string) (*v1alpha1.VSphereMachineConfig, error)
	GetEksaCloudStackMachineConfig(ctx context.Context, cloudstackMachineConfigName string, kubeconfigFile string, namespace string) (*v1alpha1.CloudStackMachineConfig, error)
	SetEksaControllerEnvVar(ctx context.Context, envVar, envVarVal, kubeconfig string) error
	CreateNamespaceIfNotPresent(ctx context.Context, kubeconfig string, namespace string) error
	ValidateControlPlaneNodes(ctx context.Context, cluster *types.Cluster, clusterName string) error
	ValidateWorkerNodes(ctx context.Context, clusterName string, kubeconfigFile string) error
	CountMachineDeploymentReplicasReady(ctx context.Context, clusterName string, kubeconfigFile string) (int, int, error)
	GetBundles(ctx context.Context, kubeconfigFile, name, namespace string) (*releasev1alpha1.Bundles, error)
	GetApiServerUrl(ctx context.Context, cluster *types.Cluster) (string, error)
	GetClusterCATlsCert(ctx context.Context, clusterName string, cluster *types.Cluster, namespace string) ([]byte, error)
	KubeconfigSecretAvailable(ctx context.Context, kubeconfig string, clusterName string, namespace string) (bool, error)
	DeleteOldWorkerNodeGroup(ctx context.Context, machineDeployment *clusterv1.MachineDeployment, kubeconfig string) error
	GetKubeadmControlPlane(ctx context.Context, cluster *types.Cluster, clusterName string, opts ...executables.KubectlOpt) (*controlplanev1.KubeadmControlPlane, error)
	GetMachineDeploymentsForCluster(ctx context.Context, clusterName string, opts ...executables.KubectlOpt) ([]clusterv1.MachineDeployment, error)
	GetMachineDeployment(ctx context.Context, workerNodeGroupName string, opts ...executables.KubectlOpt) (*clusterv1.MachineDeployment, error)
	GetEksdRelease(ctx context.Context, name, namespace, kubeconfigFile string) (*eksdv1alpha1.Release, error)
	ListObjects(ctx context.Context, resourceType, namespace, kubeconfig string, list kubernetes.ObjectList) error
}

type ClusterManager

type ClusterManager struct {
	Retrier *retrier.Retrier
	// contains filtered or unexported fields
}

func New

func New(clusterClient *RetrierClient, networking Networking, writer filewriter.FileWriter, diagnosticBundleFactory diagnostics.DiagnosticBundleFactory, awsIamAuth AwsIamAuth, eksaComponents EKSAComponents, opts ...ClusterManagerOpt) *ClusterManager

New constructs a new ClusterManager.

func (*ClusterManager) ApplyBundles added in v0.6.0

func (c *ClusterManager) ApplyBundles(ctx context.Context, clusterSpec *cluster.Spec, cluster *types.Cluster) error

func (*ClusterManager) CreateAwsIamAuthCaSecret added in v0.6.0

func (c *ClusterManager) CreateAwsIamAuthCaSecret(ctx context.Context, managementCluster *types.Cluster, workloadClusterName string) error

func (*ClusterManager) CreateEKSANamespace added in v0.11.0

func (c *ClusterManager) CreateEKSANamespace(ctx context.Context, cluster *types.Cluster) error

func (*ClusterManager) CreateEKSAResources

func (c *ClusterManager) CreateEKSAResources(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec,
	datacenterConfig providers.DatacenterConfig, machineConfigs []providers.MachineConfig,
) error

CreateEKSAResources applies the eks-a cluster specs (cluster, datacenterconfig, machine configs, etc.), as well as the release bundle to the cluster. Before applying the spec, we pause eksa controller cluster and datacenter webhook validation so that the cluster spec can be created or updated in the cluster without webhook validation error.

func (*ClusterManager) CreateWorkloadCluster

func (c *ClusterManager) CreateWorkloadCluster(ctx context.Context, managementCluster *types.Cluster, clusterSpec *cluster.Spec, provider providers.Provider) (*types.Cluster, error)

CreateWorkloadCluster creates a workload cluster in the provider that the customer has specified. It applied the kubernetes manifest file on the management cluster, waits for the control plane to be ready, and then generates the kubeconfig for the cluster. It returns a struct of type Cluster containing the name and the kubeconfig of the cluster.

func (*ClusterManager) DeleteCluster

func (c *ClusterManager) DeleteCluster(ctx context.Context, managementCluster, clusterToDelete *types.Cluster, provider providers.Provider, clusterSpec *cluster.Spec) error

func (*ClusterManager) DeletePackageResources added in v0.12.0

func (c *ClusterManager) DeletePackageResources(ctx context.Context, managementCluster *types.Cluster, clusterName string) error

func (*ClusterManager) EKSAClusterSpecChanged

func (c *ClusterManager) EKSAClusterSpecChanged(ctx context.Context, cluster *types.Cluster, newClusterSpec *cluster.Spec) (bool, error)

func (*ClusterManager) GetCurrentClusterSpec added in v0.6.0

func (c *ClusterManager) GetCurrentClusterSpec(ctx context.Context, clus *types.Cluster, clusterName string) (*cluster.Spec, error)

func (*ClusterManager) InstallAwsIamAuth added in v0.6.0

func (c *ClusterManager) InstallAwsIamAuth(ctx context.Context, management, workload *types.Cluster, spec *cluster.Spec) error

InstallAwsIamAuth applies the aws-iam-authenticator manifest based on cluster spec inputs. Generates a kubeconfig for interacting with the cluster with aws-iam-authenticator client.

func (*ClusterManager) InstallCAPI added in v0.6.0

func (c *ClusterManager) InstallCAPI(ctx context.Context, clusterSpec *cluster.Spec, cluster *types.Cluster, provider providers.Provider) error

func (*ClusterManager) InstallCustomComponents

func (c *ClusterManager) InstallCustomComponents(ctx context.Context, clusterSpec *cluster.Spec, cluster *types.Cluster, provider providers.Provider) error

func (*ClusterManager) InstallMachineHealthChecks

func (c *ClusterManager) InstallMachineHealthChecks(ctx context.Context, clusterSpec *cluster.Spec, workloadCluster *types.Cluster) error

func (*ClusterManager) InstallNetworking

func (c *ClusterManager) InstallNetworking(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, provider providers.Provider) error

func (*ClusterManager) InstallStorageClass

func (c *ClusterManager) InstallStorageClass(ctx context.Context, cluster *types.Cluster, provider providers.Provider) error

func (*ClusterManager) MoveCAPI added in v0.6.0

func (c *ClusterManager) MoveCAPI(ctx context.Context, from, to *types.Cluster, clusterName string, clusterSpec *cluster.Spec, checkers ...types.NodeReadyChecker) error

func (*ClusterManager) PauseEKSAControllerReconcile

func (c *ClusterManager) PauseEKSAControllerReconcile(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, provider providers.Provider) error

func (*ClusterManager) ResumeEKSAControllerReconcile

func (c *ClusterManager) ResumeEKSAControllerReconcile(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, provider providers.Provider) error

func (*ClusterManager) RunPostCreateWorkloadCluster added in v0.10.1

func (c *ClusterManager) RunPostCreateWorkloadCluster(ctx context.Context, managementCluster, workloadCluster *types.Cluster, clusterSpec *cluster.Spec) error

func (*ClusterManager) SaveLogsManagementCluster added in v0.6.0

func (c *ClusterManager) SaveLogsManagementCluster(ctx context.Context, spec *cluster.Spec, cluster *types.Cluster) error

func (*ClusterManager) SaveLogsWorkloadCluster added in v0.6.0

func (c *ClusterManager) SaveLogsWorkloadCluster(ctx context.Context, provider providers.Provider, spec *cluster.Spec, cluster *types.Cluster) error

func (*ClusterManager) Upgrade added in v0.13.0

func (c *ClusterManager) Upgrade(ctx context.Context, cluster *types.Cluster, currentSpec, newSpec *cluster.Spec) (*types.ChangeDiff, error)

Upgrade updates the eksa components in a cluster according to a Spec.

func (*ClusterManager) UpgradeCluster

func (c *ClusterManager) UpgradeCluster(ctx context.Context, managementCluster, workloadCluster *types.Cluster, newClusterSpec *cluster.Spec, provider providers.Provider) error

func (*ClusterManager) UpgradeNetworking added in v0.7.0

func (c *ClusterManager) UpgradeNetworking(ctx context.Context, cluster *types.Cluster, currentSpec, newSpec *cluster.Spec, provider providers.Provider) (*types.ChangeDiff, error)

type ClusterManagerOpt

type ClusterManagerOpt func(*ClusterManager)

func WithControlPlaneWaitTimeout added in v0.12.0

func WithControlPlaneWaitTimeout(timeout time.Duration) ClusterManagerOpt

func WithExternalEtcdWaitTimeout added in v0.12.0

func WithExternalEtcdWaitTimeout(timeout time.Duration) ClusterManagerOpt

func WithMachineBackoff added in v0.12.0

func WithMachineBackoff(machineBackoff time.Duration) ClusterManagerOpt

func WithMachineMaxWait added in v0.12.0

func WithMachineMaxWait(machineMaxWait time.Duration) ClusterManagerOpt

func WithMachineMinWait added in v0.12.0

func WithMachineMinWait(machineMinWait time.Duration) ClusterManagerOpt

func WithNodeStartupTimeout added in v0.14.1

func WithNodeStartupTimeout(timeout time.Duration) ClusterManagerOpt

WithNodeStartupTimeout sets the timeout of a machine without a node to be considered to have failed machine health check.

func WithRetrier added in v0.6.0

func WithRetrier(retrier *retrier.Retrier) ClusterManagerOpt

func WithUnhealthyMachineTimeout added in v0.13.0

func WithUnhealthyMachineTimeout(timeout time.Duration) ClusterManagerOpt

WithUnhealthyMachineTimeout sets the timeout of an unhealthy machine health check.

type CreateClusterShim added in v0.13.0

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

CreateClusterShim is a shim that implements the workload.Cluster interface. It leverages existing ClusterManager behavior to create a cluster for new workflows.

func NewCreateClusterShim added in v0.13.0

func NewCreateClusterShim(
	spec *cluster.Spec,
	manager *ClusterManager,
	provider providers.Provider,
) *CreateClusterShim

NewCreateClusterShim returns a new CreateClusterShim instance.

func (CreateClusterShim) CreateAsync added in v0.13.0

func (s CreateClusterShim) CreateAsync(ctx context.Context, management *types.Cluster) error

CreateAsync satisfies the workload.Cluster interface.

func (CreateClusterShim) GetName added in v0.13.0

func (s CreateClusterShim) GetName() string

GetName satisfies the workload.Cluster interface.

func (CreateClusterShim) WaitUntilControlPlaneAvailable added in v0.13.0

func (s CreateClusterShim) WaitUntilControlPlaneAvailable(ctx context.Context, management *types.Cluster) error

WaitUntilControlPlaneAvailable satisfies the workload.Cluster interface.

func (CreateClusterShim) WaitUntilReady added in v0.13.0

func (s CreateClusterShim) WaitUntilReady(ctx context.Context, management *types.Cluster) error

WaitUntilReady satisfies the workload.Cluster interface.

func (CreateClusterShim) WriteKubeconfig added in v0.13.0

func (s CreateClusterShim) WriteKubeconfig(ctx context.Context, w io.Writer, management *types.Cluster) error

WriteKubeconfig satisfies the workload.Cluster interface.

type EKSAComponentGenerator added in v0.13.0

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

EKSAComponentGenerator generates and configures eks-a components.

type EKSAComponents added in v0.13.0

type EKSAComponents interface {
	Install(ctx context.Context, log logr.Logger, cluster *types.Cluster, spec *cluster.Spec) error
	Upgrade(ctx context.Context, log logr.Logger, cluster *types.Cluster, currentSpec, newSpec *cluster.Spec) (*types.ChangeDiff, error)
}

EKSAComponents allows to manage the eks-a components installation in a cluster.

type EKSAInstaller added in v0.13.0

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

EKSAInstaller allows to install eks-a components in a cluster.

func NewEKSAInstaller added in v0.13.0

func NewEKSAInstaller(client KubernetesClient) *EKSAInstaller

NewEKSAInstaller constructs a new EKSAInstaller.

func (*EKSAInstaller) Install added in v0.13.0

func (i *EKSAInstaller) Install(ctx context.Context, log logr.Logger, cluster *types.Cluster, spec *cluster.Spec) error

Install configures and applies eks-a components in a cluster accordingly to a spec.

func (*EKSAInstaller) Upgrade added in v0.13.0

func (i *EKSAInstaller) Upgrade(ctx context.Context, log logr.Logger, cluster *types.Cluster, currentSpec, newSpec *cluster.Spec) (*types.ChangeDiff, error)

Upgrade re-installs the eksa components in a cluster if the VersionBundle defined in the new spec has a different eks-a components version. Workload clusters are ignored.

type KubernetesClient added in v0.13.0

type KubernetesClient interface {
	Apply(ctx context.Context, kubeconfigPath string, obj runtime.Object) error
	ApplyKubeSpecFromBytes(ctx context.Context, cluster *types.Cluster, data []byte) error
	ApplyKubeSpecFromBytesWithNamespace(ctx context.Context, cluster *types.Cluster, data []byte, namespace string) error
	ApplyKubeSpecFromBytesForce(ctx context.Context, cluster *types.Cluster, data []byte) error
	WaitForDeployment(ctx context.Context, cluster *types.Cluster, timeout string, condition string, target string, namespace string) error
	UpdateAnnotationInNamespace(ctx context.Context, resourceType, objectName string, annotations map[string]string, cluster *types.Cluster, namespace string) error
	RemoveAnnotationInNamespace(ctx context.Context, resourceType, objectName, key string, cluster *types.Cluster, namespace string) error
}

KubernetesClient allows to interact with the k8s api server.

type Networking

type Networking interface {
	Install(ctx context.Context, cluster *types.Cluster, clusterSpec *cluster.Spec, namespaces []string) error
	Upgrade(ctx context.Context, cluster *types.Cluster, currentSpec, newSpec *cluster.Spec, namespaces []string) (*types.ChangeDiff, error)
	RunPostControlPlaneUpgradeSetup(ctx context.Context, cluster *types.Cluster) error
}

type RetrierClient added in v0.13.0

type RetrierClient struct {
	*retrier.Retrier
	// contains filtered or unexported fields
}

RetrierClient wraps around a ClusterClient, offering retry functionality for some operations.

func NewRetrierClient added in v0.6.0

func NewRetrierClient(client ClusterClient, retrier *retrier.Retrier) *RetrierClient

NewRetrierClient constructs a new RetrierClient.

func (*RetrierClient) Apply added in v0.13.0

func (c *RetrierClient) Apply(ctx context.Context, kubeconfigPath string, obj runtime.Object) error

Apply creates/updates an object against the api server following a client side apply mechanism.

func (*RetrierClient) ApplyKubeSpecFromBytes added in v0.13.0

func (c *RetrierClient) ApplyKubeSpecFromBytes(ctx context.Context, cluster *types.Cluster, data []byte) error

ApplyKubeSpecFromBytes creates/updates the objects defined in a yaml manifest against the api server following a client side apply mechanism.

func (*RetrierClient) ApplyKubeSpecFromBytesForce added in v0.13.0

func (c *RetrierClient) ApplyKubeSpecFromBytesForce(ctx context.Context, cluster *types.Cluster, data []byte) error

ApplyKubeSpecFromBytesForce creates/updates the objects defined in a yaml manifest against the api server following a client side apply mechanism. It forces the operation, so if api validation failed, it will delete and re-create the object.

func (*RetrierClient) ApplyKubeSpecFromBytesWithNamespace added in v0.13.0

func (c *RetrierClient) ApplyKubeSpecFromBytesWithNamespace(ctx context.Context, cluster *types.Cluster, data []byte, namespace string) error

ApplyKubeSpecFromBytesWithNamespace creates/updates the objects defined in a yaml manifest against the api server following a client side apply mechanism. It applies all objects in the given namespace.

func (*RetrierClient) DeleteAWSIamConfig added in v0.13.0

func (c *RetrierClient) DeleteAWSIamConfig(ctx context.Context, cluster *types.Cluster, name string, namespace string) error

DeleteAWSIamConfig deletes an AWSIamConfig object from the cluster.

func (*RetrierClient) DeleteCluster added in v0.13.0

func (c *RetrierClient) DeleteCluster(ctx context.Context, cluster, clusterToDelete *types.Cluster) error

DeleteCluster deletes a CAPI Cluster from the cluster.

func (*RetrierClient) DeleteEKSACluster added in v0.13.0

func (c *RetrierClient) DeleteEKSACluster(ctx context.Context, cluster *types.Cluster, name string, namespace string) error

DeleteEKSACluster deletes an EKSA Cluster object from the cluster.

func (*RetrierClient) DeleteGitOpsConfig added in v0.13.0

func (c *RetrierClient) DeleteGitOpsConfig(ctx context.Context, cluster *types.Cluster, name string, namespace string) error

DeleteGitOpsConfig deletes a GitOpsConfigObject from the cluster.

func (*RetrierClient) DeleteOIDCConfig added in v0.13.0

func (c *RetrierClient) DeleteOIDCConfig(ctx context.Context, cluster *types.Cluster, name string, namespace string) error

DeleteOIDCConfig deletes a OIDCConfig object from the cluster.

func (*RetrierClient) ListObjects added in v0.13.0

func (c *RetrierClient) ListObjects(ctx context.Context, resourceType, namespace, kubeconfig string, list kubernetes.ObjectList) error

ListObjects reads all Objects of a particular resource type in a namespace.

func (*RetrierClient) RemoveAnnotationInNamespace added in v0.13.0

func (c *RetrierClient) RemoveAnnotationInNamespace(ctx context.Context, resourceType, objectName, key string, cluster *types.Cluster, namespace string) error

RemoveAnnotationInNamespace deletes an annotation for the given kubernetes resource if present.

func (*RetrierClient) UpdateAnnotationInNamespace added in v0.13.0

func (c *RetrierClient) UpdateAnnotationInNamespace(ctx context.Context, resourceType, objectName string, annotations map[string]string, cluster *types.Cluster, namespace string) error

UpdateAnnotationInNamespace adds/updates an annotation for the given kubernetes resource.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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