client

package
v0.3.20 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: Apache-2.0 Imports: 19 Imported by: 32

Documentation

Index

Constants

View Source
const DefaultCustomTemplateConfigMapKey = "template"

DefaultCustomTemplateConfigMapKey where the workload cluster template is hosted.

View Source
const NoopProvider = "-"

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyUpgradeOptions

type ApplyUpgradeOptions struct {
	// Kubeconfig to use for accessing the management cluster. If empty, default discovery rules apply.
	Kubeconfig Kubeconfig

	// ManagementGroup that should be upgraded (e.g. capi-system/cluster-api).
	ManagementGroup string

	// Contract defines the API Version of Cluster API (contract e.g. v1alpha4) the management group should upgrade to.
	// When upgrading by contract, the latest versions available will be used for all the providers; if you want
	// a more granular control on upgrade, use CoreProvider, BootstrapProviders, ControlPlaneProviders, InfrastructureProviders.
	Contract string

	// CoreProvider instance and version (e.g. capi-system/cluster-api:v0.3.0) to upgrade to. This field can be used as alternative to Contract.
	CoreProvider string

	// BootstrapProviders instance and versions (e.g. capi-kubeadm-bootstrap-system/kubeadm:v0.3.0) to upgrade to. This field can be used as alternative to Contract.
	BootstrapProviders []string

	// ControlPlaneProviders instance and versions (e.g. capi-kubeadm-control-plane-system/kubeadm:v0.3.0) to upgrade to. This field can be used as alternative to Contract.
	ControlPlaneProviders []string

	// InfrastructureProviders instance and versions (e.g. capa-system/aws:v0.5.0) to upgrade to. This field can be used as alternative to Contract.
	InfrastructureProviders []string
}

ApplyUpgradeOptions carries the options supported by upgrade apply.

type CertManagerUpgradePlan added in v0.3.10

type CertManagerUpgradePlan cluster.CertManagerUpgradePlan

CertManagerUpgradePlan defines the upgrade plan if cert-manager needs to be upgraded to a different version.

type Client

type Client interface {
	// GetProvidersConfig returns the list of providers configured for this instance of clusterctl.
	GetProvidersConfig() ([]Provider, error)

	// GetProviderComponents returns the provider components for a given provider with options including targetNamespace, watchingNamespace.
	GetProviderComponents(provider string, providerType clusterctlv1.ProviderType, options ComponentsOptions) (Components, error)

	// Init initializes a management cluster by adding the requested list of providers.
	Init(options InitOptions) ([]Components, error)

	// InitImages returns the list of images required for executing the init command.
	InitImages(options InitOptions) ([]string, error)

	// GetClusterTemplate returns a workload cluster template.
	GetClusterTemplate(options GetClusterTemplateOptions) (Template, error)

	// GetKubeconfig returns the kubeconfig of the workload cluster.
	GetKubeconfig(options GetKubeconfigOptions) (string, error)

	// Delete deletes providers from a management cluster.
	Delete(options DeleteOptions) error

	// Move moves all the Cluster API objects existing in a namespace (or from all the namespaces if empty) to a target management cluster.
	Move(options MoveOptions) error

	// PlanUpgrade returns a set of suggested Upgrade plans for the cluster, and more specifically:
	// - Each management group gets separated upgrade plans.
	// - For each management group, an upgrade plan is generated for each API Version of Cluster API (contract) available, e.g.
	//   - Upgrade to the latest version in the the v1alpha2 series: ....
	//   - Upgrade to the latest version in the the v1alpha3 series: ....
	PlanUpgrade(options PlanUpgradeOptions) ([]UpgradePlan, error)

	// PlanCertManagerUpgrade returns a CertManagerUpgradePlan.
	PlanCertManagerUpgrade(options PlanUpgradeOptions) (CertManagerUpgradePlan, error)

	// ApplyUpgrade executes an upgrade plan.
	ApplyUpgrade(options ApplyUpgradeOptions) error

	// ProcessYAML provides a direct way to process a yaml and inspect its
	// variables.
	ProcessYAML(options ProcessYAMLOptions) (YamlPrinter, error)

	// DescribeCluster returns the object tree representing the status of a Cluster API cluster.
	DescribeCluster(options DescribeClusterOptions) (*tree.ObjectTree, error)
}

