Documentation
¶
Index ¶
- Constants
- Variables
- func AutoRemoveOrphanedPackages() automa.Builder
- func CheckClusterCRDs(id string, crds []string, timeout time.Duration, ...) automa.Builder
- func CheckClusterConfigMaps(id string, configMaps []string, timeout time.Duration, ...) automa.Builder
- func CheckClusterHealth() automa.Builder
- func CheckClusterNamespaces(id string, namespaces []string, timeout time.Duration, ...) automa.Builder
- func CheckClusterNodesReady(id string, provider kube.ClientProviderFromContext) automa.Builder
- func CheckClusterPodsReady(id string, podNames []string, timeout time.Duration, ...) automa.Builder
- func CheckClusterServices(id string, services []string, timeout time.Duration, ...) automa.Builder
- func CheckWeaverInstallation(binDir string) *automa.StepBuilder
- func ConfigureKubeconfigForAdminUser() automa.Builder
- func ConfigureSysctlForKubernetes() automa.Builder
- func DisableSwap() automa.Builder
- func InitializeCluster() automa.Builder
- func InstallKernelModule(name string) automa.Builder
- func InstallSystemPackage(name string, installer func() (software.Package, error)) automa.Builder
- func InstallWeaver(binDir string) *automa.StepBuilder
- func RefreshSystemPackageIndex() automa.Builder
- func RemoveSystemPackage(name string, installer func() (software.Package, error)) automa.Builder
- func SetupBindMounts() automa.Builder
- func SetupBlockNode(profile string, valuesFile string) automa.Builder
- func SetupCilium() automa.Builder
- func SetupCrio() automa.Builder
- func SetupHelm() automa.Builder
- func SetupHomeDirectoryStructure(pp *core.WeaverPaths) automa.Builder
- func SetupK9s() automa.Builder
- func SetupKubeadm() automa.Builder
- func SetupKubectl() automa.Builder
- func SetupKubelet() automa.Builder
- func SetupMetalLB() automa.Builder
- func SetupSystemdService(serviceName string) automa.Builder
- func Sleep(ctx context.Context, d time.Duration) error
- func StartCilium() automa.Builder
- func UpgradeBlockNode(profile string, valuesFile string, reuseValues bool) automa.Builder
Constants ¶
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" )
const ( KeyModifiedByThisStep = "modifiedByThisStep" KeyBindTarget = "bindTarget" KeyBindMount = "bindMount" KeyAlreadyMounted = "alreadyMounted" KeyAlreadyInFstab = "alreadyInFstab" )
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" )
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" )
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" )
const ( ConfigureSysctlForKubernetesStepId = "configure-sysctl-for-kubernetes" SysCtlBackupFilename = "sysctl.conf" KeyBackupFile = "backup_file" KeyReloadedFiles = "reloaded_files" KeyCopiedFiles = "copied_files" KeyRemovedFiles = "removed_files" KeyWarnings = "warnings" )
const (
DisableSwapStepId = "disable-swap"
)
Variables ¶
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 ¶
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 ¶
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 DisableSwap ¶
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 ¶
InitializeCluster checks cluster status and performs initialization only if needed
func InstallKernelModule ¶
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 ¶
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 ¶
RefreshSystemPackageIndex refreshes the system package index. Essentially this is equivalent to running `apt-get update` on Debian-based systems
func RemoveSystemPackage ¶
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 SetupBlockNode ¶
SetupBlockNode sets up the block node on the cluster
func SetupCilium ¶
func SetupHomeDirectoryStructure ¶
func SetupHomeDirectoryStructure(pp *core.WeaverPaths) automa.Builder
func SetupKubeadm ¶
func SetupKubectl ¶
func SetupKubelet ¶
func SetupMetalLB ¶
func SetupSystemdService ¶
SetupSystemdService enables and starts a systemd service by name It also reloads the systemd daemon to apply any changes Example: SetupSystemdService("kubelet")
func Sleep ¶
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 ¶
Types ¶
This section is empty.
Source Files
¶
- const.go
- helpers.go
- report.go
- step_bind_mounts.go
- step_block_node.go
- step_cilium.go
- step_cluster_configmaps.go
- step_cluster_crds.go
- step_cluster_namespace.go
- step_cluster_node_ready.go
- step_cluster_pod_ready.go
- step_cluster_services.go
- step_crio.go
- step_disable_swap.go
- step_health.go
- step_helm.go
- step_k9s.go
- step_kubeadm.go
- step_kubeconfig.go
- step_kubectl.go
- step_kubelet.go
- step_metallb.go
- step_setup_directories.go
- step_sysctl.go
- step_system_module.go
- step_system_package.go
- step_systemd_service.go
- step_weaver.go