steps

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoadedByThisStep  = automa.Key("loadedByThisStep")
	ConfigurationFile = "configurationFile"

	AlreadyInstalled      = "alreadyInstalled"
	AlreadyConfigured     = "alreadyConfigured"
	ServiceAlreadyEnabled = "serviceAlreadyEnabled"
	ServiceAlreadyRunning = "serviceAlreadyRunning"

	ServiceEnabledByThisStep = "serviceEnabled"
	ServiceStartedByThisStep = "serviceStarted"

	DownloadedByThisStep = "downloaded"
	ExtractedByThisStep  = "extracted"
	InstalledByThisStep  = "installed"
	CleanedUpByThisStep  = "cleanedUp"
	ConfiguredByThisStep = "configured"

	IsReady   = "isReady"
	IsPending = "isPending"
)
View Source
const (
	KeyModifiedByThisStep = "modifiedByThisStep"
	KeyBindTarget         = "bindTarget"
	KeyBindMount          = "bindMount"
	KeyAlreadyMounted     = "alreadyMounted"
	KeyAlreadyInFstab     = "alreadyInFstab"
)
View Source
const (
	SetupBlockNodeStepId           = "setup-block-node"
	SetupBlockNodeStorageStepId    = "setup-block-node-storage"
	CreateBlockNodeNamespaceStepId = "create-block-node-namespace"
	CreateBlockNodePVsStepId       = "create-block-node-pvs"
	InstallBlockNodeStepId         = "install-block-node"
	UpgradeBlockNodeStepId         = "upgrade-block-node"
	AnnotateBlockNodeServiceStepId = "annotate-block-node-service"
	WaitForBlockNodeStepId         = "wait-for-block-node"
)
View Source
const (
	CheckClusterNodesStepId      = "check_cluster_nodes"
	CheckClusterNamespacesStepId = "check_cluster_namespaces"
	CheckClusterConfigMapsStepId = "check_cluster_configmaps"
	CheckClusterPodsStepId       = "check_cluster_pods"
	CheckClusterServicesStepId   = "check_cluster_services"
	CheckClusterCRDsStepId       = "check_cluster_crds"
)
View Source
const (
	MetalLBNamespace             = "metallb-system"
	MetalLBRelease               = "metallb"
	MetalLBChart                 = "metallb/metallb"
	MetalLBVersion               = "0.15.2"
	MetalLBRepo                  = "https://metallb.github.io/metallb"
	SetupMetalLBStepId           = "setup-metallb"
	InstallMetalLBStepId         = "install-metallb"
	MetalLBTemplatePath          = "files/metallb/metallb.yaml"
	ConfigureMetalLbConfigStepId = "configure-metallb-config"
	PrepareMetalLbConfigStepId   = "prepare-metallb-config"
	DeployMetalLbConfigStepId    = "deploy-metallb-config"
	IsMetalLBReadyStepId         = "is-metallb-ready"
)
View Source
const (
	ConfigureSysctlForKubernetesStepId = "configure-sysctl-for-kubernetes"
	SysCtlBackupFilename               = "sysctl.conf"
	KeyBackupFile                      = "backup_file"
	KeyReloadedFiles                   = "reloaded_files"
	KeyCopiedFiles                     = "copied_files"
	KeyRemovedFiles                    = "removed_files"
	KeyWarnings                        = "warnings"
)
View Source
const (
	DisableSwapStepId = "disable-swap"
)

Variables

View Source
var PrintWorkflowReport = func(report *automa.Report, fileName string) {
	b, err := yaml.Marshal(report)
	if err != nil {
		fmt.Printf("Failed to marshal report: %v\n", err)
		return
	}

	if fileName != "" {
		err := os.WriteFile(fileName, b, core.DefaultFilePerm)
		if err != nil {
			fmt.Printf("Failed to write report to file: %v\n", err)
			return
		}
	} else {
		fmt.Printf("Workflow Execution Report:%s\n", b)
	}
}

PrintWorkflowReport prints the workflow execution report in YAML format If fileName is provided, it writes the report to the specified file Otherwise, it prints the report to standard output

Functions

func AutoRemoveOrphanedPackages

func AutoRemoveOrphanedPackages() automa.Builder

AutoRemoveOrphanedPackages removes orphaned dependencies and frees disk space. Essentially this is equivalent to running `apt autoremove -y` on Debian-based systems

func CheckClusterCRDs

func CheckClusterCRDs(id string, crds []string, timeout time.Duration, provider kube.ClientProviderFromContext) automa.Builder

CheckClusterCRDs checks if the specified CRDs are installed in the cluster crds is a list of CRD names

func CheckClusterConfigMaps

func CheckClusterConfigMaps(id string, configMaps []string, timeout time.Duration, provider kube.ClientProviderFromContext) automa.Builder

CheckClusterConfigMaps checks if the specified config maps exist in the cluster

func CheckClusterHealth

func CheckClusterHealth() automa.Builder

CheckClusterHealth performs a series of checks to ensure the cluster is healthy and operational

func CheckClusterNamespaces

func CheckClusterNamespaces(id string, namespaces []string, timeout time.Duration, provider kube.ClientProviderFromContext) automa.Builder

CheckClusterNamespaces checks if the specified namespaces exist in the cluster namespaces is a list of namespace names

func CheckClusterNodesReady

func CheckClusterNodesReady(id string, provider kube.ClientProviderFromContext) automa.Builder

CheckClusterNodesReady checks if all nodes in the cluster are ready

func CheckClusterPodsReady

