cluster

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package cluster orchestrates the full lifecycle of a multi-node K8s cluster. It coordinates Lima VM provisioning, K3s installation, and cluster operations across multiple remote macOS hosts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(ctx context.Context, cfg *config.Config, nonInteractive, dryRun bool) error

Apply iterates over all nodes, rolling VM config changes (CPUs, Memory, Disk, and host mounts) one node at a time for zero downtime. A node is only restarted when its live lima.yaml differs from the desired config, and the destructive cycle is gated behind a confirmation unless nonInteractive is set.

func Backup

func Backup(ctx context.Context, cfg *config.Config, outputDir string) error

Backup creates an etcd snapshot on the init node and downloads it locally.

func Destroy

func Destroy(ctx context.Context, cfg *config.Config, force, dryRun bool) error

Destroy tears down the entire cluster.

func Init

func Init(ctx context.Context, cfg *config.Config, opts InitOptions) error

Init bootstraps a new cluster from scratch. It is idempotent.

func Join

func Join(ctx context.Context, cfg *config.Config, dryRun bool) error

Join adds nodes that are in the config but not yet in the cluster. Each node is provisioned through its NodeProvider (Lima VM or native Linux host).

func Reconcile added in v0.53.0

func Reconcile(ctx context.Context, cfg *config.Config, dryRun bool) error

Reconcile converges an already-provisioned cluster to the current desired baseline without rebuilding it. It does two things, both idempotent and safe to run repeatedly:

  1. Per node: ensure the standard node package set (lima.NodePackages — notably socat, which kubectl port-forward and devx bridge need to carry traffic on Docker-runtime k3s nodes) is installed inside every node's Lima VM. Nodes are reconciled in parallel.
  2. Cluster-wide: ensure the resilience defaults (CoreDNS HA + single default StorageClass) via the init server node — mirroring Init's Phase 6.5 — so a cluster that predates these defaults, or one where a k3s upgrade reset a bundled addon, re-adopts them on `cluster apply`.

Unlike Init/Join it does not touch VM lifecycle or the K3s install itself; it only installs packages and re-asserts cluster-level Kubernetes defaults on nodes that already exist, so existing clusters can adopt new baselines without a destroy/recreate.

func Remove

func Remove(ctx context.Context, cfg *config.Config, hostName string, dryRun bool) error

Remove drains and removes a specific node from the cluster.

func Restore

func Restore(ctx context.Context, cfg *config.Config, snapshotPath string) error

Restore restores etcd from a snapshot file.

func Status

func Status(ctx context.Context, cfg *config.Config) error

Status displays the current state of all configured nodes.

func Upgrade

func Upgrade(ctx context.Context, cfg *config.Config, dryRun bool) error

Upgrade performs a rolling upgrade of K3s across all nodes. Agents are upgraded first, then servers one at a time to maintain quorum.

Types

type InitOptions

type InitOptions struct {
	DryRun      bool
	AutoInstall bool
}

InitOptions configures the Init operation.

Jump to

Keyboard shortcuts

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