Documentation ¶
Overview ¶
Package clusterctl implements clusterctl interaction.
Index ¶
- Constants
- func AdjustConfigPathForBinary(clusterctlBinaryPath, clusterctlConfigPath string) string
- func ApplyClusterTemplateAndWait(ctx context.Context, input ApplyClusterTemplateAndWaitInput, ...)
- func ApplyCustomClusterTemplateAndWait(ctx context.Context, input ApplyCustomClusterTemplateAndWaitInput, ...)
- func ConfigCluster(ctx context.Context, input ConfigClusterInput) []byte
- func ConfigClusterWithBinary(_ context.Context, clusterctlBinaryPath string, input ConfigClusterInput) []byte
- func CopyAndAmendClusterctlConfig(_ context.Context, input CopyAndAmendClusterctlConfigInput) error
- func CreateRepository(ctx context.Context, input CreateRepositoryInput) string
- func Delete(ctx context.Context, input DeleteInput)
- func Init(ctx context.Context, input InitInput)
- func InitManagementClusterAndWatchControllerLogs(ctx context.Context, input InitManagementClusterAndWatchControllerLogsInput, ...)
- func InitWithBinary(_ context.Context, binary string, input InitInput)
- func Move(ctx context.Context, input MoveInput)
- func ResolveRelease(ctx context.Context, releaseMarker string) (string, error)
- func Upgrade(ctx context.Context, input UpgradeInput)
- func UpgradeManagementClusterAndWait(ctx context.Context, input UpgradeManagementClusterAndWaitInput, ...)
- func UpgradeWithBinary(ctx context.Context, binary string, input UpgradeInput) error
- func YAMLForComponentSource(ctx context.Context, source ProviderVersionSource) ([]byte, error)
- type ApplyClusterTemplateAndWaitInput
- type ApplyClusterTemplateAndWaitResult
- type ApplyCustomClusterTemplateAndWaitInput
- type ApplyCustomClusterTemplateAndWaitResult
- type ComponentConfig
- type ComponentReplacement
- type ComponentSourceType
- type ComponentWaiter
- type ComponentWaiterType
- type ConfigClusterInput
- type ContainerImage
- type ControlPlaneWaiters
- type CopyAndAmendClusterctlConfigInput
- type CreateRepositoryInput
- type DeleteInput
- type E2EConfig
- func (c *E2EConfig) AbsPaths(basePath string)
- func (c *E2EConfig) AddonProviders() []string
- func (c *E2EConfig) DeepCopy() *E2EConfig
- func (c *E2EConfig) Defaults()
- func (c *E2EConfig) GetInt32PtrVariable(varName string) *int32
- func (c *E2EConfig) GetInt64PtrVariable(varName string) *int64
- func (c *E2EConfig) GetIntervals(spec, key string) []interface{}
- func (c *E2EConfig) GetProviderLatestVersionsByContract(contract string, providers ...string) []string
- func (c *E2EConfig) GetProviderVersions(provider string) []string
- func (c *E2EConfig) GetProvidersWithOldestVersion(providers ...string) []string
- func (c *E2EConfig) GetVariable(varName string) string
- func (c *E2EConfig) HasDockerProvider() bool
- func (c *E2EConfig) HasVariable(varName string) bool
- func (c *E2EConfig) IPAMProviders() []string
- func (c *E2EConfig) InfrastructureProviders() []string
- func (c *E2EConfig) ResolveReleases(ctx context.Context) error
- func (c *E2EConfig) RuntimeExtensionProviders() []string
- func (c *E2EConfig) Validate() error
- type Files
- type InitInput
- type InitManagementClusterAndWatchControllerLogsInput
- type LoadE2EConfigInput
- type LoadImageBehavior
- type MoveInput
- type ProviderConfig
- type ProviderVersionSource
- type RepositoryFileTransformation
- type UpgradeInput
- type UpgradeManagementClusterAndWaitInput
- type Waiter
Constants ¶
const (
// DefaultFlavor for ConfigClusterInput; use it for getting the cluster-template.yaml file.
DefaultFlavor = ""
)
const (
// DefaultInfrastructureProvider for ConfigClusterInput; use it for using the only infrastructure provider installed in a cluster.
DefaultInfrastructureProvider = ""
)
Variables ¶
This section is empty.
Functions ¶
func AdjustConfigPathForBinary ¶ added in v1.3.0
AdjustConfigPathForBinary adjusts the clusterctlConfigPath in case the clusterctl version v1.3.
func ApplyClusterTemplateAndWait ¶
func ApplyClusterTemplateAndWait(ctx context.Context, input ApplyClusterTemplateAndWaitInput, result *ApplyClusterTemplateAndWaitResult)
ApplyClusterTemplateAndWait gets a cluster template using clusterctl, and waits for the cluster to be ready. Important! this method assumes the cluster uses a KubeadmControlPlane and MachineDeployments.
func ApplyCustomClusterTemplateAndWait ¶ added in v1.5.0
func ApplyCustomClusterTemplateAndWait(ctx context.Context, input ApplyCustomClusterTemplateAndWaitInput, result *ApplyCustomClusterTemplateAndWaitResult)
func ConfigCluster ¶
func ConfigCluster(ctx context.Context, input ConfigClusterInput) []byte
ConfigCluster gets a workload cluster based on a template.
func ConfigClusterWithBinary ¶
func ConfigClusterWithBinary(_ context.Context, clusterctlBinaryPath string, input ConfigClusterInput) []byte
ConfigClusterWithBinary uses clusterctl binary to run config cluster or generate cluster. NOTE: This func detects the clusterctl version and uses config cluster or generate cluster accordingly. We can drop the detection when we don't have to support clusterctl v0.3.x anymore.
func CopyAndAmendClusterctlConfig ¶ added in v1.7.0
func CopyAndAmendClusterctlConfig(_ context.Context, input CopyAndAmendClusterctlConfigInput) error
CopyAndAmendClusterctlConfig copies the clusterctl-config from ClusterctlConfigPath to OutputPath and adds the given Variables.
func CreateRepository ¶
func CreateRepository(ctx context.Context, input CreateRepositoryInput) string
CreateRepository creates a clusterctl local repository based on the e2e test config, and the returns the path to a clusterctl config file to be used for working with such repository.
func Delete ¶ added in v1.1.0
func Delete(ctx context.Context, input DeleteInput)
Delete calls clusterctl delete --all.
func InitManagementClusterAndWatchControllerLogs ¶
func InitManagementClusterAndWatchControllerLogs(ctx context.Context, input InitManagementClusterAndWatchControllerLogsInput, intervals ...interface{})
InitManagementClusterAndWatchControllerLogs initializes a management using clusterctl and setup watches for controller logs. Important: Considering we want to support test suites using existing clusters, clusterctl init is executed only in case there are no provider controllers in the cluster; but controller logs watchers are created regardless of the pre-existing providers.
func InitWithBinary ¶
InitWithBinary uses clusterctl binary to run init with the list of providers defined in the local repository.
func ResolveRelease ¶ added in v1.7.0
func Upgrade ¶
func Upgrade(ctx context.Context, input UpgradeInput)
Upgrade calls clusterctl upgrade apply with the list of providers defined in the local repository.
func UpgradeManagementClusterAndWait ¶
func UpgradeManagementClusterAndWait(ctx context.Context, input UpgradeManagementClusterAndWaitInput, intervals ...interface{})
UpgradeManagementClusterAndWait upgrades provider a management cluster using clusterctl, and waits for the cluster to be ready.
func UpgradeWithBinary ¶ added in v1.6.2
func UpgradeWithBinary(ctx context.Context, binary string, input UpgradeInput) error
UpgradeWithBinary calls clusterctl upgrade apply with the list of providers defined in the local repository.
func YAMLForComponentSource ¶
func YAMLForComponentSource(ctx context.Context, source ProviderVersionSource) ([]byte, error)
YAMLForComponentSource returns the YAML for the provided component source.
Types ¶
type ApplyClusterTemplateAndWaitInput ¶
type ApplyClusterTemplateAndWaitInput struct { ClusterProxy framework.ClusterProxy ConfigCluster ConfigClusterInput CNIManifestPath string WaitForClusterIntervals []interface{} WaitForControlPlaneIntervals []interface{} WaitForMachineDeployments []interface{} WaitForMachinePools []interface{} CreateOrUpdateOpts []framework.CreateOrUpdateOption // options to be passed to CreateOrUpdate function config PreWaitForCluster func() PostMachinesProvisioned func() ControlPlaneWaiters }
ApplyClusterTemplateAndWaitInput is the input type for ApplyClusterTemplateAndWait.
type ApplyClusterTemplateAndWaitResult ¶
type ApplyClusterTemplateAndWaitResult struct { ClusterClass *clusterv1.ClusterClass Cluster *clusterv1.Cluster ControlPlane *controlplanev1.KubeadmControlPlane MachineDeployments []*clusterv1.MachineDeployment MachinePools []*expv1.MachinePool }
ApplyClusterTemplateAndWaitResult is the output type for ApplyClusterTemplateAndWait.
func (*ApplyClusterTemplateAndWaitResult) ExpectedTotalNodes ¶ added in v0.4.2
func (r *ApplyClusterTemplateAndWaitResult) ExpectedTotalNodes() int32
ExpectedTotalNodes returns the expected number of nodes that will be provisioned by the given cluster template.
func (*ApplyClusterTemplateAndWaitResult) ExpectedWorkerNodes ¶ added in v0.4.2
func (r *ApplyClusterTemplateAndWaitResult) ExpectedWorkerNodes() int32
ExpectedWorkerNodes returns the expected number of worker nodes that will be provisioned by the given cluster template.
type ApplyCustomClusterTemplateAndWaitInput ¶ added in v1.5.0
type ApplyCustomClusterTemplateAndWaitInput struct { ClusterProxy framework.ClusterProxy CustomTemplateYAML []byte ClusterName string Namespace string CNIManifestPath string Flavor string WaitForClusterIntervals []interface{} WaitForControlPlaneIntervals []interface{} WaitForMachineDeployments []interface{} WaitForMachinePools []interface{} CreateOrUpdateOpts []framework.CreateOrUpdateOption // options to be passed to CreateOrUpdate function config PreWaitForCluster func() PostMachinesProvisioned func() ControlPlaneWaiters }
ApplyCustomClusterTemplateAndWaitInput is the input type for ApplyCustomClusterTemplateAndWait.
type ApplyCustomClusterTemplateAndWaitResult ¶ added in v1.5.0
type ApplyCustomClusterTemplateAndWaitResult struct { ClusterClass *clusterv1.ClusterClass Cluster *clusterv1.Cluster ControlPlane *controlplanev1.KubeadmControlPlane MachineDeployments []*clusterv1.MachineDeployment MachinePools []*expv1.MachinePool }
type ComponentConfig ¶
type ComponentConfig struct { // Name is the name of the component. // This field is primarily used for logging. Name string `json:"name"` // Sources is an optional list of component YAML to apply to the management // cluster. // This field may be omitted when wanting only to block progress via one or // more Waiters. Sources []ProviderVersionSource `json:"sources,omitempty"` // Waiters is an optional list of checks to perform in order to determine // whether or not the installed components are ready. Waiters []ComponentWaiter `json:"waiters,omitempty"` }
ComponentConfig describes a component required by the e2e test environment.
type ComponentReplacement ¶
type ComponentReplacement struct { // Old is the pattern to replace. // A regular expression may be used. Old string `json:"old"` // New is the string used to replace the old pattern. // An empty string is valid. New string `json:"new,omitempty"` }
ComponentReplacement is used to replace some of the generated YAML prior to application.
type ComponentSourceType ¶
type ComponentSourceType string
ComponentSourceType indicates how a component's source should be obtained.
const ( // URLSource is component YAML available directly via a URL. // The URL may begin with http://, https:// or file://(can be omitted, relative paths supported). URLSource ComponentSourceType = "url" // KustomizeSource is a valid kustomization root that can be used to produce // the component YAML. KustomizeSource ComponentSourceType = "kustomize" )
type ComponentWaiter ¶
type ComponentWaiter struct { // Value varies depending on the specified Type. // Please see the documentation for the different WaiterType constants to // understand the valid values for this field. Value string `json:"value"` // Type describes the type of check to perform. // // Defaults to "pods". Type ComponentWaiterType `json:"type,omitempty"` }
ComponentWaiter contains information to help determine whether installed components are ready.
type ComponentWaiterType ¶
type ComponentWaiterType string
ComponentWaiterType indicates the type of check to use to determine if the installed components are ready.
const ( // ServiceWaiter indicates to wait until a service's condition is Available. // When ComponentWaiter.Value is set to "service", the ComponentWaiter.Value // should be set to the name of a Service resource. ServiceWaiter ComponentWaiterType = "service" // PodsWaiter indicates to wait until all the pods in a namespace have a // condition of Ready. // When ComponentWaiter.Value is set to "pods", the ComponentWaiter.Value // should be set to the name of a Namespace resource. PodsWaiter ComponentWaiterType = "pods" )
type ConfigClusterInput ¶
type ConfigClusterInput struct { LogFolder string ClusterctlConfigPath string KubeconfigPath string InfrastructureProvider string Namespace string ClusterName string KubernetesVersion string ControlPlaneMachineCount *int64 WorkerMachineCount *int64 Flavor string ClusterctlVariables map[string]string }
ConfigClusterInput is the input for ConfigCluster.
type ContainerImage ¶
type ContainerImage struct { // Name is the fully qualified name of the image. Name string // LoadBehavior may be used to dictate whether a failed load operation // should fail the test run. This is useful when wanting to load images // *if* they exist locally, but not wanting to fail if they don't. // // Defaults to MustLoadImage. LoadBehavior LoadImageBehavior }
ContainerImage describes an image to load into a cluster and the behavior when loading the image.
type ControlPlaneWaiters ¶
type ControlPlaneWaiters struct { WaitForControlPlaneInitialized Waiter WaitForControlPlaneMachinesReady Waiter }
ControlPlaneWaiters are Waiter functions for the control plane.
type CopyAndAmendClusterctlConfigInput ¶ added in v1.7.0
type CopyAndAmendClusterctlConfigInput struct { ClusterctlConfigPath string OutputPath string Variables map[string]string }
CopyAndAmendClusterctlConfigInput is the input for copyAndAmendClusterctlConfig.
type CreateRepositoryInput ¶
type CreateRepositoryInput struct { RepositoryFolder string E2EConfig *E2EConfig FileTransformations []RepositoryFileTransformation }
CreateRepositoryInput is the input for CreateRepository.
func (*CreateRepositoryInput) RegisterClusterResourceSetConfigMapTransformation ¶
func (i *CreateRepositoryInput) RegisterClusterResourceSetConfigMapTransformation(manifestPath, envSubstVar string)
RegisterClusterResourceSetConfigMapTransformation registers a FileTransformations that injects a manifests file into a ConfigMap that defines a ClusterResourceSet resource.
NOTE: this transformation is specifically designed for replacing "data: ${envSubstVar}".
type DeleteInput ¶ added in v1.1.0
DeleteInput is the input for Delete.
type E2EConfig ¶
type E2EConfig struct { // Name is the name of the Kind management cluster. // Defaults to test-[random generated suffix]. ManagementClusterName string `json:"managementClusterName,omitempty"` // Images is a list of container images to load into the Kind cluster. Images []ContainerImage `json:"images,omitempty"` // Providers is a list of providers to be configured in the local repository that will be created for the e2e test. // It is required to provide following providers // - cluster-api // - bootstrap kubeadm // - control-plane kubeadm // - one infrastructure provider // The test will adapt to the selected infrastructure provider Providers []ProviderConfig `json:"providers,omitempty"` // Variables to be added to the clusterctl config file // Please note that clusterctl read variables from OS environment variables as well, so you can avoid to hard code // sensitive data in the config file. Variables map[string]string `json:"variables,omitempty"` // Intervals to be used for long operations during tests Intervals map[string][]string `json:"intervals,omitempty"` }
E2EConfig defines the configuration of an e2e test environment.
func LoadE2EConfig ¶
func LoadE2EConfig(ctx context.Context, input LoadE2EConfigInput) *E2EConfig
LoadE2EConfig loads the configuration for the e2e test environment.
func (*E2EConfig) AddonProviders ¶ added in v1.5.0
AddonProviders returns the add-on provider selected for running this E2E test.
func (*E2EConfig) Defaults ¶
func (c *E2EConfig) Defaults()
Defaults assigns default values to the object. More specifically: - ManagementClusterName gets a default name if empty. - Providers version gets type KustomizeSource if not otherwise specified. - Providers file gets targetName = sourceName if not otherwise specified. - Images gets LoadBehavior = MustLoadImage if not otherwise specified.
func (*E2EConfig) GetInt32PtrVariable ¶
GetInt32PtrVariable returns an Int32Ptr variable from the e2e config file.
func (*E2EConfig) GetInt64PtrVariable ¶
GetInt64PtrVariable returns an Int64Ptr variable from the e2e config file.
func (*E2EConfig) GetIntervals ¶
GetIntervals returns the intervals to be applied to a Eventually operation. It searches for [spec]/[key] intervals first, and if it is not found, it searches for default/[key]. If also the default/[key] intervals are not found, ginkgo DefaultEventuallyTimeout and DefaultEventuallyPollingInterval are used.
func (*E2EConfig) GetProviderLatestVersionsByContract ¶ added in v1.0.0
func (*E2EConfig) GetProviderVersions ¶
GetProviderVersions returns the sorted list of versions defined for a provider.
func (*E2EConfig) GetProvidersWithOldestVersion ¶
func (*E2EConfig) GetVariable ¶
GetVariable returns a variable from environment variables or from the e2e config file.
func (*E2EConfig) HasDockerProvider ¶
func (*E2EConfig) HasVariable ¶
func (*E2EConfig) IPAMProviders ¶ added in v1.3.0
IPAMProviders returns the IPAM provider selected for running this E2E test.
func (*E2EConfig) InfrastructureProviders ¶
InfrastructureProviders returns the infrastructure provider selected for running this E2E test.
func (*E2EConfig) ResolveReleases ¶ added in v1.7.0
ResolveReleases converts release markers to release version.
func (*E2EConfig) RuntimeExtensionProviders ¶ added in v1.3.0
RuntimeExtensionProviders returns the runtime extension provider selected for running this E2E test.
func (*E2EConfig) Validate ¶
Validate validates the configuration. More specifically: - ManagementClusterName should not be empty. - There should be one CoreProvider (cluster-api), one BootstrapProvider (kubeadm), one ControlPlaneProvider (kubeadm). - There should be one InfraProvider (pick your own). - Image should have name and loadBehavior be one of [mustload, tryload]. - Intervals should be valid ginkgo intervals.
type Files ¶
type Files struct { // SourcePath path of the file. SourcePath string `json:"sourcePath"` // TargetName name of the file copied into the local repository. if empty, the source name // Will be preserved TargetName string `json:"targetName,omitempty"` }
Files contains information about files to be copied into the local repository.
type InitInput ¶
type InitInput struct { LogFolder string ClusterctlConfigPath string KubeconfigPath string CoreProvider string BootstrapProviders []string ControlPlaneProviders []string InfrastructureProviders []string IPAMProviders []string RuntimeExtensionProviders []string AddonProviders []string }
InitInput is the input for Init.
type InitManagementClusterAndWatchControllerLogsInput ¶
type InitManagementClusterAndWatchControllerLogsInput struct { ClusterProxy framework.ClusterProxy ClusterctlConfigPath string CoreProvider string BootstrapProviders []string ControlPlaneProviders []string InfrastructureProviders []string IPAMProviders []string RuntimeExtensionProviders []string AddonProviders []string LogFolder string DisableMetricsCollection bool ClusterctlBinaryPath string }
InitManagementClusterAndWatchControllerLogsInput is the input type for InitManagementClusterAndWatchControllerLogs.
type LoadE2EConfigInput ¶
type LoadE2EConfigInput struct { // ConfigPath for the e2e test. ConfigPath string }
LoadE2EConfigInput is the input for LoadE2EConfig.
type LoadImageBehavior ¶
type LoadImageBehavior string
LoadImageBehavior indicates the behavior when loading an image.
const ( // MustLoadImage causes a load operation to fail if the image cannot be // loaded. MustLoadImage LoadImageBehavior = "mustLoad" // TryLoadImage causes any errors that occur when loading an image to be // ignored. TryLoadImage LoadImageBehavior = "tryLoad" )
type MoveInput ¶
type MoveInput struct { LogFolder string ClusterctlConfigPath string FromKubeconfigPath string ToKubeconfigPath string Namespace string }
MoveInput is the input for ClusterctlMove.
type ProviderConfig ¶
type ProviderConfig struct { // Name is the name of the provider. Name string `json:"name"` // Type is the type of the provider. Type string `json:"type"` // Versions is a list of component YAML to be added to the local repository, one for each release. // Please note that the first source will be used a default release for this provider. Versions []ProviderVersionSource `json:"versions,omitempty"` // Files is a list of files to be copied into the local repository for all the releases. Files []Files `json:"files,omitempty"` }
ProviderConfig describes a provider to be configured in the local repository that will be created for the e2e test.
type ProviderVersionSource ¶
type ProviderVersionSource struct { // Name is used for logging when a component has multiple sources. Name string `json:"name,omitempty"` // Value is the source of the component's YAML. // May be a URL or a kustomization root (specified by Type). // If a Type=url then Value may begin with file://, http://, or https://. // If a Type=kustomize then Value may be any valid go-getter URL. For // more information please see https://github.com/hashicorp/go-getter#url-format. Value string `json:"value"` // Contract defines the Cluster API contract version a specific version of the provider abides to. Contract string `json:"contract,omitempty"` // Type describes how to process the source of the component's YAML. // // Defaults to "kustomize". Type ComponentSourceType `json:"type,omitempty"` // Replacements is a list of patterns to replace in the component YAML // prior to application. Replacements []ComponentReplacement `json:"replacements,omitempty"` // Files is a list of files to be copied into the local repository for this release. Files []Files `json:"files,omitempty"` }
ProviderVersionSource describes how to obtain a component's YAML.
type RepositoryFileTransformation ¶
RepositoryFileTransformation is a helpers for managing a clusterctl local repository to be used for running e2e tests in isolation.
type UpgradeInput ¶
type UpgradeInput struct { LogFolder string ClusterctlConfigPath string ClusterctlVariables map[string]string ClusterName string KubeconfigPath string Contract string CoreProvider string BootstrapProviders []string ControlPlaneProviders []string InfrastructureProviders []string IPAMProviders []string RuntimeExtensionProviders []string AddonProviders []string }
UpgradeInput is the input for Upgrade.
type UpgradeManagementClusterAndWaitInput ¶
type UpgradeManagementClusterAndWaitInput struct { ClusterProxy framework.ClusterProxy ClusterctlConfigPath string ClusterctlVariables map[string]string Contract string CoreProvider string BootstrapProviders []string ControlPlaneProviders []string InfrastructureProviders []string IPAMProviders []string RuntimeExtensionProviders []string AddonProviders []string LogFolder string ClusterctlBinaryPath string }
UpgradeManagementClusterAndWaitInput is the input type for UpgradeManagementClusterAndWait.
type Waiter ¶
type Waiter func(ctx context.Context, input ApplyCustomClusterTemplateAndWaitInput, result *ApplyCustomClusterTemplateAndWaitResult)
Waiter is a function that runs and waits for a long-running operation to finish and updates the result.