config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SchemeVersion = 1
	SanitizeMask  = "***"
)
View Source
const (
	BondModeBalanceRR    = "balance-rr"
	BondModeActiveBackup = "active-backup"
	BondModeBalnaceXOR   = "balance-xor"
	BondModeBroadcast    = "broadcast"
	BondModeIEEE802_3ad  = "802.3ad"
	BondModeBalanceTLB   = "balance-tlb"
	BondModeBalanceALB   = "balance-alb"
)
View Source
const (
	SingleDiskMinSizeGiB   = 250
	MultipleDiskMinSizeGiB = 180
	HardMinDataDiskSizeGiB = 50
	MaxPods                = 200
)
View Source
const (
	ModeCreate  = "create"
	ModeJoin    = "join"
	ModeUpgrade = "upgrade"
	ModeInstall = "install"

	RoleDefault = "default"
	RoleWitness = "witness"
	RoleMgmt    = "management"
	RoleWorker  = "worker"

	NetworkMethodDHCP   = "dhcp"
	NetworkMethodStatic = "static"
	NetworkMethodNone   = "none"

	MgmtInterfaceName     = "mgmt-br"
	MgmtBondInterfaceName = "mgmt-bo"

	RancherdConfigFile = "/etc/rancher/rancherd/config.yaml"

	DefaultCosOemSizeMiB      = 50
	DefaultCosStateSizeMiB    = 15360
	DefaultCosRecoverySizeMiB = 8192

	DefaultPersistentPercentageNum = 0.3
	PersistentSizeMinGiB           = 150
)

Variables

View Source
var (
	// Following variables are replaced by ldflags
	RKE2Version            = ""
	RancherVersion         = ""
	HarvesterChartVersion  = ""
	MonitoringChartVersion = ""
	LoggingChartVersion    = ""
)

Functions

func ConvertToCOS added in v0.2.0

func ConvertToCOS(config *HarvesterConfig) (*yipSchema.YipConfig, error)

ConvertToCOS converts HarvesterConfig to cOS configuration.

func GenerateRancherdConfig added in v1.2.0

func GenerateRancherdConfig(config *HarvesterConfig) (*yipSchema.YipConfig, error)

func NewToBool added in v0.2.0

func NewToBool() mapper.Mapper

func NewToMap added in v0.2.0

func NewToMap() mapper.Mapper

func NewToSlice added in v0.2.0

func NewToSlice() mapper.Mapper

func NewTypeConverter added in v0.2.0

func NewTypeConverter(fieldType string, converter Converter) mapper.Mapper

func PrintInstall

func PrintInstall(cfg HarvesterConfig) ([]byte, error)

func RestoreOriginalNetworkConfig added in v0.2.3

func RestoreOriginalNetworkConfig() error

RestoreOriginalNetworkConfig restores the previous state of network configurations saved by `SaveOriginalNetworkConfig`.

func SaveOriginalNetworkConfig added in v0.2.3

func SaveOriginalNetworkConfig() error

SaveOriginalNetworkConfig saves the current state of network configurations. Namely - all `/etc/sysconfig/network/ifroute-*` files, and - all `/etc/sysconfig/network/ifcfg-*` files

It can only be invoked once for the whole lifetime of this program.

func ToEnv added in v0.2.0

func ToEnv(prefix string, obj interface{}) ([]string, error)

func UpdateManagementInterfaceConfig added in v1.1.0

func UpdateManagementInterfaceConfig(stage *yipSchema.Stage, mgmtInterface Network, run bool) (string, error)

UpdateManagementInterfaceConfig updates a cOS config stage to include steps that: - generates wicked interface files (`/etc/sysconfig/network/ifcfg-*` and `ifroute-*`) - manipulates nameservers in `/etc/resolv.conf`. - call `wicked ifreload all` if `run` flag is true.

func UpdateWifiConfig added in v0.2.0

func UpdateWifiConfig(stage *yipSchema.Stage, wifis []Wifi, run bool) error

Types

type Addon added in v1.2.0

