setup

package
v5.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (
	ErrCertManagerInstallerFactoryNil = errors.New("cert-manager installer factory is nil")
	ErrArgoCDInstallerFactoryNil      = errors.New("argocd installer factory is nil")
	ErrClusterConfigNil               = errors.New("cluster config is nil")
)

Errors for component installation.

View Source
var ErrCSIInstallerFactoryNil = errors.New("CSI installer factory is nil")

ErrCSIInstallerFactoryNil is returned when the CSI installer factory is nil.

View Source
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

func HelmClientForCluster(clusterCfg *v1alpha1.Cluster) (*helm.Client, string, error)

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

func InstallCNI(
	cmd *cobra.Command,
	clusterCfg *v1alpha1.Cluster,
	tmr timer.Timer,
) (bool, error)

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 InstallMetricsServerSilent

func InstallMetricsServerSilent(
	ctx context.Context,
	clusterCfg *v1alpha1.Cluster,
	factories *InstallerFactories,
) error

InstallMetricsServerSilent installs metrics-server 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).

func NeedsMetricsServerInstall

func NeedsMetricsServerInstall(clusterCfg *v1alpha1.Cluster) bool

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)

Types

type DockerClientInvoker

type DockerClientInvoker func(*cobra.Command, func(client.APIClient) error) error

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)
	ArgoCD      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.
	EnsureFluxResources func(
		ctx context.Context, kubeconfig string, clusterCfg *v1alpha1.Cluster, clusterName string,
	) 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.

type StageInfo

type StageInfo struct {
	Title         string
	Emoji         string
	Activity      string
	Success       string
	FailurePrefix string
}

StageInfo contains display information for a setup stage. Note: Leading newlines between stages are handled automatically by StageSeparatingWriter.

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.

Jump to

Keyboard shortcuts

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