distrocfg

package
v0.2.5 Latest Latest
Warning

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

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

Documentation

Overview

Package distrocfg defines the standard interface that all distro config settings

Index

Constants

View Source
const (
	// Binary id string
	Binary = "Binary"
	// BinaryDir id string
	BinaryDir = "BinDir"
	// Config id string
	Config = "Config"
	// Token id string
	Token = "Token"
	// Data id string
	Data = "DataDir"
	// WorkerService id string
	WorkerService = "Worker"
	// ControllerService id string
	ControllerService = "Control"
)
View Source
const (
	// DistroK3S id
	DistroK3S = "k3s"
)
View Source
const (
	// DistroRKE2 id
	DistroRKE2 = "rke2"
)

Variables

View Source
var (

	// ErrVersionNotDetected if a version is not detected
	ErrVersionNotDetected = errors.New("failed to get version from the distro binary")
	// ErrPathKey if a path key is not used
	ErrPathKey = errors.New("key for set path does not exist")
)

Functions

func NodeLabelsMapToList

func NodeLabelsMapToList(m map[string]string) []string

NodeLabelsMapToList takes a map and returns a string array for used by Kubernetes labels

Types

type Common

type Common struct {
	//keep-sorted start
	// Binary name of the engine binary
	Binary string
	// BinaryDir where the engine binary is stored in
	BinaryDir string
	// Config where the engine config is located
	Config string
	// Data where the engine data is located
	Data string
	// ID the id used to identify the distro
	ID string
	// ServiceController the controller service
	ServiceController string
	// ServiceWorker the worker service
	ServiceWorker string
	// Token the token path
	Token string
}

Common for all the distro's

func (*Common) BinaryName

func (r *Common) BinaryName() string

BinaryName returns the engine binary name

func (*Common) BinaryPath

func (r *Common) BinaryPath() string

BinaryPath returns the full path to the engine binary

func (*Common) ConfigPath

func (r *Common) ConfigPath() string

ConfigPath returns the full path for the config directory used by the engine

func (*Common) DataDirPath

func (r *Common) DataDirPath() string

DataDirPath returns the full path for the data directory used by the engine

func (*Common) GetControllerService

func (r *Common) GetControllerService() string

GetControllerService returns the name of the controller service

func (*Common) GetWorkerService

func (r *Common) GetWorkerService() string

GetWorkerService returns the name of the worker service

func (*Common) JoinTokenPath

func (r *Common) JoinTokenPath() string

JoinTokenPath returns the path of the token to join the cluster

func (*Common) SetPath

func (r *Common) SetPath(key string, value string) error

SetPath takes in a key value pair to change how the distro values are configured, if a key is not valid it will throw an "ErrPathKey" error

type Distro

type Distro interface {
	//keep-sorted start sticky_comments=yes
	// BinaryName returns the engine binary name
	BinaryName() string
	// BinaryPath returns the full path to the engine binary
	BinaryPath() string
	// ConfigPath returns the full path for the config directory used by the engine
	ConfigPath() string
	// ConfigureEngine does distro specific configuration on a host
	ConfigureEngine(context.Context, cluster.ZarfHost, cluster.ZarfRuntimeMeta, distro.ZarfDistro) error
	// DataDirPath returns the full path for the data directory used by the engine
	DataDirPath() string
	// DistroCmdf returns a string that can be used to execute commands on the core engine binary
	DistroCmdf(string, ...any) string
	// GetClusterCIDR returns a string array with the all the known cluster cidr blocks
	GetClusterCIDR(distro.ZarfDistro) []string
	// GetControllerService returns the name of the controller service
	GetControllerService() string
	// GetWorkerService returns the name of the worker service
	GetWorkerService() string
	// JoinTokenPath returns the path of the token to join the cluster
	JoinTokenPath() string
	// JoinTokenPathAgent returns the path of the token to join the cluster.
	// Distro's like RKE2 and K3S allow for agent tokens, so this allows for some level of access control if a node is allowed to be a controller or an agent.
	JoinTokenPathAgent() string
	// KubeconfigPath returns the path to the admin config for a given
	KubeconfigPath(cluster.ZarfHost, string) string
	// KubectlCmdf returns a string with that can be executed to interact with the kubernetes cluster
	KubectlCmdf(cluster.ZarfHost, string, string, ...any) string
	// RunningVersion returns the version of the distro being ran, if the engine is not running it throws an "ErrVersionNotDetected" error
	RunningVersion(cluster.ZarfHost) (string, error)
	// SetPath takes in a key value pair to change how the distro values are configured, if a key is not valid it will throw an "ErrPathKey" error
	SetPath(key string, value string) error
	// StopControllerService stops the controller service on the host
	StopControllerService(*cluster.ZarfHost) error
	// StopWorkerService stops the controller service on the host
	StopWorkerService(*cluster.ZarfHost) error
}