type Addon struct {
	Enabled       bool   `json:"enabled,omitempty"`
	ValuesContent string `json:"valuesContent,omitempty"`
}

type Converter added in v0.2.0

type Converter func(val interface{}) interface{}

type ElementalConfig added in v1.1.2

type ElementalConfig struct {
	Install ElementalInstallSpec `yaml:"install,omitempty"`
}

refer: https://github.com/rancher/elemental-cli/blob/v0.1.0/config.yaml.example

func ConvertToElementalConfig added in v1.1.2

func ConvertToElementalConfig(config *HarvesterConfig) (*ElementalConfig, error)

func CreateRootPartitioningLayout added in v1.0.1

func CreateRootPartitioningLayout(elementalConfig *ElementalConfig, hvstConfig *HarvesterConfig) (*ElementalConfig, error)

func NewElementalConfig added in v1.1.2

func NewElementalConfig() *ElementalConfig

type ElementalDefaultPartition added in v1.1.2

type ElementalDefaultPartition struct {
	OEM        *ElementalPartition `yaml:"oem,omitempty"`
	State      *ElementalPartition `yaml:"state,omitempty"`
	Recovery   *ElementalPartition `yaml:"recovery,omitempty"`
	Persistent *ElementalPartition `yaml:"persistent,omitempty"`
}

type ElementalInstallSpec added in v1.1.2

type ElementalInstallSpec struct {
	Target          string                     `yaml:"target,omitempty"`
	Firmware        string                     `yaml:"firmware,omitempty"`
	PartTable       string                     `yaml:"part-table,omitempty"`
	Partitions      *ElementalDefaultPartition `yaml:"partitions,omitempty"`
	ExtraPartitions []ElementalPartition       `yaml:"extra-partitions,omitempty"`
	CloudInit       string                     `yaml:"cloud-init,omitempty"`
	Tty             string                     `yaml:"tty,omitempty"`
	System          *ElementalSystem           `yaml:"system,omitempty"`
}

type ElementalPartition added in v1.1.2

type ElementalPartition struct {
	FilesystemLabel string `yaml:"label,omitempty"`
	Size            uint   `yaml:"size,omitempty"`
	FS              string `yaml:"fs,omitempty"`
}

type ElementalSystem added in v1.2.0

type ElementalSystem struct {
	Label string `yaml:"label,omitempty"`
	Size  uint   `yaml:"size,omitempty"`
	FS    string `yaml:"fs,omitempty"`
	URI   string `yaml:"uri,omitempty"`
}

type File added in v0.2.0

type File struct {
	Encoding           string `json:"encoding"`
	Content            string `json:"content"`
	Owner              string `json:"owner"`
	Path               string `json:"path"`
	RawFilePermissions string `json:"permissions"`
}

type FuzzyNames added in v0.2.0

type FuzzyNames struct {
	mappers.DefaultMapper
	// contains filtered or unexported fields
}

func (*FuzzyNames) ModifySchema added in v0.2.0

func (f *FuzzyNames) ModifySchema(schema *mapper.Schema, schemas *mapper.Schemas) error

func (*FuzzyNames) ToInternal added in v0.2.0

func (f *FuzzyNames) ToInternal(data map[string]interface{}) error

type HTTPBasicAuth

type HTTPBasicAuth struct {
	User     string `json:"user,omitempty"`
	Password string `json:"password,omitempty"`
}

type HarvesterChartValues added in v1.1.3

type HarvesterChartValues struct {
	StorageClass     StorageClass        `json:"storageClass,omitempty"`
	Longhorn         LonghornChartValues `json:"longhorn,omitempty"`
	EnableGoCoverDir bool                `json:"enableGoCoverDir,omitempty"`
}

type HarvesterConfig

