models

package
v0.42.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package models provides cluster template models (for each sub-document of multi-doc YAML).

Index

Constants

View Source
const KindCluster = "Cluster"

KindCluster is Cluster model kind.

View Source
const KindControlPlane = "ControlPlane"

KindControlPlane is ControlPlane model kind.

View Source
const KindMachine = "Machine"

KindMachine is a Machine model kind.

View Source
const KindWorkers = "Workers"

KindWorkers is Workers model kind.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackupConfiguration

type BackupConfiguration struct {
	// Interval configures intervals between backups. If set to 0, etcd backups for this cluster are disabled.
	Interval time.Duration `yaml:"interval,omitempty"`
}

BackupConfiguration contains backup configuration settings.

type BootstrapSpec

type BootstrapSpec struct {
	// ClusterUUID defines the UUID of the cluster to restore from.
	ClusterUUID string `yaml:"clusterUUID"`

	// Snapshot defines the snapshot file name to restore from.
	Snapshot string `yaml:"snapshot"`
}

BootstrapSpec defines the model for setting the bootstrap specification, i.e. restoring from a backup, in the machine set. Only valid for the control plane machine set.

type Cluster

type Cluster struct {
	Meta             `yaml:",inline"`
	SystemExtensions `yaml:",inline"`

	// Name is the name of the cluster.
	Name string `yaml:"name"`

	// Descriptors are the user descriptors to apply to the cluster.
	Descriptors Descriptors `yaml:",inline"`

	// Kubernetes settings.
	Kubernetes KubernetesCluster `yaml:"kubernetes"`

	// Talos settings.
	Talos TalosCluster `yaml:"talos"`

	// Features settings.
	Features Features `yaml:"features,omitempty"`

	// Cluster-wide patches.
	Patches PatchList `yaml:"patches,omitempty"`
}

Cluster is a top-level template object.

func (*Cluster) Translate

func (cluster *Cluster) Translate(ctx TranslateContext) ([]resource.Resource, error)

Translate into Omni resources.

func (*Cluster) Validate

func (cluster *Cluster) Validate() error

Validate the model.

type ControlPlane

type ControlPlane struct {
	MachineSet `yaml:",inline"`
}

ControlPlane describes Cluster controlplane nodes.

func (*ControlPlane) Translate

func (controlplane *ControlPlane) Translate(ctx TranslateContext) ([]resource.Resource, error)

Translate the model.

func (*ControlPlane) Validate

func (controlplane *ControlPlane) Validate() error

Validate the model.

type Descriptors

type Descriptors struct {
	// Labels are the user labels to apply to the resource.
	Labels map[string]string `yaml:"labels,omitempty"`

	// Annotations are the user annotations to apply to the resource.
	Annotations map[string]string `yaml:"annotations,omitempty"`
}

Descriptors are the user descriptors (i.e. Labels, Annotations) to apply to the resource.

func (*Descriptors) Apply

func (d *Descriptors) Apply(res resource.Resource)

Apply applies the descriptors to the given resource.

func (*Descriptors) Validate

func (d *Descriptors) Validate() error

Validate validates the descriptors.

type Features

type Features struct {
	// DiskEncryption enables KMS encryption.
	DiskEncryption bool `yaml:"diskEncryption,omitempty"`
	// EnableWorkloadProxy enables workload proxy.
	EnableWorkloadProxy bool `yaml:"enableWorkloadProxy,omitempty"`
	// UseEmbeddedDiscoveryService enables the use of embedded discovery service.
	UseEmbeddedDiscoveryService bool `yaml:"useEmbeddedDiscoveryService,omitempty"`
	// BackupConfiguration contains backup configuration settings.
	BackupConfiguration BackupConfiguration `yaml:"backupConfiguration,omitempty"`
}

Features defines cluster-wide features.

type KubernetesCluster

type KubernetesCluster struct {
	// Version is the Kubernetes version.
	Version string `yaml:"version"`
}

KubernetesCluster is a Kubernetes cluster settings.