Distro interface for any distro object

type K3S

type K3S struct {
	RancherCommon
}

K3S distro struct

func (*K3S) KubeconfigPath

func (d *K3S) KubeconfigPath(_ cluster.ZarfHost, _ string) string

KubeconfigPath returns the path to the admin config for a given

func (*K3S) KubectlCmdf

func (d *K3S) KubectlCmdf(host cluster.ZarfHost, dataDir string, s string, args ...any) string

KubectlCmdf returns a string with that can be executed to interact with the kubernetes cluster

func (*K3S) StopControllerService

func (d *K3S) StopControllerService(h *cluster.ZarfHost) error

StopControllerService stops the controller service on the host

func (*K3S) StopWorkerService

func (d *K3S) StopWorkerService(h *cluster.ZarfHost) error

StopWorkerService stops the controller service on the host

type RKE2

type RKE2 struct {
	RancherCommon
}

RKE2 distro struct

func (*RKE2) KubeconfigPath

func (d *RKE2) KubeconfigPath(_ cluster.ZarfHost, _ string) string

KubeconfigPath returns the path to the admin config for a given distro

func (*RKE2) KubectlCmdf

func (d *RKE2) KubectlCmdf(host cluster.ZarfHost, dataDir string, s string, args ...any) string

KubectlCmdf returns a string with that can be executed to interact with the kubernetes cluster

func (*RKE2) StopControllerService

func (d *RKE2) StopControllerService(h *cluster.ZarfHost) error

StopControllerService implements Distro.

func (*RKE2) StopWorkerService

func (d *RKE2) StopWorkerService(h *cluster.ZarfHost) error

StopWorkerService implements Distro.

type RancherCommon

type RancherCommon struct {
	Common
}

RancherCommon is a parent object for both RKE2 and k3s distros

func (*RancherCommon) ConfigureEngine

func (d *RancherCommon) ConfigureEngine(ctx context.Context, host cluster.ZarfHost, run cluster.ZarfRuntimeMeta, dis distro.ZarfDistro) error

ConfigureEngine does distro specific configuration on a host

func (*RancherCommon) DistroCmdf

func (d *RancherCommon) DistroCmdf(template string, args ...any) string

DistroCmdf returns a string that can be used to execute commands on the core engine binary

func (*RancherCommon) GetClusterCIDR

func (d *RancherCommon) GetClusterCIDR(dis distro.ZarfDistro) []string

GetClusterCIDR returns a string array with the all the known cluster cidr blocks

func (*RancherCommon) JoinTokenPathAgent

func (d *RancherCommon) JoinTokenPathAgent() string

JoinTokenPathAgent returns the path of the token to join the cluster. Distro's like RKE2 and K3S allow for agent tokens, so this allows for some level of access control if a node is allowed to be a controller or an agent.

func (*RancherCommon) RunningVersion

func (d *RancherCommon) RunningVersion(host cluster.ZarfHost) (string, error)

RunningVersion returns the version of the distro being ran, if the engine is not running it throws an "ErrVersionNotDetected" error

Directories

Path Synopsis
Package registry is used to register a distro
Package registry is used to register a distro

Jump to

Keyboard shortcuts

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