config

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentRole  = "agent"
	ServerRole = "server"
	// ServerName must be a valid hostname.
	// Since ctx.Project() can be a quite long string, prefix for server name is 4 character.
	ServerNamePrefix = "phkh"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolTransformer

type BoolTransformer struct{}

BoolTransformer is simple struct for mergo. ParameterDoc: none.

func (BoolTransformer) Transformer

func (b BoolTransformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error

A Transformer for mergo to avoid overwriting false values from node level.

type Config

type Config struct {

	// Nodepools is a map with agents and servers defined.
	// Required for at least one server node.
	// Default is not specified.
	Nodepools *NodepoolsConfig
	// Defaults is a map with default settings for agents and servers.
	// Global values for all nodes can be set here as well.
	// Can be empty, but required.
	// Default is not specified.
	Defaults *DefaultConfig
	// Network defines network configuration for cluster.
	// Can be empty, but required.
	// Default is not specified.
	Network *NetworkConfig
	// K8S defines a distribution-agnostic cluster configuration.
	// Can be empty, but required.
	// Default is not specified.
	K8S *k8sconfig.Config
	// contains filtered or unexported fields
}

func New

func New(ctx *pulumi.Context) *Config

New returns the parsed configuration for the cluster as is without any modifications.

func (*Config) Nodes

func (c *Config) Nodes() ([]*NodeConfig, error)

Nodes returns the nodes for the cluster. They are merged with the defaults and nodepool config values. They are sorted by majority as well.

func (*Config) Validate

func (c *Config) Validate(nodes []*NodeConfig) error

Validate validates config globally. If checking requires different parts of the configuration it should be done here, in config package. If checking requires only one specific part of the configuration in Validate() method of that part.

func (*Config) ValidateCCM

func (c *Config) ValidateCCM(_ []*NodeConfig) error

func (*Config) ValidateK3SUpgradeController

func (c *Config) ValidateK3SUpgradeController(merged []*NodeConfig) error

func (*Config) WithInited

func (c *Config) WithInited() *Config

WithInited returns the parsed configuration for the cluster with all the defaults set. Nodepools and Nodes returned sorted. This is required for the network module to work correctly when user changes order of nodepools and nodes.

type DefaultConfig

type DefaultConfig struct {
	// Global provides configuration settings that are applied to all nodes, unless overridden by specific roles.
	Global *NodeConfig

	// Servers holds configuration settings specific to server nodes, overriding Global settings where specified.
	Servers *NodeConfig

	// Agents holds configuration settings specific to agent nodes, overriding Global settings where specified.
	Agents *NodeConfig
}

func (*DefaultConfig) WithInited

func (d *DefaultConfig) WithInited() *DefaultConfig

type FirewallConfig

type FirewallConfig struct {
	// Hetzner specify firewall configuration for cloud firewall.
	Hetzner *firewall.Config
}

type NetworkConfig

type NetworkConfig struct {
	// Hetzner specifies network configuration for private networking.
	Hetzner *network.Config
}

func (*NetworkConfig) WithInited

func (n *NetworkConfig) WithInited() *NetworkConfig

type NodeConfig

type NodeConfig struct {
	// ID is id of server. It is used through entire program as key.
	// Required.
	// Default is not specified.
	ID string
	// Leader specify leader of multi-muster cluster.
	// Required if number of master more than 1.
	// Default is not specified.
	Leader bool
	// Server is configuration of hetzner server.
	Server *ServerConfig
	// K3S is configuration of k3s cluster.
	K3s *k3s.Config
	// K8S is common configuration for nodes.
	K8S *k8sconfig.NodeConfig
	// Role specifes role of server (server or agent). Do not set manually.
	// Default is computed.
	Role string
}

func (*NodeConfig) GetID

func (n *NodeConfig) GetID() string

type NodepoolConfig

type NodepoolConfig struct {
	// ID is id of group of servers. It is used through entire program as key for the group.
	// Required.
	// Default is not specified.
	ID string
	// Config is the default node configuration for group
	Config *NodeConfig
	// Nodes is a list of nodes inside of the group.
	Nodes []*NodeConfig
}

func (*NodepoolConfig) GetID

func (n *NodepoolConfig) GetID() string

type NodepoolsConfig

type NodepoolsConfig struct {
	// Servers is a list of NodepoolConfig objects, each representing a configuration for a pool of server nodes.
	Servers []*NodepoolConfig

	// Agents is a list of NodepoolConfig objects, each representing a configuration for a pool of agent nodes.
	Agents []*NodepoolConfig
}

func (*NodepoolsConfig) SpecifyLeader

func (no *NodepoolsConfig) SpecifyLeader()

func (*NodepoolsConfig) WithInited

func (no *NodepoolsConfig) WithInited(ctx *pulumi.Context) *NodepoolsConfig

type ServerConfig

type ServerConfig struct {
	// ServerType specifies the type of server to be provisioned (e.g., "cx11", "cx21").
	// Default is cx21.
	ServerType string `json:"server-type" yaml:"server-type"`

	// Hostname is the desired hostname to assign to the server.
	// Default is `phkh-${name-of-stack}-${id-of-node}`.
	Hostname string

	// Firewall points to an optional configuration for a firewall to be associated with the server.
	Firewall *FirewallConfig

	// Location specifies the physical location or data center where the server will be hosted (e.g., "fsn1").
	// Default is hel1.
	Location string

	// AdditionalSSHKeys contains a list of additional public SSH keys to install in the server's user account.
	AdditionalSSHKeys []string `json:"additional-ssh-keys" yaml:"additional-ssh-keys"`

	// UserName is the primary user account name that will be created on the server.
	// Default is rancher.
	UserName string `json:"user-name" yaml:"user-name"`

	// UserPasswd is the password for the primary user account on the server.
	UserPasswd string `json:"user-password" yaml:"user-password"`

	// Image specifies the operating system image to use for the server (e.g., "ubuntu-20.04" or id of private image).
	// Default is autodiscovered.
	Image string
}

type WithID

type WithID interface {
	GetID() string
}

Jump to

Keyboard shortcuts

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