func (*KubernetesCluster) Validate

func (kubernetes *KubernetesCluster) Validate() error

Validate the model.

type List

type List []Model

List implements a list of models, essentially it's a template.

func (List) ClusterName

func (l List) ClusterName() (string, error)

ClusterName returns the name of the cluster in the template.

func (List) Translate

func (l List) Translate() ([]resource.Resource, error)

Translate a set of models (template) to a set of Omni resources.

Translate assumes that the template is valid.

func (List) Validate

func (l List) Validate() error

Validate the set of models as a complete template.

Each model should be valid, but also the set of models should be complete.

type Machine

type Machine struct {
	Meta             `yaml:",inline"`
	SystemExtensions `yaml:",inline"`

	// Machine name (ID).
	Name MachineID `yaml:"name"`

	// Descriptors are the user descriptors to apply to the cluster.
	Descriptors Descriptors `yaml:",inline"`

	// Locked locks the machine, so no config updates, upgrades and downgrades will be performed on the machine.
	Locked bool `yaml:"locked,omitempty"`

	// Install specification.
	Install MachineInstall `yaml:"install,omitempty"`

	// ClusterMachine patches.
	Patches PatchList `yaml:"patches,omitempty"`
}

Machine provides customization for a specific machine.

func (*Machine) Translate

func (machine *Machine) Translate(ctx TranslateContext) ([]resource.Resource, error)

Translate the model.

func (*Machine) Validate

func (machine *Machine) Validate() error

Validate the model.

type MachineClassConfig

type MachineClassConfig struct {
	// Name defines used machine class name.
	Name string `yaml:"name"`

	// Size sets the number of machines to be pulled from the machine class.
	Size Size `yaml:"size"`
}

MachineClassConfig defines the model for setting the machine class based machine selector in the machine set.

type MachineID

type MachineID string

MachineID is a Machine UUID.

func (MachineID) Validate

func (id MachineID) Validate() error

Validate the model.

type MachineIDList

type MachineIDList []MachineID

MachineIDList is a list of Machine UUIDs.

func (MachineIDList) Validate

func (l MachineIDList) Validate() error

Validate the list of machines.

type MachineInstall

type MachineInstall struct {
	// Disk device name.
	Disk string `yaml:"disk"`
}

MachineInstall provides machine install configuration.

func (*MachineInstall) Validate

func (install *MachineInstall) Validate() error

Validate the model.

type MachineSet

type MachineSet struct {
	Meta             `yaml:",inline"`
	SystemExtensions `yaml:",inline"`

	// Name is the name of the machine set. When empty, the default name will be used.
	Name string `yaml:"name,omitempty"`

	// Descriptors are the user descriptors to apply to the cluster.
	Descriptors Descriptors `yaml:",inline"`

	BootstrapSpec *BootstrapSpec `yaml:"bootstrapSpec,omitempty"`

	// MachineSet machines.
	Machines MachineIDList `yaml:"machines,omitempty"`

	MachineClass *MachineClassConfig `yaml:"machineClass,omitempty"`

	// UpdateStrategy defines the update strategy for the machine set.
	UpdateStrategy *UpdateStrategyConfig `yaml:"updateStrategy,omitempty"`

	// DeleteStrategy defines the delete strategy for the machine set.
	DeleteStrategy *UpdateStrategyConfig `yaml:"deleteStrategy,omitempty"`

	// MachineSet patches.
	Patches PatchList `yaml:"patches,omitempty"`
}

MachineSet is a base model for controlplane and workers.

func (*MachineSet) Validate

func (machineset *MachineSet) Validate() error

Validate checks the machine set fields correctness.

type Meta

type Meta struct {
	Kind string `yaml:"kind"`
}

Meta is embedded into all template objects.

type Model

type Model interface {
	Validate() error
	Translate(TranslateContext) ([]resource.Resource, error)
}

Model is a base interface for cluster templates.

func New

func New(kind string) (Model, error)

New creates a model by kind.