func CheckClusterPodsReady(id string, podNames []string, timeout time.Duration, provider kube.ClientProviderFromContext) automa.Builder

CheckClusterPodsReady checks if the specified pods are running in the cluster podNames is a list of strings in the format 'namespace/pod-name-prefix'

func CheckClusterServices

func CheckClusterServices(id string, services []string, timeout time.Duration, provider kube.ClientProviderFromContext) automa.Builder

CheckClusterServices checks if the specified services are running in the cluster services is a list of strings in the format 'namespace/service-name'

func CheckWeaverInstallation

func CheckWeaverInstallation(binDir string) *automa.StepBuilder

CheckWeaverInstallation checks if weaver is installed at the given binDir.

func ConfigureKubeconfigForAdminUser

func ConfigureKubeconfigForAdminUser() automa.Builder

func ConfigureSysctlForKubernetes

func ConfigureSysctlForKubernetes() automa.Builder

func DisableSwap

func DisableSwap() automa.Builder

DisableSwap disables swap on the system On execute, it runs the swapoff and ensures fstab is updated to prevent swap from being re-enabled on reboot On rollback, it runs the swapon and ensures fstab is updated to re-enable swap on reboot

func InitializeCluster

func InitializeCluster() automa.Builder

InitializeCluster checks cluster status and performs initialization only if needed

func InstallKernelModule

func InstallKernelModule(name string) automa.Builder

InstallKernelModule ensures that a specific kernel module is loaded and persisted. If the module is already loaded, it skips the loading process. On rollback, it unloads the module only if it was loaded by this step.

func InstallSystemPackage

func InstallSystemPackage(name string, installer func() (software.Package, error)) automa.Builder

InstallSystemPackage installs a system package using the provided installer function. The installer function should return a software.Package instance that knows how to install the package. If the package is already installed, it will skip the installation.

func InstallWeaver

func InstallWeaver(binDir string) *automa.StepBuilder

InstallWeaver installs the currently running executable as the `weaver` binary into the provided `binDir` and attempts to create a convenience symlink in `/usr/local/bin`.

Behavior

  • The step locates the currently running executable (source).
  • It ensures `binDir` exists and then copies the source executable into a temporary file created inside `binDir` (pattern `weaver.tmp.*`).
  • After the copy completes the temp file is closed, its mode is set to executable (`0o755`), and the temp file is atomically renamed to the final destination `binDir/weaver`.

Why a temp file + rename

  • Atomic replacement: renaming a file within the same filesystem is atomic on POSIX. This guarantees other processes see either the old binary or the fully-written new one, never a half-written file.
  • Crash/failure safety: if the copy fails (disk full, interrupt, etc.) the existing installed binary is not touched; the incomplete temp file can be removed without corrupting the installation.
  • Running processes remain valid: on Unix, processes holding the old inode continue to run unaffected after the file at the destination is replaced.
  • Correct final state: permissions and any finalization (e.g. fsync if added) can be applied to the temp file before it becomes visible at the final path.

Implementation notes

  • The temp file is created inside `binDir` to ensure the rename is a same- filesystem move (required for atomicity).
  • If creating a symlink at `/usr/local/bin/weaver` fails the step logs a warning but does not treat this as a hard error (installation can still succeed without the symlink).
  • The step returns an automa success or failure report describing the outcome.
  • Elevated permissions (e.g. `sudo`) are typically required to write to the system `binDir` or create the symlink in `/usr/local/bin`.

Usage

  • Intended to be executed as part of an installation workflow; callers should ensure the process has the required permissions when calling this step.

func RefreshSystemPackageIndex

func RefreshSystemPackageIndex() automa.Builder

RefreshSystemPackageIndex refreshes the system package index. Essentially this is equivalent to running `apt-get update` on Debian-based systems

func RemoveSystemPackage

func RemoveSystemPackage(name string, installer func() (software.Package, error)) automa.Builder

RemoveSystemPackage removes a system package using the provided installer function. The installer function should return a software.Package instance that knows how to uninstall the package. If the package is not installed, it will skip the removal.

func SetupBindMounts

func SetupBindMounts() automa.Builder

func SetupBlockNode

func SetupBlockNode(profile string, valuesFile string) automa.Builder

SetupBlockNode sets up the block node on the cluster

func SetupCilium

func SetupCilium() automa.Builder

func SetupCrio

func SetupCrio() automa.Builder

func SetupHelm

func SetupHelm() automa.Builder

func SetupHomeDirectoryStructure

func SetupHomeDirectoryStructure(pp *core.WeaverPaths) automa.Builder

func SetupK9s

func SetupK9s() automa.Builder

func SetupKubeadm

func SetupKubeadm() automa.Builder

func SetupKubectl

func SetupKubectl() automa.Builder

func SetupKubelet

func SetupKubelet() automa.Builder

func SetupMetalLB

func SetupMetalLB() automa.Builder

func SetupSystemdService

func SetupSystemdService(serviceName string) automa.Builder

SetupSystemdService enables and starts a systemd service by name It also reloads the systemd daemon to apply any changes Example: SetupSystemdService("kubelet")

func Sleep

func Sleep(ctx context.Context, d time.Duration) error

Sleep sleeps for the given duration or returns early if the context is canceled or its deadline expires. Returns nil on success or ctx.Err() on cancellation.

func StartCilium

func StartCilium() automa.Builder

func UpgradeBlockNode added in v0.5.0

func UpgradeBlockNode(profile string, valuesFile string, reuseValues bool) automa.Builder

UpgradeBlockNode upgrades the block node on the cluster

Types

This section is empty.

Jump to

Keyboard shortcuts

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