Client is exposes the clusterctl high-level client library.

func New

func New(path string, options ...Option) (Client, error)

New returns a configClient.

type ClusterClientFactory

type ClusterClientFactory func(ClusterClientFactoryInput) (cluster.Client, error)

type ClusterClientFactoryInput added in v0.3.7

type ClusterClientFactoryInput struct {
	Kubeconfig Kubeconfig
	Processor  Processor
}

ClusterClientFactoryInput reporesents the inputs required by the ClusterClientFactory

type Components

type Components repository.Components

Components wraps a YAML file that defines the provider's components (CRDs, controller, RBAC rules etc.).

type ComponentsOptions added in v0.3.4

type ComponentsOptions repository.ComponentsOptions

ComponentsOptions wraps inputs to get provider's components

type ConfigMapSourceOptions

type ConfigMapSourceOptions struct {
	// Namespace where the ConfigMap exists. If unspecified, the current namespace will be used.
	Namespace string

	// Name to read the workload cluster template from.
	Name string

	// DataKey where the workload cluster template is hosted. If unspecified, the
	// DefaultCustomTemplateConfigMapKey will be used.
	DataKey string
}

ConfigMapSourceOptions defines the options to be used when reading a workload cluster template from a ConfigMap.

type DeleteOptions

type DeleteOptions struct {
	// Kubeconfig defines the kubeconfig to use for accessing the management cluster. If empty,
	// default rules for kubeconfig discovery will be used.
	Kubeconfig Kubeconfig

	// Namespace where the provider to be deleted lives. If unspecified, the namespace name will be inferred
	// from the current configuration.
	Namespace string

	// CoreProvider version (e.g. cluster-api:v0.3.0) to add to the management cluster. If unspecified, the
	// cluster-api core provider's latest release is used.
	CoreProvider string

	// BootstrapProviders and versions (e.g. kubeadm:v0.3.0) to add to the management cluster.
	// If unspecified, the kubeadm bootstrap provider's latest release is used.
	BootstrapProviders []string

	// InfrastructureProviders and versions (e.g. aws:v0.5.0) to add to the management cluster.
	InfrastructureProviders []string

	// ControlPlaneProviders and versions (e.g. kubeadm:v0.3.0) to add to the management cluster.
	// If unspecified, the kubeadm control plane provider latest release is used.
	ControlPlaneProviders []string

	// DeleteAll set for deletion of all the providers.
	DeleteAll bool

	// IncludeNamespace forces the deletion of the namespace where the providers are hosted
	// (and of all the contained objects).
	IncludeNamespace bool

	// IncludeCRDs forces the deletion of the provider's CRDs (and of all the related objects).
	// By Extension, this forces the deletion of all the resources shared among provider instances, like e.g. web-hooks.
	IncludeCRDs bool
}

DeleteOptions carries the options supported by Delete.

type DescribeClusterOptions added in v0.3.13

type DescribeClusterOptions struct {
	// Kubeconfig defines the kubeconfig to use for accessing the management cluster. If empty,
	// default rules for kubeconfig discovery will be used.
	Kubeconfig Kubeconfig

	// Namespace where the workload cluster is located. If unspecified, the current namespace will be used.
	Namespace string

	// ClusterName to be used for the workload cluster.
	ClusterName string

	// ShowOtherConditions is a list of comma separated kind or kind/name for which we should add the ShowObjectConditionsAnnotation
	// to signal to the presentation layer to show all the conditions for the objects.
	ShowOtherConditions string

	// DisableNoEcho disable hiding MachineInfrastructure or BootstrapConfig objects if the object's ready condition is true
	// or it has the same Status, Severity and Reason of the parent's object ready condition (it is an echo)
	DisableNoEcho bool

	// DisableGrouping disable grouping machines objects in case the ready condition
	// has the same Status, Severity and Reason
	DisableGrouping bool
}

DescribeClusterOptions carries the options supported by DescribeCluster.

