Documentation
¶
Overview ¶
Package models provides cluster template models (for each sub-document of multi-doc YAML).
Index ¶
- Constants
- type BackupConfiguration
- type BootstrapSpec
- type Cluster
- type ControlPlane
- type Descriptors
- type Features
- type FileContext
- type InlineContent
- type KubernetesCluster
- type KubernetesHealthCheck
- type KubernetesHealthCheckList
- type KubernetesManifest
- type KubernetesManifestMode
- type KubernetesManifestsList
- type List
- type Machine
- type MachineClassConfig
- type MachineID
- type MachineIDList
- type MachineInstall
- type MachineSet
- type Meta
- type Model
- type OptionalList
- type Patch
- type PatchList
- type RollingUpdateStrategyConfig
- type Size
- type TalosCluster
- type TranslateContext
- type UpdateStrategyConfig
- type UpdateStrategyType
- type ValidateOptions
- type Workers
Constants ¶
const KindCluster = "Cluster"
KindCluster is Cluster model kind.
const KindControlPlane = "ControlPlane"
KindControlPlane is ControlPlane model kind.
const KindMachine = "Machine"
KindMachine is a Machine model kind.
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 are the system extensions to install on the machines of the cluster.
SystemExtensions OptionalList `yaml:"systemExtensions,omitempty"`
// 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"`
// KernelArgs are the additional kernel arguments.
KernelArgs OptionalList `yaml:"kernelArgs,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(opts ValidateOptions) 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(opts ValidateOptions) 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 FileContext ¶ added in v1.8.0
type FileContext struct {
// Root restricts file access to a single directory tree. When nil, no restriction is applied.
Root *os.Root
// Dir is the directory used to resolve relative file paths from the template.
// When empty, callers should treat it as "." (for example, for non-file-backed templates).
Dir string
}
FileContext describes how to resolve and read files referenced by a template.
type InlineContent ¶ added in v1.8.0
type InlineContent struct {
// contains filtered or unexported fields
}
InlineContent represents inline YAML content embedded into a template.
It accepts three input forms:
- a single YAML mapping,
- a sequence of YAML mappings (multi-document),
- a raw YAML literal block scalar (bytes).
func NewInlineContent ¶ added in v1.8.0
func NewInlineContent(docs ...map[string]any) *InlineContent
NewInlineContent builds InlineContent from one or more YAML mappings.
func NewInlineContentBytes ¶ added in v1.8.0
func NewInlineContentBytes(raw []byte) *InlineContent
NewInlineContentBytes builds InlineContent from raw YAML bytes.
func (InlineContent) Bytes ¶ added in v1.8.0
func (i InlineContent) Bytes() ([]byte, error)
Bytes returns the YAML-encoded inline content.
Multi-document content is encoded with the standard YAML multi-document framing.
func (InlineContent) IsZero ¶ added in v1.8.0
func (i InlineContent) IsZero() bool
IsZero reports whether the InlineContent is empty.
func (InlineContent) MarshalYAML ¶ added in v1.8.0
func (i InlineContent) MarshalYAML() (any, error)
MarshalYAML implements yaml.Marshaler.
func (*InlineContent) UnmarshalYAML ¶ added in v1.8.0
func (i *InlineContent) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
type KubernetesCluster ¶
type KubernetesCluster struct {
// Version is the Kubernetes version.
Version string `yaml:"version"`
// Manifests allow defining Kubernetes manifests to be applied to the deployed Omni cluster.
Manifests KubernetesManifestsList `yaml:"manifests,omitempty"`
// Healthchecks are advanced healthcheck definitions deployed into the cluster.
Healthchecks KubernetesHealthCheckList `yaml:"healthchecks,omitempty"`
}
KubernetesCluster is a Kubernetes cluster settings.
type KubernetesHealthCheck ¶ added in v1.9.0
type KubernetesHealthCheck struct {
// Descriptors are the user descriptors to apply to the resource.
Descriptors Descriptors `yaml:",inline"`
// IDOverride overrides the generated resource ID. When set, the prefix is ignored.
IDOverride string `yaml:"idOverride,omitempty"`
// Name of the healthcheck, used to derive the resource ID.
Name string `yaml:"name,omitempty"`
// Job is the inline Kubernetes Job manifest Omni runs to perform the healthcheck. Mutually exclusive with File.
Job *InlineContent `yaml:"job,omitempty"`
// File is the path to a file whose contents are used as the Job manifest. Mutually exclusive with Job.
File string `yaml:"file,omitempty"`
// Interval is how often Omni re-checks while it is holding an upgrade. If not set, a default interval of
// 30s is used.
Interval time.Duration `yaml:"interval,omitempty"`
}
KubernetesHealthCheck is an advanced healthcheck definition: a Kubernetes Job that Omni runs to check the cluster while it gates an upgrade, plus how often Omni re-checks.
func (*KubernetesHealthCheck) Translate ¶ added in v1.9.0
func (h *KubernetesHealthCheck) Translate(ctx TranslateContext, prefix string, labels ...pair.Pair[string, string]) (*omni.KubernetesHealthCheck, error)
Translate the healthcheck into an Omni resource.
prefix is used to namespace the generated resource ID when IDOverride is not set.
func (*KubernetesHealthCheck) Validate ¶ added in v1.9.0
func (h *KubernetesHealthCheck) Validate(opts ValidateOptions) error
Validate the healthcheck.
type KubernetesHealthCheckList ¶ added in v1.9.0
type KubernetesHealthCheckList []KubernetesHealthCheck
KubernetesHealthCheckList is a list of advanced healthchecks.
func (KubernetesHealthCheckList) Translate ¶ added in v1.9.0
func (l KubernetesHealthCheckList) Translate(ctx TranslateContext, prefix string, labels ...pair.Pair[string, string]) ([]resource.Resource, error)
Translate the list of healthchecks into resources.
func (KubernetesHealthCheckList) Validate ¶ added in v1.9.0
func (l KubernetesHealthCheckList) Validate(opts ValidateOptions) error
Validate the list of healthchecks.
type KubernetesManifest ¶ added in v1.7.0
type KubernetesManifest struct {
Inline *InlineContent `yaml:"inline,omitempty"`
Descriptors Descriptors `yaml:",inline"`
Name string `yaml:"name"`
File string `yaml:"file,omitempty"`
Mode KubernetesManifestMode `yaml:"mode"`
}
KubernetesManifest represents the kubernetes manifest to be applied in the cluster. The manifests are applied on the server side.
func (*KubernetesManifest) GetManifests ¶ added in v1.8.0
func (km *KubernetesManifest) GetManifests() ([]byte, error)
GetManifests returns the inline manifest content as YAML bytes.
The result may contain a single document or multiple documents separated by `---`, depending on the input form.
func (*KubernetesManifest) Translate ¶ added in v1.7.0
func (km *KubernetesManifest) Translate(ctx TranslateContext, prefix string, weight int, labels ...pair.Pair[string, string]) (*omni.KubernetesManifestGroup, error)
Translate the model into a resource.
func (*KubernetesManifest) Validate ¶ added in v1.7.0
func (km *KubernetesManifest) Validate(opts ValidateOptions) error
Validate a kubernetes manifest.
type KubernetesManifestMode ¶ added in v1.7.0
type KubernetesManifestMode specs.KubernetesManifestGroupSpec_Mode
func (KubernetesManifestMode) MarshalYAML ¶ added in v1.7.0
func (c KubernetesManifestMode) MarshalYAML() (any, error)
MarshalYAML implements yaml.Marshaler.
func (*KubernetesManifestMode) UnmarshalYAML ¶ added in v1.7.0
func (c *KubernetesManifestMode) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML implements yaml.Unmarshaler.
type KubernetesManifestsList ¶ added in v1.7.0
type KubernetesManifestsList []KubernetesManifest
KubernetesManifestsList is the list of KubernetesManifest structs.
func (KubernetesManifestsList) Translate ¶ added in v1.7.0
func (l KubernetesManifestsList) Translate(ctx TranslateContext, prefix string, baseWeight int, labels ...pair.Pair[string, string]) ([]resource.Resource, error)
Translate the list of KubernetesManifests into a list of resources.
func (KubernetesManifestsList) Validate ¶ added in v1.7.0
func (k KubernetesManifestsList) Validate(opts ValidateOptions) error
Validate the manifests in the list.
type List ¶
type List []Model
List implements a list of models, essentially it's a template.
func (List) ClusterName ¶
ClusterName returns the name of the cluster in the template.
func (List) Translate ¶
func (l List) Translate(fc FileContext) ([]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(opts ValidateOptions) 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 are the system extensions to install on the machine.
SystemExtensions OptionalList `yaml:"systemExtensions,omitempty"`
// 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"`
// KernelArgs are the additional kernel arguments.
KernelArgs OptionalList `yaml:"kernelArgs,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(opts ValidateOptions) 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 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 are the system extensions to install on the machines of the machine set.
SystemExtensions OptionalList `yaml:"systemExtensions,omitempty"`
// 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"`
// UpgradeStrategy defines the upgrade strategy for the machine set.
UpgradeStrategy *UpdateStrategyConfig `yaml:"upgradeStrategy,omitempty"`
// MachineSet patches.
Patches PatchList `yaml:"patches,omitempty"`
// KernelArgs are the additional kernel arguments.
KernelArgs OptionalList `yaml:"kernelArgs,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(ValidateOptions) error
Translate(TranslateContext) ([]resource.Resource, error)
}
Model is a base interface for cluster templates.
type OptionalList ¶ added in v1.9.0
type OptionalList struct {
// contains filtered or unexported fields
}
OptionalList is a list of strings that tells an unset list apart from an explicitly empty one.
An unset list is omitted from YAML, while a defined list is rendered as a sequence, including the empty `[]`. This lets a template express "leave this as it is" separately from "clear it".
func NewOptionalList ¶ added in v1.9.0
func NewOptionalList(values []string) OptionalList
NewOptionalList returns a defined OptionalList holding the given values.
func (OptionalList) Get ¶ added in v1.9.0
func (l OptionalList) Get() (values []string, defined bool)
Get returns the list and whether it is defined.
func (OptionalList) IsZero ¶ added in v1.9.0
func (l OptionalList) IsZero() bool
IsZero reports whether the list is unset, so that it is omitted from YAML.
func (OptionalList) MarshalYAML ¶ added in v1.9.0
func (l OptionalList) MarshalYAML() (any, error)
MarshalYAML implements yaml.Marshaler.
func (*OptionalList) Set ¶ added in v1.9.0
func (l *OptionalList) Set(values []string)
Set sets the list, marking it as defined.
func (*OptionalList) UnmarshalYAML ¶ added in v1.9.0
func (l *OptionalList) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler.
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 *InlineContent `yaml:"inline,omitempty"`
}
Patch is a Talos machine configuration patch.
func (*Patch) GetPatches ¶ added in v1.8.0
GetPatches returns the inline patch content as YAML bytes.
The result may contain a single document or multiple documents separated by `---`, depending on the input form.
func (*Patch) Translate ¶
func (patch *Patch) Translate(ctx TranslateContext, 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(opts ValidateOptions) error
Validate the model.
type PatchList ¶
type PatchList []Patch
PatchList is a list of patches.
func (PatchList) Translate ¶
func (l PatchList) Translate(ctx TranslateContext, 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(opts ValidateOptions) 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_MachineAllocation_Type
}
Size extends protobuf generated allocation type enum to parse string constants.
func (Size) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler.
type TalosCluster ¶
type TalosCluster struct {
// Version is the Talos version.
Version string `yaml:"version"`
}
TalosCluster is a Talos cluster settings.
type TranslateContext ¶
type TranslateContext struct {
FileContext
LockedMachines map[MachineID]struct{}
MachineDescriptors map[MachineID]Descriptors
MachineSetLevelKernelArgs map[MachineID]OptionalList
ClusterName string
ClusterLevelKernelArgs OptionalList
}
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 ValidateOptions ¶ added in v1.8.0
type ValidateOptions struct {
FileContext
}
ValidateOptions contains options for model validation.
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(opts ValidateOptions) error
Validate the model.