mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-18 04:27:06 +02:00
This fixes the reverse Go dependency from `pkg/machinery` to `talos` package. Add a check to `Dockerfile` to prevent `pkg/machinery/go.mod` getting out of sync, this should prevent problems in the future. Fix potential security issue in `token` authorizer to deny requests without grpc metadata. In provisioner, add support for launching nodes without the config (config is not delivered to the provisioned nodes). Breaking change in `pkg/provision`: now `NodeRequest.Type` should be set to the node type (as config can be missing now). In `talosctl cluster create` add a flag to skip providing config to the nodes so that they enter maintenance mode, while the generated configs are written down to disk (so they can be tweaked and applied easily). Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
148 lines
3.1 KiB
Go
148 lines
3.1 KiB
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package provision
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
|
|
"github.com/talos-systems/talos/pkg/machinery/config"
|
|
"github.com/talos-systems/talos/pkg/machinery/config/types/v1alpha1"
|
|
"github.com/talos-systems/talos/pkg/machinery/config/types/v1alpha1/machine"
|
|
)
|
|
|
|
// ClusterRequest is the root object describing cluster to be provisioned.
|
|
type ClusterRequest struct {
|
|
Name string
|
|
|
|
Network NetworkRequest
|
|
Nodes NodeRequests
|
|
|
|
Image string
|
|
KernelPath string
|
|
InitramfsPath 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
|
|
}
|
|
|
|
// CNIConfig describes CNI part of NetworkRequest.
|
|
type CNIConfig struct {
|
|
BinPath []string
|
|
ConfDir string
|
|
CacheDir string
|
|
|
|
BundleURL string
|
|
}
|
|
|
|
// NetworkRequest describes cluster network.
|
|
type NetworkRequest struct {
|
|
Name string
|
|
CIDR net.IPNet
|
|
GatewayAddr net.IP
|
|
MTU int
|
|
Nameservers []net.IP
|
|
|
|
// CNI-specific parameters.
|
|
CNI CNIConfig
|
|
}
|
|
|
|
// NodeRequests is a list of NodeRequest.
|
|
type NodeRequests []NodeRequest
|
|
|
|
// FindInitNode looks up init node, it returns an error if no init node is present or if it's duplicate.
|
|
func (reqs NodeRequests) FindInitNode() (req NodeRequest, err error) {
|
|
found := false
|
|
|
|
for i := range reqs {
|
|
if reqs[i].Config == nil {
|
|
continue
|
|
}
|
|
|
|
if reqs[i].Config.Machine().Type() == machine.TypeInit {
|
|
if found {
|
|
err = fmt.Errorf("duplicate init node in requests")
|
|
|
|
return
|
|
}
|
|
|
|
req = reqs[i]
|
|
found = true
|
|
}
|
|
}
|
|
|
|
if !found {
|
|
err = fmt.Errorf("no init node found in requests")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// MasterNodes returns subset of nodes which are Init/ControlPlane type.
|
|
func (reqs NodeRequests) MasterNodes() (nodes []NodeRequest) {
|
|
for i := range reqs {
|
|
if reqs[i].Type == machine.TypeInit || reqs[i].Type == machine.TypeControlPlane {
|
|
nodes = append(nodes, reqs[i])
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// WorkerNodes returns subset of nodes which are Init/ControlPlane type.
|
|
func (reqs NodeRequests) WorkerNodes() (nodes []NodeRequest) {
|
|
for i := range reqs {
|
|
if reqs[i].Type == machine.TypeJoin {
|
|
nodes = append(nodes, reqs[i])
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// PXENodes returns subset of nodes which are PXE booted.
|
|
func (reqs NodeRequests) PXENodes() (nodes []NodeRequest) {
|
|
for i := range reqs {
|
|
if reqs[i].PXEBooted {
|
|
nodes = append(nodes, reqs[i])
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// Disk represents a disk size and name in NodeRequest.
|
|
type Disk struct {
|
|
// Size in bytes.
|
|
Size uint64
|
|
// Partitions represents the list of partitions.
|
|
Partitions []*v1alpha1.DiskPartition
|
|
}
|
|
|
|
// NodeRequest describes a request for a node.
|
|
type NodeRequest struct {
|
|
Name string
|
|
IP net.IP
|
|
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
|
|
|
|
// PXE-booted VMs
|
|
PXEBooted bool
|
|
TFTPServer string
|
|
IPXEBootFilename string
|
|
}
|