type Patch

type Patch struct {
	// Name of the patch.
	//
	// Optional for 'path' patches, mandatory for 'inline' patches if idOverride is not set.
	Name string `yaml:"name,omitempty"`

	// IDOverride overrides the ID of the patch. When set, the ID will not be generated using the name and/or the file path.
	IDOverride string `yaml:"idOverride,omitempty"`

	// Descriptors are the user descriptors to apply to the resource.
	Descriptors Descriptors `yaml:",inline"`

	// File path to the file containing the patch.
	//
	// Mutually exclusive with `inline:`.
	File string `yaml:"file,omitempty"`

	// Inline patch content.
	Inline map[string]any `yaml:"inline,omitempty"`
}

Patch is a Talos machine configuration patch.

func (*Patch) Translate

func (patch *Patch) Translate(prefix string, weight int, labels ...pair.Pair[string, string]) (*omni.ConfigPatch, error)

Translate the model into a resource.

func (*Patch) Validate

func (patch *Patch) Validate() error

Validate the model.

type PatchList

type PatchList []Patch

PatchList is a list of patches.

func (PatchList) Translate

func (l PatchList) Translate(prefix string, baseWeight int, labels ...pair.Pair[string, string]) ([]resource.Resource, error)

Translate the list of patches into a list of resources.

func (PatchList) Validate

func (l PatchList) Validate() error

Validate the model.

type RollingUpdateStrategyConfig

type RollingUpdateStrategyConfig struct {
	MaxParallelism uint32 `yaml:"maxParallelism,omitempty"`
}

RollingUpdateStrategyConfig defines the model for setting the rolling update strategy in the machine set.

type Size

type Size struct {
	Value          uint32
	AllocationType specs.MachineSetSpec_MachineClass_AllocationType
}

Size extends protobuf generated allocation type enum to parse string constants.

func (Size) MarshalYAML

func (c Size) MarshalYAML() (any, error)

MarshalYAML implements yaml.Marshaler.

func (*Size) UnmarshalYAML

func (c *Size) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements yaml.Unmarshaler.

type SystemExtensions added in v0.33.1

type SystemExtensions struct {
	SystemExtensions []string `yaml:"systemExtensions,omitempty"`
}

SystemExtensions is embedded in Cluster, MachineSet and Machine objects.

type TalosCluster

type TalosCluster struct {
	// Version is the Talos version.
	Version string `yaml:"version"`
}

TalosCluster is a Talos cluster settings.

func (*TalosCluster) Validate

func (talos *TalosCluster) Validate() error

Validate the model.

type TranslateContext

type TranslateContext struct {
	LockedMachines map[MachineID]struct{}

	MachineDescriptors map[MachineID]Descriptors

	// ClusterName is the name of the cluster.
	ClusterName string
}

TranslateContext is a context for translation.

type UpdateStrategyConfig

type UpdateStrategyConfig struct {
	Type    *UpdateStrategyType          `yaml:"type,omitempty"`
	Rolling *RollingUpdateStrategyConfig `yaml:"rolling,omitempty"`
}

UpdateStrategyConfig defines the model for setting the update strategy in the machine set.

type UpdateStrategyType

type UpdateStrategyType uint32

UpdateStrategyType extends protobuf generated update strategy enum to parse string constants.

func (UpdateStrategyType) MarshalYAML

func (t UpdateStrategyType) MarshalYAML() (any, error)

MarshalYAML implements yaml.Marshaler.

func (*UpdateStrategyType) UnmarshalYAML

func (t *UpdateStrategyType) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements yaml.Unmarshaler.

type Workers

type Workers struct {
	MachineSet `yaml:",inline"`
}

Workers describes Cluster worker nodes.

func (*Workers) Translate

func (workers *Workers) Translate(ctx TranslateContext) ([]resource.Resource, error)

Translate the model.

func (*Workers) Validate

func (workers *Workers) Validate() error

Validate the model.

Jump to

Keyboard shortcuts

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