config

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config handles loading, parsing, and validating the homelab cluster configuration from YAML files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterConfig

type ClusterConfig struct {
	Name       string `yaml:"name"`
	K3sVersion string `yaml:"k3sVersion"`
	Kubeconfig string `yaml:"kubeconfig"`
}

ClusterConfig holds cluster-wide settings.

type Config

type Config struct {
	Cluster ClusterConfig `yaml:"cluster"`
	Nodes   []NodeConfig  `yaml:"nodes"`
}

Config is the top-level configuration for a homelab cluster.

func Load

func Load(path string) (*Config, error)

Load reads and parses a config file from the given path. It will search parent directories for the file if only a filename is provided.

func (*Config) AgentNodes

func (c *Config) AgentNodes() []NodeConfig

AgentNodes returns only the nodes with role "agent".

func (*Config) InitNode

func (c *Config) InitNode() NodeConfig

InitNode returns the first server node, which is used to bootstrap the cluster.

func (*Config) ServerNodes

func (c *Config) ServerNodes() []NodeConfig

ServerNodes returns only the nodes with role "server".

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that the config is well-formed and internally consistent.

type NodeConfig

type NodeConfig struct {
	Host       string   `yaml:"host"`
	Role       string   `yaml:"role"` // "server" or "agent"
	Pool       string   `yaml:"pool"`
	VM         VMConfig `yaml:"vm"`
	VMName     string   `yaml:"vmName,omitempty"`     // Override default VM name (default: "k8s-node")
	SSHUser    string   `yaml:"sshUser,omitempty"`    // SSH username (default: current user)
	SSHPort    string   `yaml:"sshPort,omitempty"`    // SSH port (default: 22)
	SSHKeyPath string   `yaml:"sshKeyPath,omitempty"` // Path to SSH private key (optional)
}

NodeConfig describes a single node in the cluster.

func (*NodeConfig) GetVMName

func (n *NodeConfig) GetVMName() string

GetVMName returns the VM name for this node, defaulting to "k8s-node".

type VMConfig

type VMConfig struct {
	CPUs   int    `yaml:"cpus"`
	Memory string `yaml:"memory"`
	Disk   string `yaml:"disk"`
}

VMConfig describes the resource allocation for a Lima VM.

Jump to

Keyboard shortcuts

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