cluster

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: 16 Imported by: 0

Documentation

Overview

Package cluster is for the api representation of Cluster

Index

Constants

View Source
const (
	// RoleController string enum
	RoleController = "controller"
	// RoleControllerWorker string enum
	RoleControllerWorker = "controller+worker"
	// RoleSingle string enum
	RoleSingle = "single"
	// RoleWorker string enum
	RoleWorker = "worker"
	// RoleError string enum
	RoleError = "error"
)

Variables

View Source
var ErrCommandFailed = errors.New("command failed")

ErrCommandFailed is returned when a command fails

Functions

This section is empty.

Types

type ZarfCluster

type ZarfCluster struct {
	APIVersion      string                  `json:"apiVersion,omitempty" jsonschema:"enum=zarf.dev/v1alpha1"`
	Kind            v1alpha1.ZarfDistroKind `json:"kind" jsonschema:"enum=ZarfCluster"`
	Metadata        ZarfClusterMetadata     `json:"metadata"`
	Spec            ZarfClusterSpec         `json:"spec"`
	RuntimeMetadata ZarfRuntimeMeta         `json:"-"`
}

ZarfCluster root for a cluster config

type ZarfClusterConfig

type ZarfClusterConfig struct {
	LoadBalancer string                  `json:"loadbalancer" jsonschema:"format=hostname"`
	Registries   []ZarfClusterRegistries `json:"registries,omitempty"`
	Profiles     []ZarfClusterProfiles   `json:"profiles,omitempty"`
}

ZarfClusterConfig for a cluster

type ZarfClusterFiles

type ZarfClusterFiles struct {
	Name                 string `json:"name"`
	Source               string `json:"src,omitempty"`
	Destination          string `json:"dst,omitempty"`
	DestinationDirectory string `json:"dstDir,omitempty"`
	Permission           string `json:"perm,omitempty"`
	User                 string `json:"user,omitempty" jsonschema:"example=root"`
	Group                string `json:"group,omitempty" jsonschema:"example=root"`
	Data                 string `json:"data,omitempty"`
}

ZarfClusterFiles data

type ZarfClusterMetadata