type HarvesterConfig struct {
	// Harvester will use scheme version to determine current version and migrate config to new scheme version
	SchemeVersion          uint32 `json:"schemeVersion,omitempty"`
	ServerURL              string `json:"serverUrl,omitempty"`
	Token                  string `json:"token,omitempty"`
	OS                     `json:"os,omitempty"`
	Install                `json:"install,omitempty"`
	RuntimeVersion         string            `json:"runtimeVersion,omitempty"`
	RancherVersion         string            `json:"rancherVersion,omitempty"`
	HarvesterChartVersion  string            `json:"harvesterChartVersion,omitempty"`
	MonitoringChartVersion string            `json:"monitoringChartVersion,omitempty"`
	SystemSettings         map[string]string `json:"systemSettings,omitempty"`
	LoggingChartVersion    string            `json:"loggingChartVersion,omitempty"`
}

func LoadHarvesterConfig

func LoadHarvesterConfig(yamlBytes []byte) (*HarvesterConfig, error)

func NewHarvesterConfig

func NewHarvesterConfig() *HarvesterConfig

func ReadConfig

func ReadConfig() (HarvesterConfig, error)

ReadConfig constructs a config by reading various sources

func ReadUserDataConfig added in v1.2.0

func ReadUserDataConfig() (HarvesterConfig, error)

ReadUserDataConfig constructs a config from userdata

func (*HarvesterConfig) DeepCopy added in v0.2.0

func (c *HarvesterConfig) DeepCopy() (*HarvesterConfig, error)

func (*HarvesterConfig) GetKubeletArgs added in v0.2.6

func (c *HarvesterConfig) GetKubeletArgs() ([]string, error)

func (*HarvesterConfig) Merge added in v1.0.1

func (c *HarvesterConfig) Merge(other HarvesterConfig) error

func (HarvesterConfig) ShouldCreateDataPartitionOnOsDisk added in v1.0.1

func (c HarvesterConfig) ShouldCreateDataPartitionOnOsDisk() bool

func (HarvesterConfig) ShouldMountDataPartition added in v1.0.1

func (c HarvesterConfig) ShouldMountDataPartition() bool

func (*HarvesterConfig) String

func (c *HarvesterConfig) String() string

func (*HarvesterConfig) ToCosInstallEnv added in v0.2.0

func (c *HarvesterConfig) ToCosInstallEnv() ([]string, error)

type Install

type Install struct {
	Automatic           bool    `json:"automatic,omitempty"`
	SkipChecks          bool    `json:"skipchecks,omitempty"`
	Mode                string  `json:"mode,omitempty"`
	ManagementInterface Network `json:"managementInterface,omitempty"`

	Vip       string `json:"vip,omitempty"`
	VipHwAddr string `json:"vipHwAddr,omitempty"`
	VipMode   string `json:"vipMode,omitempty"`

	ForceEFI      bool   `json:"forceEfi,omitempty"`
	Device        string `json:"device,omitempty"`
	ConfigURL     string `json:"configUrl,omitempty"`
	Silent        bool   `json:"silent,omitempty"`
	ISOURL        string `json:"isoUrl,omitempty"`
	PowerOff      bool   `json:"powerOff,omitempty"`
	NoFormat      bool   `json:"noFormat,omitempty"`
	Debug         bool   `json:"debug,omitempty"`
	TTY           string `json:"tty,omitempty"`
	ForceGPT      bool   `json:"forceGpt,omitempty"`
	Role          string `json:"role,omitempty"`
	WithNetImages bool   `json:"withNetImages,omitempty"`
	WipeDisks     bool   `json:"wipeDisks,omitempty"`

	// Following options are not cOS installer flag
	ForceMBR bool   `json:"forceMbr,omitempty"`
	DataDisk string `json:"dataDisk,omitempty"`

	Webhooks                []Webhook            `json:"webhooks,omitempty"`
	Addons                  map[string]Addon     `json:"addons,omitempty"`
	Harvester               HarvesterChartValues `json:"harvester,omitempty"`
	RawDiskImagePath        string               `json:"rawDiskImagePath,omitempty"`
	PersistentPartitionSize string               `json:"persistentPartitionSize,omitempty"`
}

type LHDefaultSettings added in v1.2.0

