k3s

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package k3s handles K3s installation, cluster join, and lifecycle management on remote Lima VMs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles K3s operations on a remote Lima VM.

func NewManager

func NewManager(runner *remote.Runner) *Manager

NewManager creates a new K3s manager for the given remote host.

func NewManagerWithVM

func NewManagerWithVM(runner *remote.Runner, vmName string) *Manager

NewManagerWithVM creates a new K3s manager with a custom VM name.

func (*Manager) CreateSnapshot

func (m *Manager) CreateSnapshot(ctx context.Context) (string, error)

CreateSnapshot creates an etcd snapshot and returns the snapshot name/path.

func (*Manager) DeleteNode

func (m *Manager) DeleteNode(ctx context.Context, nodeName string) error

DeleteNode removes a node from the cluster.

func (*Manager) DownloadSnapshot

func (m *Manager) DownloadSnapshot(ctx context.Context, remotePath, localPath string) error

DownloadSnapshot copies a snapshot from the remote VM to the local machine.

func (*Manager) DrainNode

func (m *Manager) DrainNode(ctx context.Context, nodeName string) error

DrainNode drains a node before removal.

func (*Manager) GetKubeconfig

func (m *Manager) GetKubeconfig(ctx context.Context, serverIP string) (string, error)

GetKubeconfig retrieves and patches the kubeconfig for external access.

func (*Manager) GetNodeStatus

func (m *Manager) GetNodeStatus(ctx context.Context) (string, error)

GetNodeStatus returns the output of kubectl get nodes.

func (*Manager) GetToken

func (m *Manager) GetToken(ctx context.Context) (string, error)

GetToken retrieves the K3s node token from the server.

func (*Manager) GetVersion

func (m *Manager) GetVersion(ctx context.Context) (string, error)

GetVersion returns the installed K3s version string.

func (*Manager) InitCluster

func (m *Manager) InitCluster(ctx context.Context, nodeIP, pool, k3sVersion string, tlsSANs []string) error

InitCluster bootstraps the first control plane node with --cluster-init.

func (*Manager) IsInstalled

func (m *Manager) IsInstalled(ctx context.Context) (bool, error)

IsInstalled checks whether K3s is installed inside the VM.

func (*Manager) JoinAgent

func (m *Manager) JoinAgent(ctx context.Context, nodeIP, serverURL, token, pool, k3sVersion string) error

JoinAgent joins a worker node to the cluster.

func (*Manager) JoinServer

func (m *Manager) JoinServer(ctx context.Context, nodeIP, serverURL, token, pool, k3sVersion string, tlsSANs []string) error

JoinServer joins a server node to an existing HA cluster.

func (*Manager) ReinstallAgent

func (m *Manager) ReinstallAgent(ctx context.Context, nodeIP, serverURL, token, version, pool string) error

ReinstallAgent reinstalls K3s on an agent node.

func (*Manager) ReinstallJoinServer

func (m *Manager) ReinstallJoinServer(ctx context.Context, nodeIP, serverURL, token, version, pool string) error

ReinstallJoinServer reinstalls K3s on a server node that joins an existing cluster.

func (*Manager) ReinstallServer

func (m *Manager) ReinstallServer(ctx context.Context, nodeIP, version string, tlsSANs []string, pool string) error

ReinstallServer reinstalls K3s server (init node) with a new version.

func (*Manager) RestoreSnapshot

func (m *Manager) RestoreSnapshot(ctx context.Context, snapshotPath string) error

RestoreSnapshot restores etcd from a snapshot file on the remote VM.

func (*Manager) StartService

func (m *Manager) StartService(ctx context.Context) error

StartService starts the K3s systemd service.

func (*Manager) StopService

func (m *Manager) StopService(ctx context.Context) error

StopService stops the K3s systemd service.

func (*Manager) UncordonNode

func (m *Manager) UncordonNode(ctx context.Context, nodeName string) error

UncordonNode marks a node as schedulable after draining.

func (*Manager) Uninstall

func (m *Manager) Uninstall(ctx context.Context, role string) error

Uninstall removes K3s from the VM.

func (*Manager) UploadSnapshot

func (m *Manager) UploadSnapshot(ctx context.Context, localPath, remotePath string) error

UploadSnapshot copies a snapshot from the local machine to the remote VM.

func (*Manager) WaitForReady

func (m *Manager) WaitForReady(ctx context.Context, timeout time.Duration) error

WaitForReady polls until K3s is initialized, the node token exists, and the API server is responding to kubectl commands.

Jump to

Keyboard shortcuts

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