type GetClusterTemplateOptions

type GetClusterTemplateOptions struct {
	// Kubeconfig defines the kubeconfig to use for accessing the management cluster. If empty,
	// default rules for kubeconfig discovery will be used.
	Kubeconfig Kubeconfig

	// ProviderRepositorySource to be used for reading the workload cluster template from a provider repository;
	// only one template source can be used at time; if not other source will be set, a ProviderRepositorySource
	// will be generated inferring values from the cluster.
	ProviderRepositorySource *ProviderRepositorySourceOptions

	// URLSource to be used for reading the workload cluster template; only one template source can be used at time.
	URLSource *URLSourceOptions

	// ConfigMapSource to be used for reading the workload cluster template; only one template source can be used at time.
	ConfigMapSource *ConfigMapSourceOptions

	// TargetNamespace where the objects describing the workload cluster should be deployed. If unspecified,
	// the current namespace will be used.
	TargetNamespace string

	// ClusterName to be used for the workload cluster.
	ClusterName string

	// KubernetesVersion to use for the workload cluster. If unspecified, the value from os env variables
	// or the .cluster-api/clusterctl.yaml config file will be used.
	KubernetesVersion string

	// ControlPlaneMachineCount defines the number of control plane machines to be added to the workload cluster.
	// It can be set through the cli flag, CONTROL_PLANE_MACHINE_COUNT environment variable or will default to 1
	ControlPlaneMachineCount *int64

	// WorkerMachineCount defines number of worker machines to be added to the workload cluster.
	// It can be set through the cli flag, WORKER_MACHINE_COUNT environment variable or will default to 0
	WorkerMachineCount *int64

	// ListVariablesOnly sets the GetClusterTemplate method to return the list of variables expected by the template
	// without executing any further processing.
	ListVariablesOnly bool

	// YamlProcessor defines the yaml processor to use for the cluster
	// template processing. If not defined, SimpleProcessor will be used.
	YamlProcessor Processor
}

GetClusterTemplateOptions carries the options supported by GetClusterTemplate.

type GetKubeconfigOptions added in v0.3.9

type GetKubeconfigOptions struct {
	// Kubeconfig defines the kubeconfig to use for accessing the management cluster. If empty,
	// default rules for kubeconfig discovery will be used.
	Kubeconfig Kubeconfig

	// Namespace is the namespace in which secret is placed.
	Namespace string

	// WorkloadClusterName is the name of the workload cluster.
	WorkloadClusterName string
}

GetKubeconfigOptions carries all the options supported by GetKubeconfig

type InitOptions

type InitOptions struct {
	// Kubeconfig defines the kubeconfig to use for accessing the management cluster. If empty,
	// default rules for kubeconfig discovery will be used.
	Kubeconfig Kubeconfig

	// CoreProvider version (e.g. cluster-api:v0.3.0) to add to the management cluster. If unspecified, the
	// cluster-api core provider's latest release is used.
	CoreProvider string

	// BootstrapProviders and versions (e.g. kubeadm:v0.3.0) to add to the management cluster.
	// If unspecified, the kubeadm bootstrap provider's latest release is used.
	BootstrapProviders []string

	// InfrastructureProviders and versions (e.g. aws:v0.5.0) to add to the management cluster.
	InfrastructureProviders []string

	// ControlPlaneProviders and versions (e.g. kubeadm:v0.3.0) to add to the management cluster.
	// If unspecified, the kubeadm control plane provider latest release is used.
	ControlPlaneProviders []string

	// TargetNamespace defines the namespace where the providers should be deployed. If unspecified, each provider
	// will be installed in a provider's default namespace.
	TargetNamespace string

	// WatchingNamespace defines the namespace the providers should watch to reconcile Cluster API objects.
	// If unspecified, the providers watches for Cluster API objects across all namespaces.
	WatchingNamespace string

	// LogUsageInstructions instructs the init command to print the usage instructions in case of first run.
	LogUsageInstructions bool
	// contains filtered or unexported fields
}

InitOptions carries the options supported by Init.

type Kubeconfig added in v0.3.4

