Documentation
¶
Overview ¶
Package setup provides helpers for cluster creation and setup workflows. It contains component installers, CNI setup, and registry stage handling that are used by the cluster create command.
Index ¶
- Variables
- func EnsureArgoCDResources(ctx context.Context, kubeconfig string, clusterCfg *v1alpha1.Cluster, ...) error
- func HelmClientForCluster(clusterCfg *v1alpha1.Cluster) (*helm.Client, string, error)
- func InstallArgoCDSilent(ctx context.Context, clusterCfg *v1alpha1.Cluster, ...) error
- func InstallCNI(cmd *cobra.Command, clusterCfg *v1alpha1.Cluster, tmr timer.Timer) (bool, error)
- func InstallCSISilent(ctx context.Context, clusterCfg *v1alpha1.Cluster, ...) error
- func InstallCertManagerSilent(ctx context.Context, clusterCfg *v1alpha1.Cluster, ...) error
- func InstallFluxSilent(ctx context.Context, clusterCfg *v1alpha1.Cluster, ...) error
- func InstallLoadBalancerSilent(ctx context.Context, clusterCfg *v1alpha1.Cluster, ...) error
- func InstallMetricsServerSilent(ctx context.Context, clusterCfg *v1alpha1.Cluster, ...) error
- func InstallPolicyEngineSilent(ctx context.Context, clusterCfg *v1alpha1.Cluster, ...) error
- func InstallPostCNIComponents(cmd *cobra.Command, clusterCfg *v1alpha1.Cluster, ...) error
- func NeedsLoadBalancerInstall(clusterCfg *v1alpha1.Cluster) bool
- func NeedsMetricsServerInstall(clusterCfg *v1alpha1.Cluster) bool
- func RunDockerStage(cmd *cobra.Command, tmr timer.Timer, info StageInfo, ...) error
- func ShouldPushOCIArtifact(clusterCfg *v1alpha1.Cluster) bool
- type ComponentRequirements
- type DockerClientInvoker
- type InstallerFactories
- type StageInfo
Constants ¶
This section is empty.
Variables ¶
var ( ErrCertManagerInstallerFactoryNil = errors.New("cert-manager installer factory is nil") ErrArgoCDInstallerFactoryNil = errors.New("argocd installer factory is nil") ErrKubeletCSRApproverInstallerFactoryNil = errors.New( "kubelet-csr-approver installer factory is nil", ) ErrCSIInstallerFactoryNil = errors.New("CSI installer factory is nil") ErrPolicyEngineInstallerFactoryNil = errors.New("policy engine installer factory is nil") ErrPolicyEngineDisabled = errors.New("policy engine is disabled") ErrClusterConfigNil = errors.New("cluster config is nil") )
Errors for component installation.
var ErrUnsupportedCNI = errors.New("unsupported CNI type")
ErrUnsupportedCNI is returned when an unsupported CNI type is encountered.
Functions ¶
func EnsureArgoCDResources ¶
func EnsureArgoCDResources( ctx context.Context, kubeconfig string, clusterCfg *v1alpha1.Cluster, clusterName string, ) error
EnsureArgoCDResources configures default Argo CD resources post-install.
func HelmClientForCluster ¶
HelmClientForCluster creates a Helm client configured for the cluster.
func InstallArgoCDSilent ¶
func InstallArgoCDSilent( ctx context.Context, clusterCfg *v1alpha1.Cluster, factories *InstallerFactories, ) error
InstallArgoCDSilent installs ArgoCD silently for parallel execution.
func InstallCNI ¶
InstallCNI installs the configured CNI for the cluster. Returns true if a CNI was installed, false if using default/none.
func InstallCSISilent ¶
func InstallCSISilent( ctx context.Context, clusterCfg *v1alpha1.Cluster, factories *InstallerFactories, ) error
InstallCSISilent installs CSI silently for parallel execution.
func InstallCertManagerSilent ¶
func InstallCertManagerSilent( ctx context.Context, clusterCfg *v1alpha1.Cluster, factories *InstallerFactories, ) error
InstallCertManagerSilent installs cert-manager silently for parallel execution.
func InstallFluxSilent ¶
func InstallFluxSilent( ctx context.Context, clusterCfg *v1alpha1.Cluster, factories *InstallerFactories, ) error
InstallFluxSilent installs Flux silently for parallel execution.
func InstallLoadBalancerSilent ¶ added in v5.28.9
func InstallLoadBalancerSilent( ctx context.Context, clusterCfg *v1alpha1.Cluster, factories *InstallerFactories, ) error
InstallLoadBalancerSilent installs LoadBalancer support silently for parallel execution. For Vanilla (Kind) × Docker, starts the Cloud Provider KIND controller as a Docker container. For Talos × Docker, installs MetalLB.
func InstallMetricsServerSilent ¶
func InstallMetricsServerSilent( ctx context.Context, clusterCfg *v1alpha1.Cluster, factories *InstallerFactories, ) error
InstallMetricsServerSilent installs metrics-server silently for parallel execution.
func InstallPolicyEngineSilent ¶ added in v5.17.0
func InstallPolicyEngineSilent( ctx context.Context, clusterCfg *v1alpha1.Cluster, factories *InstallerFactories, ) error
InstallPolicyEngineSilent installs the policy engine silently for parallel execution.
func InstallPostCNIComponents ¶
func InstallPostCNIComponents( cmd *cobra.Command, clusterCfg *v1alpha1.Cluster, factories *InstallerFactories, tmr timer.Timer, ) error
InstallPostCNIComponents installs all post-CNI components in parallel. This includes metrics-server, CSI, cert-manager, and GitOps engines (Flux/ArgoCD). For Flux, the OCI artifact push and readiness wait happens after installation.
func NeedsLoadBalancerInstall ¶ added in v5.28.9
NeedsLoadBalancerInstall determines if LoadBalancer support needs to be installed. Returns true only when LoadBalancer is Enabled AND the distribution × provider doesn't provide it by default. When LoadBalancer is Default, we don't install (rely on distribution × provider default behavior).
func NeedsMetricsServerInstall ¶
NeedsMetricsServerInstall determines if metrics-server needs to be installed. Returns true only when MetricsServer is Enabled AND the distribution doesn't provide it by default. When MetricsServer is Default, we don't install (rely on distribution's default behavior).
func RunDockerStage ¶
func RunDockerStage( cmd *cobra.Command, tmr timer.Timer, info StageInfo, action func(context.Context, client.APIClient) error, dockerInvoker DockerClientInvoker, ) error
RunDockerStage executes a Docker-based stage with standard progress messaging. This provides a consistent pattern for all Docker operations that need to: 1. Track timing via Timer.NewStage() 2. Show a title message with emoji 3. Show an activity message (optional) 4. Execute a Docker action 5. Show success/failure messages
Parameters:
- cmd: The Cobra command for output context
- tmr: Timer for stage timing
- info: Stage display information
- action: The Docker action to execute
- dockerInvoker: Function to create/invoke Docker client (use nil for default)
func ShouldPushOCIArtifact ¶ added in v5.21.6
ShouldPushOCIArtifact determines if OCI artifact push should happen for GitOps engines. Returns true if Flux or ArgoCD is enabled and a local registry is configured.
Types ¶
type ComponentRequirements ¶ added in v5.17.0
type ComponentRequirements struct {
NeedsMetricsServer bool
NeedsLoadBalancer bool
NeedsKubeletCSRApprover bool
NeedsCSI bool
NeedsCertManager bool
NeedsPolicyEngine bool
NeedsArgoCD bool
NeedsFlux bool
}
ComponentRequirements represents which components need to be installed.
func GetComponentRequirements ¶ added in v5.17.0
func GetComponentRequirements(clusterCfg *v1alpha1.Cluster) ComponentRequirements
GetComponentRequirements determines which components need to be installed based on cluster config.
func (ComponentRequirements) Count ¶ added in v5.17.0
func (r ComponentRequirements) Count() int
Count returns the number of components that need to be installed.
type DockerClientInvoker ¶
DockerClientInvoker is a function that invokes an operation with a Docker client.
func DefaultDockerClientInvoker ¶
func DefaultDockerClientInvoker() DockerClientInvoker
DefaultDockerClientInvoker returns the default Docker client invoker.
type InstallerFactories ¶
type InstallerFactories struct {
Flux func(client helm.Interface, timeout time.Duration) installer.Installer
CertManager func(clusterCfg *v1alpha1.Cluster) (installer.Installer, error)
CSI func(clusterCfg *v1alpha1.Cluster) (installer.Installer, error)
PolicyEngine func(clusterCfg *v1alpha1.Cluster) (installer.Installer, error)
ArgoCD func(clusterCfg *v1alpha1.Cluster) (installer.Installer, error)
KubeletCSRApprover func(clusterCfg *v1alpha1.Cluster) (installer.Installer, error)
// EnsureArgoCDResources configures default Argo CD resources post-install.
EnsureArgoCDResources func(
ctx context.Context, kubeconfig string, clusterCfg *v1alpha1.Cluster, clusterName string,
) error
// EnsureFluxResources enforces default Flux resources post-install.
// If artifactPushed is false, the function will skip waiting for FluxInstance readiness
// because the artifact doesn't exist yet (will be pushed later via workload push).
// registryHostOverride replaces the default Docker container name in the OCI URL
// when non-empty.
EnsureFluxResources func(
ctx context.Context, kubeconfig string, clusterCfg *v1alpha1.Cluster,
clusterName string, registryHostOverride string, artifactPushed bool,
) error
// SetupFluxInstance creates the FluxInstance CR without waiting for readiness.
// registryHostOverride replaces the default Docker container name in the OCI URL
// when non-empty.
// Use with WaitForFluxReady after pushing artifacts.
SetupFluxInstance func(
ctx context.Context, kubeconfig string, clusterCfg *v1alpha1.Cluster, clusterName string, registryHostOverride string,
) error
// WaitForFluxReady waits for the FluxInstance to be ready.
// Call after pushing OCI artifacts.
WaitForFluxReady func(ctx context.Context, kubeconfig string) error
// EnsureOCIArtifact checks if an OCI artifact exists and pushes one if needed.
// Returns true if artifact exists or was pushed, false if not needed.
// Set to nil to use the default implementation.
EnsureOCIArtifact func(
ctx context.Context, cmd *cobra.Command, clusterCfg *v1alpha1.Cluster, clusterName string, writer io.Writer,
) (bool, error)
// HelmClientFactory creates a Helm client for the cluster.
HelmClientFactory func(clusterCfg *v1alpha1.Cluster) (*helm.Client, string, error)
}
InstallerFactories holds factory functions for creating component installers. These can be overridden in tests for dependency injection.
func DefaultInstallerFactories ¶
func DefaultInstallerFactories() *InstallerFactories
DefaultInstallerFactories returns the default installer factories.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package localregistry provides local registry lifecycle operations for cluster commands.
|
Package localregistry provides local registry lifecycle operations for cluster commands. |
|
Package mirrorregistry provides mirror registry setup and connection stages for cluster creation.
|
Package mirrorregistry provides mirror registry setup and connection stages for cluster creation. |