1
// This Source Code Form is subject to the terms of the Mozilla Public
2
// License, v. 2.0. If a copy of the MPL was not distributed with this
3
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
13
"github.com/google/uuid"
14
"github.com/siderolabs/go-procfs/procfs"
16
"github.com/siderolabs/talos/pkg/machinery/config"
17
"github.com/siderolabs/talos/pkg/machinery/config/machine"
18
"github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1"
21
// ClusterRequest is the root object describing cluster to be provisioned.
22
type ClusterRequest struct {
25
Network NetworkRequest
28
// Docker specific parameters.
31
// Boot options (QEMU).
41
// Path to talosctl executable to re-execute itself as needed.
44
// Path to root of state directory (~/.talos/clusters by default).
47
SiderolinkRequest SiderolinkRequest
50
// CNIConfig describes CNI part of NetworkRequest.
51
type CNIConfig struct {
59
// NetworkRequest describes cluster network.
60
type NetworkRequest struct {
63
NoMasqueradeCIDRs []netip.Prefix
64
GatewayAddrs []netip.Addr
66
Nameservers []netip.Addr
68
LoadBalancerPorts []int
70
// CNI-specific parameters.
76
// Docker-specific parameters.
77
DockerDisableIPv6 bool
79
// Network chaos parameters.
89
// NodeRequests is a list of NodeRequest.
90
type NodeRequests []NodeRequest
92
// FindInitNode looks up init node, it returns an error if no init node is present or if it's duplicate.
93
func (reqs NodeRequests) FindInitNode() (req NodeRequest, err error) {
97
if reqs[i].Config == nil {
101
if reqs[i].Config.Machine().Type() == machine.TypeInit {
103
err = errors.New("duplicate init node in requests")
114
err = errors.New("no init node found in requests")
120
// ControlPlaneNodes returns subset of nodes which are Init/ControlPlane type.
121
func (reqs NodeRequests) ControlPlaneNodes() (nodes []NodeRequest) {
122
for i := range reqs {
123
if reqs[i].Type == machine.TypeInit || reqs[i].Type == machine.TypeControlPlane {
124
nodes = append(nodes, reqs[i])
131
// WorkerNodes returns subset of nodes which are Init/ControlPlane type.
132
func (reqs NodeRequests) WorkerNodes() (nodes []NodeRequest) {
133
for i := range reqs {
134
if reqs[i].Type == machine.TypeWorker {
135
nodes = append(nodes, reqs[i])
142
// PXENodes returns subset of nodes which are PXE booted.
143
func (reqs NodeRequests) PXENodes() (nodes []NodeRequest) {
144
for i := range reqs {
145
if reqs[i].PXEBooted {
146
nodes = append(nodes, reqs[i])
153
// Disk represents a disk size and name in NodeRequest.
157
// Whether to skip preallocating the disk space.
159
// Partitions represents the list of partitions.
160
Partitions []*v1alpha1.DiskPartition
161
// Driver for the disk.
163
// Supported types: "virtio", "ide", "ahci", "scsi", "nvme".
167
// NodeRequest describes a request for a node.
168
type NodeRequest struct {
171
Config config.Provider
174
// Share of CPUs, in 1e-9 fractions
176
// Memory limit in bytes
178
// Disks (volumes), if applicable
182
// SkipInjectingConfig disables reading configuration from http server
183
SkipInjectingConfig bool
184
// DefaultBootOrder overrides default boot order "cn" (disk, then network boot).
186
// BootOrder can be forced to be "nc" (PXE boot) via the API in QEMU provisioner.
187
DefaultBootOrder string
189
// ExtraKernelArgs passes additional kernel args
190
// to the initial boot from initramfs and vmlinuz.
192
// This doesn't apply to boots from ISO or from the disk image.
193
ExtraKernelArgs *procfs.Cmdline
195
// UUID allows to specify the UUID of the node (VMs only).
197
// If not specified, a random UUID will be generated.
202
// BadRTC resets RTC to well known time in the past (QEMU provisioner).
208
IPXEBootFilename string
211
// SiderolinkRequest describes a request for SideroLink agent.
212
type SiderolinkRequest struct {
213
WireguardEndpoint string
217
SiderolinkBind []SiderolinkBind
220
// GetAddr returns the address for the given UUID.
221
func (sr *SiderolinkRequest) GetAddr(u *uuid.UUID) (netip.Addr, bool) {
222
if idx := slices.IndexFunc(sr.SiderolinkBind, func(sb SiderolinkBind) bool { return sb.UUID == *u }); idx != -1 {
223
return sr.SiderolinkBind[idx].Addr, true
226
return netip.Addr{}, false
229
// SiderolinkBind describes a pair of prebinded UUID->Addr for SideroLink agent.
230
type SiderolinkBind struct {