type ZarfClusterMetadata struct {
	Name        string            `json:"name" jsonschema:"pattern=^[a-z0-9][a-z0-9\\-]*$"`
	Description string            `json:"description,omitempty"`
	Version     string            `json:"version,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
}

ZarfClusterMetadata a cluster config

type ZarfClusterProfiles

type ZarfClusterProfiles struct {
	Name    string         `json:"name"`
	Kubelet map[string]any `json:"kubeletConfig,omitempty"`
	Engine  map[string]any `json:"engineConfig,omitempty"`
}

ZarfClusterProfiles for the engine

type ZarfClusterRegistries

type ZarfClusterRegistries struct {
	// Name of the registry
	Name string `json:"name"`
	// Authentication for the registry
	Authentication ZarfClusterRegistryAuth `json:"auth,omitempty"`
	// Proxy for the registry
	Proxy ZarfClusterRegistryProxy `json:"proxy"`
}

ZarfClusterRegistries overrides

type ZarfClusterRegistryAuth

type ZarfClusterRegistryAuth struct {
	// Username for the remote registry
	Username string `json:"user,omitempty"`
	// Password for the remote registry
	Password string `json:"pass,omitempty"`
	// Token for the remote registry
	Token string `json:"token,omitempty"`
}

ZarfClusterRegistryAuth information

type ZarfClusterRegistryProxy

type ZarfClusterRegistryProxy struct {
	// URL to the registry that will engine will now pull from
	URL string `json:"url"`
}

ZarfClusterRegistryProxy override for the registry information

type ZarfClusterSpec

type ZarfClusterSpec struct {
	Config ZarfClusterConfig `json:"config"`
	Hosts  ZarfHosts         `json:"hosts" jsonschema:"minItems=1"`
}

ZarfClusterSpec a cluster config

type ZarfHost

type ZarfHost struct {
	rig.Connection `json:",inline"`
	//keep-sorted start
	Environment      map[string]string  `json:"environment,omitempty"`
	Files            []ZarfClusterFiles `json:"files,omitempty"`
	Hostname         string             `json:"hostname,omitempty"`
	NodeLabels       map[string]string  `json:"labels,omitempty"`
	NodeTaints       []string           `json:"taints,omitempty"`
	Ports            []ZarfHostPort     `json:"ports,omitempty" xml:"port"`
	PrivateAddress   string             `json:"privateAddress,omitempty"`
	PrivateInterface string             `json:"privateInterface,omitempty"`
	Profile          string             `json:"profile,omitempty"`
	Role             string             `json:"role" jsonschema:"enum=controller,enum=controller+worker,enum=single,enum=worker"`
	//keep-sorted end
	Configurer os.Configurer    `json:"-"`
	Metadata   ZarfHostMetadata `json:"-"`
}

ZarfHost is a remote connection to a node

func (*ZarfHost) Arch

func (h *ZarfHost) Arch() (string, error)

Arch returns the host architecture, caching the result in metadata

func (*ZarfHost) CheckHTTPStatus

func (h *ZarfHost) CheckHTTPStatus(url string, expected ...int) error

CheckHTTPStatus will perform a web request to the url and return an error if the http status is not the expected

func (*ZarfHost) DeleteFile

func (h *ZarfHost) DeleteFile(path string) error

DeleteFile removes a file via the resolved configurer.

func (*ZarfHost) Dir

func (h *ZarfHost) Dir(path string) (string, error)

Dir returns the configurer-specific directory name for the given path.

func (*ZarfHost) FileChanged

func (h *ZarfHost) FileChanged(lpath, rpath string) bool

FileChanged returns true when a remote file has a different sha256 checksum or if an error occurs

func (*ZarfHost) FileExist

func (h *ZarfHost) FileExist(path string) bool

FileExist if a file exists on the host

func (*ZarfHost) IsController

func (h *ZarfHost) IsController() bool

IsController returns true for controller and controller+worker roles

func (*ZarfHost) KubeRole

func (h *ZarfHost) KubeRole() string

KubeRole of the role host

func (*ZarfHost) OSKind

func (h *ZarfHost) OSKind() (string, error)

OSKind returns the host OS kind via the resolved configurer.

func (*ZarfHost) ReadFile

func (h *ZarfHost) ReadFile(path string) (string, error)

ReadFile read the contents of a file, if it exists, or returns an error

func (*ZarfHost) ResolveConfigurer

func (h *ZarfHost) ResolveConfigurer() error

ResolveConfigurer assigns a rig-style configurer to the Host (see configurer/)

func (*ZarfHost) ServiceName

func (h *ZarfHost) ServiceName() string

ServiceName returns correct service name

func (*ZarfHost) Touch

func (h *ZarfHost) Touch(path string, modTime time.Time, opts ...exec.Option) error

Touch updates file modification timestamps via the resolved configurer.

func (*ZarfHost) WriteFile

func (h *ZarfHost) WriteFile(path string, data string, permissions string) error

WriteFile writes file to host with given contents. Do not use for large files.

type ZarfHostMetadata

type ZarfHostMetadata struct {
	//keep-sorted start
	Arch           string
	BinaryTempFile []string
	DistroVersion  string
	EngineUploaded bool
	ExistingConfig string
	Hostname       string
	Install        func(context.Context, *ZarfHost) error
	Installed      bool
	IsLeader       bool
	MachineID      string
	NeedsUpgrade   bool
	NewConfig      string
	Ready          bool
}

ZarfHostMetadata runtime discovered values

type ZarfHostPort

type ZarfHostPort struct {
	Protocol string `json:"protocol" xml:"protocol,attr" jsonschema:"enum=tcp,enum=udp"`
	Port     string `json:"port" xml:"port,attr" jsonschema:"oneof_type=string;integer"`
}

ZarfHostPort ports that should be opened on the public side of the firewall

type ZarfHosts

type ZarfHosts []*ZarfHost

ZarfHosts are the hosts that will be managed

func (ZarfHosts) BatchedParallelEach

func (hosts ZarfHosts) BatchedParallelEach(ctx context.Context, batchSize int, filter ...func(context.Context, *ZarfHost) error) error

BatchedParallelEach runs a function (or multiple functions chained) on every Host parallelly in groups of batchSize hosts.

func (ZarfHosts) Controllers

func (hosts ZarfHosts) Controllers() ZarfHosts

Controllers returns hosts with the role "controller"

func (ZarfHosts) Each

func (hosts ZarfHosts) Each(ctx context.Context, filters ...func(context.Context, *ZarfHost) error) error

Each runs a function (or multiple functions chained) on every Host.

func (ZarfHosts) Filter

func (hosts ZarfHosts) Filter(filter func(h *ZarfHost) bool) ZarfHosts

Filter returns a filtered list of Hosts. The filter function should return true for hosts matching the criteria.

func (ZarfHosts) Find

func (hosts ZarfHosts) Find(filter func(h *ZarfHost) bool) *ZarfHost

Find returns the first matching Host. The finder function should return true for a Host matching the criteria.

func (ZarfHosts) First

func (hosts ZarfHosts) First() *ZarfHost

First returns the first host

func (ZarfHosts) Last

func (hosts ZarfHosts) Last() *ZarfHost

Last returns the last host

func (ZarfHosts) ParallelEach

func (hosts ZarfHosts) ParallelEach(ctx context.Context, filters ...func(context.Context, *ZarfHost) error) error

ParallelEach runs a function (or multiple functions chained) on every Host parallelly. Any errors will be concatenated and returned.

func (ZarfHosts) WithRole

func (hosts ZarfHosts) WithRole(s string) ZarfHosts

WithRole returns a ltered list of Hosts that have the given role

func (ZarfHosts) Workers

func (hosts ZarfHosts) Workers() ZarfHosts

Workers returns hosts with the role "worker"

type ZarfRuntimeMeta

type ZarfRuntimeMeta struct {
	ControllerTLS   []string
	ControllerToken string
	AgentToken      string
	LoadBalancer    string
	Leader          *ZarfHost
}

ZarfRuntimeMeta for storing data when running the various phases

Jump to

Keyboard shortcuts

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