type LHDefaultSettings struct {
	// 0 is valid, means not setting CPU resources, use pointer to check if it is set
	GuaranteedEngineManagerCPU  *uint32 `json:"guaranteedEngineManagerCPU,omitempty"`
	GuaranteedReplicaManagerCPU *uint32 `json:"guaranteedReplicaManagerCPU,omitempty"`
}

type LonghornChartValues added in v1.2.0

type LonghornChartValues struct {
	DefaultSettings LHDefaultSettings `json:"defaultSettings,omitempty"`
}

type NTPSettings added in v1.2.0

type NTPSettings struct {
	NTPServers []string `json:"ntpServers,omitempty"`
}

type Network

type Network struct {
	Interfaces   []NetworkInterface `json:"interfaces,omitempty"`
	Method       string             `json:"method,omitempty"`
	IP           string             `json:"ip,omitempty"`
	SubnetMask   string             `json:"subnetMask,omitempty"`
	Gateway      string             `json:"gateway,omitempty"`
	DefaultRoute bool               `json:"-"`
	BondOptions  map[string]string  `json:"bondOptions,omitempty"`
	MTU          int                `json:"mtu,omitempty"`
	VlanID       int                `json:"vlanId,omitempty"`
}

type NetworkInterface added in v0.2.3

type NetworkInterface struct {
	Name   string `json:"name,omitempty"`
	HwAddr string `json:"hwAddr,omitempty"`
}

func (*NetworkInterface) FindNetworkInterfaceHwAddr added in v1.1.0

func (n *NetworkInterface) FindNetworkInterfaceHwAddr() error

FindNetworkInterfaceHwAddr uses device name to lookup hardware address

func (*NetworkInterface) FindNetworkInterfaceName added in v0.2.8

func (n *NetworkInterface) FindNetworkInterfaceName() error

FindNetworkInterfaceName uses MAC address to lookup interface name

func (*NetworkInterface) FindNetworkInterfaceNameAndHwAddr added in v1.1.0

func (n *NetworkInterface) FindNetworkInterfaceNameAndHwAddr() error

type OS

type OS struct {
	AfterInstallChrootCommands []string `json:"afterInstallChrootCommands,omitempty"`
	SSHAuthorizedKeys          []string `json:"sshAuthorizedKeys,omitempty"`
	WriteFiles                 []File   `json:"writeFiles,omitempty"`
	Hostname                   string   `json:"hostname,omitempty"`

	Modules        []string          `json:"modules,omitempty"`
	Sysctls        map[string]string `json:"sysctls,omitempty"`
	NTPServers     []string          `json:"ntpServers,omitempty"`
	DNSNameservers []string          `json:"dnsNameservers,omitempty"`
	Wifi           []Wifi            `json:"wifi,omitempty"`
	Password       string            `json:"password,omitempty"`
	Environment    map[string]string `json:"environment,omitempty"`
	Labels         map[string]string `json:"labels,omitempty"`
	SSHD           SSHDConfig        `json:"sshd,omitempty"`

	PersistentStatePaths []string `json:"persistentStatePaths,omitempty"`
}

type SSHDConfig added in v1.2.2

type SSHDConfig struct {
	SFTP bool `json:"sftp,omitempty"`
}

SSHDConfig is the SSHD configuration for the node

  • SFTP: the switch to enable/disable SFTP

type StorageClass added in v1.2.0

type StorageClass struct {
	// 0 is invalid, will be omitted
	ReplicaCount uint32 `json:"replicaCount,omitempty"`
}

type Webhook

type Webhook struct {
	Event     string              `json:"event,omitempty"`
	Method    string              `json:"method,omitempty"`
	Headers   map[string][]string `json:"headers,omitempty"`
	URL       string              `json:"url,omitempty"`
	Payload   string              `json:"payload,omitempty"`
	Insecure  bool                `json:"insecure,omitempty"`
	BasicAuth HTTPBasicAuth       `json:"basicAuth,omitempty"`
}

type Wifi

type Wifi struct {
	Name       string `json:"name,omitempty"`
	Passphrase string `json:"passphrase,omitempty"`
}

Jump to

Keyboard shortcuts

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