provision

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MPL-2.0 Imports: 14 Imported by: 2

Documentation

Overview

Package provision provides abstract definitions for Talos cluster provisioners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CNIConfig

type CNIConfig struct {
	BinPath  []string
	ConfDir  string
	CacheDir string

	BundleURL string
}

CNIConfig describes CNI part of NetworkRequest.

type Cluster

type Cluster interface {
	// Provisioner returns name of the provisioner used to build the cluster.
	Provisioner() string
	// StatePath returns path to the state directory of the cluster.
	StatePath() (string, error)
	// Info returns running cluster information.
	Info() ClusterInfo
}

Cluster describes the provisioned Cluster.

type ClusterInfo

type ClusterInfo struct {
	ClusterName string

	Network NetworkInfo
	Nodes   []NodeInfo

	// ExtraNodes are not part of the cluster.
	ExtraNodes []NodeInfo
}

ClusterInfo describes the cluster.

type ClusterRequest

type ClusterRequest struct {
	Name string

	Network NetworkRequest
	Nodes   NodeRequests

	Image         string
	KernelPath    string
	InitramfsPath string
	ISOPath       string
	DiskImagePath string

	// Path to talosctl executable to re-execute itself as needed.
	SelfExecutable string

	// Path to root of state directory (~/.talos/clusters by default).
	StateDirectory string
}

ClusterRequest is the root object describing cluster to be provisioned.

type Disk

type Disk struct {
	// Size in bytes.
	Size uint64
	// Partitions represents the list of partitions.
	Partitions []*v1alpha1.DiskPartition
}

Disk represents a disk size and name in NodeRequest.

type NetworkInfo

type NetworkInfo struct {
	Name         string
	CIDRs        []netip.Prefix
	GatewayAddrs []netip.Addr
	MTU          int
}

NetworkInfo describes cluster network.

type NetworkRequest

type NetworkRequest struct {
	Name         string
	CIDRs        []netip.Prefix
	GatewayAddrs []netip.Addr
	MTU          int
	Nameservers  []netip.Addr

	LoadBalancerPorts []int

	// CNI-specific parameters.
	CNI CNIConfig

	// DHCP options
	DHCPSkipHostname bool

	// Docker-specific parameters.
	DockerDisableIPv6 bool
}

NetworkRequest describes cluster network.

type NodeInfo

type NodeInfo struct {
	ID   string
	UUID uuid.UUID
	Name string
	Type machine.Type

	// Share of CPUs, in 1e-9 fractions
	NanoCPUs int64
	// Memory limit in bytes
	Memory int64
	// Disk (volume) size in bytes, if applicable
	DiskSize uint64

	IPs []netip.Addr

	APIPort int
}

NodeInfo describes a node.

type NodeRequest

type NodeRequest struct {
	Name   string
	IPs    []netip.Addr
	Config config.Provider
	Type   machine.Type

	// Share of CPUs, in 1e-9 fractions
	NanoCPUs int64
	// Memory limit in bytes
	Memory int64
	// Disks (volumes), if applicable
	Disks []*Disk
	// Ports
	Ports []string
	// SkipInjectingConfig disables reading configuration from http server
	SkipInjectingConfig bool
	// DefaultBootOrder overrides default boot order "cn" (disk, then network boot).
	//
	// BootOrder can be forced to be "nc" (PXE boot) via the API in QEMU provisioner.
	DefaultBootOrder string

	// ExtraKernelArgs passes additional kernel args
	// to the initial boot from initramfs and vmlinuz.
	//
	// This doesn't apply to boots from ISO or from the disk image.
	ExtraKernelArgs *procfs.Cmdline

	// BadRTC resets RTC to well known time in the past (QEMU provisioner).
	BadRTC bool

	// PXE-booted VMs
	PXEBooted        bool
	TFTPServer       string
	IPXEBootFilename string
}

NodeRequest describes a request for a node.

type NodeRequests

type NodeRequests []NodeRequest

NodeRequests is a list of NodeRequest.

func (NodeRequests) ControlPlaneNodes

func (reqs NodeRequests) ControlPlaneNodes() (nodes []NodeRequest)

ControlPlaneNodes returns subset of nodes which are Init/ControlPlane type.

