cluster

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 18 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     map[string]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 acts as the name of the cluster if you allow cargoship to add it to the kubeconfig
	Name string `json:"name" jsonschema:"pattern=^[a-z0-9][a-z0-9\\-]*$"`
}

ZarfClusterMetadata a cluster config

type ZarfClusterProfiles

type ZarfClusterProfiles struct {
	Host   ZarfHostConfig `json:"host,omitempty"`
	Engine ZarfHostEngine `json:"engine,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 ZarfFirewallPolicyConfig added in v0.6.0

type ZarfFirewallPolicyConfig struct {
	XMLName xml.Name           `xml:"policy" json:"-"`
	Short   string             `xml:"short,omitempty" json:"-"`
	Target  string             `xml:"target,attr,omitempty" json:"target" jsonschema:"enum=CONTINUE,enum=ACCEPT,enum=REJECT,enum=DROP"`
	Ingress ZarfFirewallZone   `xml:"ingress-zone"`
	Egress  ZarfFirewallZone   `xml:"egress-zone"`
	Ports   []ZarfFirewallPort `xml:"port,omitempty" json:"ports,omitempty"`
}

ZarfFirewallPolicyConfig is used in the inventory file to allow opening ports from one zone to another with firewalld policies

type ZarfFirewallPort added in v0.6.0

type ZarfFirewallPort struct {
	// Protocol the type of allowed traffic
	Protocol string `xml:"protocol,attr" json:"protocol" jsonschema:"enum=tcp,enum=udp,enum=sctp,enum=dccp"`
	// Port the port number, or range, that will be opened
	Port string `xml:"port,attr" json:"port" jsonschema:"oneof_type=string;integer"`
}

ZarfFirewallPort is used to define what ports are allowed thru the firewalld policy

type ZarfFirewallZone added in v0.6.0

type ZarfFirewallZone struct {
	Name string `xml:"name,attr" jsonschema:"example=trusted,example=public"`
}

ZarfFirewallZone name of either the ingress or egress zone for the policy

type ZarfHost

type ZarfHost struct {
	// Connection is a Struct you can embed into your application's "Host" types
	// to give them multi-protocol connectivity.
	rig.Connection `json:",inline"`
	// Environment a map of environment variables that will be populated on the host system
	Environment map[string]string `json:"environment,omitempty"`
	// Files that will be uploaded to a host
	Files []ZarfClusterFiles `json:"files,omitempty"`
	// Hostname overrides the name of the node
	Hostname string `json:"hostname,omitempty"`
	// PrivateAddress override the given private address
	PrivateAddress string `json:"privateAddress,omitempty"`
	// PrivateInterface override the given private interface
	PrivateInterface string `json:"privateInterface,omitempty"`
	// Profile is the name of the profile that should be used in the config
	Profile string `json:"profile,omitempty"`
	// Role of this node will be applied when adding nodes to the cluster;
	// options are either controller or worker.
	Role string `json:"role" jsonschema:"required,enum=controller,enum=worker"`
	// Host config for the various nodes
	Host ZarfHostConfig `json:"host,omitempty"`
	// Host config for the various nodes
	Engine ZarfHostEngine `json:"engine,omitempty"`
	// Configurer defines the per-host operations required for managing a host
	Configurer os.Configurer `json:"-"`
	// Metadata runtime discovered values
	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) String added in v0.5.0

func (h *ZarfHost) String() string

String returns the connection string

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 ZarfHostConfig added in v0.10.0

type ZarfHostConfig struct {
	// Policy firewalld policies to allow traffic from one interface to another
	Policy map[string]ZarfFirewallPolicyConfig `json:"policy,omitempty"`
	// Ports are a list of ports and protocols that will be opened on a specfic node
	Ports []ZarfHostPort `json:"ports,omitempty" xml:"port"`
}

ZarfHostConfig defines the configuration for a specific host, including firewall policies and ports that need to be opened on the node.

func (*ZarfHostConfig) Merge added in v0.10.0

func (c *ZarfHostConfig) Merge(update ZarfHostConfig)

Merge merges update into c if the corresponding fields in c are nil.

update: ZarfHostConfig to merge from. No return value.

type ZarfHostEngine added in v0.10.0

type ZarfHostEngine struct {
	// NodeLabels a map of node labels variables
	NodeLabels map[string]string `json:"labels,omitempty"`
	// NodeTaints that will be applied to the distro specific config that will be applied to the node
	NodeTaints []string `json:"taints,omitempty"`
}

ZarfHostEngine defines configuration options for node-level metadata, specifically Kubernetes node labels and taints applied to a cluster host.

func (*ZarfHostEngine) Merge added in v0.10.0

func (c *ZarfHostEngine) Merge(update ZarfHostEngine)

Merge merges update into c if the corresponding fields in c are nil.

update: ZarfHostEngine to merge from. No return value.

type ZarfHostMetadata

type ZarfHostMetadata struct {
	Arch           string
	BinaryTempFile []string
	DistroVersion  string
	EngineUploaded bool
	ExistingConfig string
	Hostname       string
	Install        func(context.Context, *ZarfHost) error
	// Installed is a distro engine is already installed onto a host
	Installed bool
	// IsLeader if the host is a control-plane node
	IsLeader bool
	// MachineID is used by the distro engine to identify a node
	MachineID string
	// ModulesAdded is an indication if a new kernel module was added to the host system
	ModulesAdded bool
	// NeedsUpgrade if the host needs the distro engine upgraded
	NeedsUpgrade bool
	NewConfig    string
	// Ready indicates if the distro service is up and running
	Ready bool
}

ZarfHostMetadata runtime discovered values

type ZarfHostPort

type ZarfHostPort struct {
	// Protocol the type of allowed traffic
	Protocol string `json:"protocol" xml:"protocol,attr" jsonschema:"enum=tcp,enum=udp"`
	// Port the port number, or range, that will be opened
	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