type Kubeconfig cluster.Kubeconfig

Kubeconfig is a type that specifies inputs related to the actual kubeconfig.

type MoveOptions

type MoveOptions struct {
	// FromKubeconfig defines the kubeconfig to use for accessing the source management cluster. If empty,
	// default rules for kubeconfig discovery will be used.
	FromKubeconfig Kubeconfig

	// ToKubeconfig defines the kubeconfig to use for accessing the target management cluster. If empty,
	// default rules for kubeconfig discovery will be used.
	ToKubeconfig Kubeconfig

	// Namespace where the objects describing the workload cluster exists. If unspecified, the current
	// namespace will be used.
	Namespace string

	// DryRun means the move action is a dry run, no real action will be performed
	DryRun bool
}

MoveOptions carries the options supported by move.

type Option

type Option func(*clusterctlClient)

Option is a configuration option supplied to New

func InjectClusterClientFactory

func InjectClusterClientFactory(factory ClusterClientFactory) Option

InjectClusterClientFactory allows to override the default factory used for creating ClusterClient objects.

func InjectConfig

func InjectConfig(config config.Client) Option

InjectConfig allows to override the default configuration client used by clusterctl.

func InjectRepositoryFactory

func InjectRepositoryFactory(factory RepositoryClientFactory) Option

InjectRepositoryFactory allows to override the default factory used for creating RepositoryClient objects.

type PlanUpgradeOptions

type PlanUpgradeOptions struct {
	// Kubeconfig defines the kubeconfig to use for accessing the management cluster. If empty, default discovery rules apply.
	Kubeconfig Kubeconfig
}

PlanUpgradeOptions carries the options supported by upgrade plan.

type ProcessYAMLOptions added in v0.3.8

type ProcessYAMLOptions struct {
	ReaderSource *ReaderSourceOptions
	// URLSource to be used for reading the template
	URLSource *URLSourceOptions

	// ListVariablesOnly return the list of variables expected by the template
	// without executing any further processing.
	ListVariablesOnly bool
}

ProcessYAMLOptions are the options supported by ProcessYAML.

type Processor added in v0.3.7

type Processor yaml.Processor

Processor defines the methods necessary for creating a specific yaml processor.

type Provider

type Provider config.Provider

Provider defines a provider configuration.

type ProviderRepositorySourceOptions

type ProviderRepositorySourceOptions struct {
	// InfrastructureProvider to read the workload cluster template from. If unspecified, the default
	// infrastructure provider will be used if no other sources are specified.
	InfrastructureProvider string

	// Flavor defines The workload cluster template variant to be used when reading from the infrastructure
	// provider repository. If unspecified, the default cluster template will be used.
	Flavor string
}

ProviderRepositorySourceOptions defines the options to be used when reading a workload cluster template from a provider repository.

type ReaderSourceOptions added in v0.3.8

type ReaderSourceOptions struct {
	Reader io.Reader
}

ReaderSourceOptions define the options to be used when reading a template from an arbitrary reader

type RepositoryClientFactory

type RepositoryClientFactory func(RepositoryClientFactoryInput) (repository.Client, error)

type RepositoryClientFactoryInput added in v0.3.7

type RepositoryClientFactoryInput struct {
	Provider  Provider
	Processor Processor
}

RepositoryClientFactoryInput represents the inputs required by the RepositoryClientFactory

type Template

type Template repository.Template

Template wraps a YAML file that defines the cluster objects (Cluster, Machines etc.).

type URLSourceOptions

type URLSourceOptions struct {
	// URL to read the workload cluster template from.
	URL string
}

URLSourceOptions defines the options to be used when reading a workload cluster template from an URL.

type UpgradePlan

type UpgradePlan cluster.UpgradePlan

UpgradePlan defines a list of possible upgrade targets for a management group.

type YamlPrinter added in v0.3.8

type YamlPrinter interface {
	// Variables required by the template.
	Variables() []string

	// Yaml returns yaml defining all the cluster template objects as a byte array.
	Yaml() ([]byte, error)
}

YamlPrinter exposes methods that prints the processed template and variables.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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