func (NodeRequests) FindInitNode

func (reqs NodeRequests) FindInitNode() (req NodeRequest, err error)

FindInitNode looks up init node, it returns an error if no init node is present or if it's duplicate.

func (NodeRequests) PXENodes

func (reqs NodeRequests) PXENodes() (nodes []NodeRequest)

PXENodes returns subset of nodes which are PXE booted.

func (NodeRequests) WorkerNodes

func (reqs NodeRequests) WorkerNodes() (nodes []NodeRequest)

WorkerNodes returns subset of nodes which are Init/ControlPlane type.

type Option

type Option func(o *Options) error

Option controls Provisioner.

func WithBootlader

func WithBootlader(enabled bool) Option

WithBootlader enables or disables bootloader (bootloader is enabled by default).

func WithDeleteOnErr

func WithDeleteOnErr(v bool) Option

WithDeleteOnErr informs the provisioner to delete cluster state folder on error.

func WithDockerPorts

func WithDockerPorts(ports []string) Option

WithDockerPorts allows docker provisioner to expose ports on workers.

func WithDockerPortsHostIP

func WithDockerPortsHostIP(hostIP string) Option

WithDockerPortsHostIP sets host IP for docker provisioner to expose ports on workers.

func WithEndpoint

func WithEndpoint(endpoint string) Option

WithEndpoint specifies endpoint to use when acessing Talos cluster.

func WithExtraUEFISearchPaths

func WithExtraUEFISearchPaths(extraUEFISearchPaths []string) Option

WithExtraUEFISearchPaths configures additional search paths to look for UEFI firmware.

func WithLogWriter

func WithLogWriter(w io.Writer) Option

WithLogWriter sets logging destination.

func WithTalosClient

func WithTalosClient(client *client.Client) Option

WithTalosClient specifies client to use when acessing Talos cluster.

func WithTalosConfig

func WithTalosConfig(talosConfig *clientconfig.Config) Option

WithTalosConfig specifies talosconfig to use when acessing Talos cluster.

func WithTargetArch

func WithTargetArch(arch string) Option

WithTargetArch specifies target architecture for the cluster.

func WithUEFI

func WithUEFI(enabled bool) Option

WithUEFI enables or disables UEFI boot on amd64 (default for amd64 is BIOS boot).

type Options

type Options struct {
	LogWriter     io.Writer
	TalosConfig   *clientconfig.Config
	TalosClient   *client.Client
	ForceEndpoint string
	TargetArch    string

	// Enable bootloader by booting from disk image after install.
	BootloaderEnabled bool

	// Enable UEFI (for amd64), arm64 can only boot UEFI
	UEFIEnabled bool
	// Configure additional search paths to look for UEFI firmware.
	ExtraUEFISearchPaths []string

	// Expose ports to worker machines in docker provisioner
	DockerPorts       []string
	DockerPortsHostIP string
	DeleteStateOnErr  bool
}

Options describes Provisioner parameters.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns default options.

type Provisioner

type Provisioner interface {
	Create(context.Context, ClusterRequest, ...Option) (Cluster, error)
	Destroy(context.Context, Cluster, ...Option) error

	CrashDump(context.Context, Cluster, io.Writer)

	Reflect(ctx context.Context, clusterName, stateDirectory string) (Cluster, error)

	GenOptions(NetworkRequest) []generate.GenOption
	GetLoadBalancers(NetworkRequest) (internalEndpoint, externalEndpoint string)
	GetFirstInterface() string

	Close() error

	UserDiskName(index int) string
}

Provisioner is an interface each provisioner should implement.

Directories

Path Synopsis
Package access provides methods to access provisioned Talos cluster.
Package access provides methods to access provisioned Talos cluster.
internal
cniutils
Package cniutils provides helper functions to parse CNI results.
Package cniutils provides helper functions to parse CNI results.
inmemhttp
Package inmemhttp implements temporary HTTP server which is based off memory fs.
Package inmemhttp implements temporary HTTP server which is based off memory fs.
docker
Package docker implements Provisioner via docker.
Package docker implements Provisioner via docker.
vm
Package vm implements common methods for VM provisioners.
Package vm implements common methods for VM provisioners.

Jump to

Keyboard shortcuts

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