2022-08-10 16:55:20 +00:00
|
|
|
package config
|
|
|
|
|
2022-12-09 15:00:28 +00:00
|
|
|
type P2P struct {
|
2022-08-10 16:55:20 +00:00
|
|
|
NetworkToken string `yaml:"network_token,omitempty"`
|
|
|
|
NetworkID string `yaml:"network_id,omitempty"`
|
|
|
|
Role string `yaml:"role,omitempty"`
|
|
|
|
DNS bool `yaml:"dns,omitempty"`
|
|
|
|
LogLevel string `yaml:"loglevel,omitempty"`
|
2022-12-09 15:00:28 +00:00
|
|
|
VPN VPN `yaml:"vpn,omitempty"`
|
|
|
|
|
2022-12-12 14:38:21 +00:00
|
|
|
MinimumNodes int `yaml:"minimum_nodes,omitempty"`
|
|
|
|
DisableDHT bool `yaml:"disable_dht,omitempty"`
|
|
|
|
Auto Auto `yaml:"auto,omitempty"`
|
2022-12-12 10:49:15 +00:00
|
|
|
|
|
|
|
DynamicRoles bool `yaml:"dynamic_roles,omitempty"`
|
2022-12-09 15:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type VPN struct {
|
|
|
|
Create *bool `yaml:"create,omitempty"`
|
|
|
|
Use *bool `yaml:"use,omitempty"`
|
|
|
|
Env map[string]string `yaml:"env,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// If no setting is provided by the user,
|
|
|
|
// we assume that we are going to create and use the VPN
|
|
|
|
// for the network layer of our cluster.
|
|
|
|
func (p P2P) UseVPNWithKubernetes() bool {
|
|
|
|
return p.VPNNeedsCreation() && (p.VPN.Use == nil || *p.VPN.Use)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p P2P) VPNNeedsCreation() bool {
|
|
|
|
return p.VPN.Create == nil || *p.VPN.Create
|
2022-08-10 16:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Config struct {
|
2022-12-09 15:00:28 +00:00
|
|
|
P2P *P2P `yaml:"p2p,omitempty"`
|
|
|
|
K3sAgent K3s `yaml:"k3s-agent,omitempty"`
|
|
|
|
K3s K3s `yaml:"k3s,omitempty"`
|
|
|
|
KubeVIP KubeVIP `yaml:"kubevip,omitempty"`
|
2022-12-01 17:14:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type KubeVIP struct {
|
|
|
|
Args []string `yaml:"args,omitempty"`
|
|
|
|
EIP string `yaml:"eip,omitempty"`
|
|
|
|
ManifestURL string `yaml:"manifest_url,omitempty"`
|
|
|
|
Interface string `yaml:"interface,omitempty"`
|
2022-12-12 14:38:21 +00:00
|
|
|
Enable *bool `yaml:"enable,omitempty"`
|
2022-12-09 15:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (k KubeVIP) IsEnabled() bool {
|
2022-12-13 16:58:49 +00:00
|
|
|
return (k.Enable == nil && k.EIP != "") || (k.Enable != nil && *k.Enable)
|
2022-08-10 16:55:20 +00:00
|
|
|
}
|
|
|
|
|
2022-12-12 14:38:21 +00:00
|
|
|
type Auto struct {
|
|
|
|
Enable *bool `yaml:"enable,omitempty"`
|
|
|
|
HA HA `yaml:"ha,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a Auto) IsEnabled() bool {
|
|
|
|
return a.Enable == nil || (a.Enable != nil && *a.Enable)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ha HA) IsEnabled() bool {
|
|
|
|
return (ha.Enable != nil && *ha.Enable) || (ha.Enable == nil && ha.MasterNodes != nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
type HA struct {
|
|
|
|
Enable *bool `yaml:"enable,omitempty"`
|
2022-12-06 16:27:29 +00:00
|
|
|
ExternalDB string `yaml:"external_db,omitempty"`
|
2022-12-12 14:38:21 +00:00
|
|
|
MasterNodes *int `yaml:"master_nodes,omitempty"`
|
2022-12-06 16:27:29 +00:00
|
|
|
}
|
|
|
|
|
2022-08-10 16:55:20 +00:00
|
|
|
type K3s struct {
|
|
|
|
Env map[string]string `yaml:"env,omitempty"`
|
|
|
|
ReplaceEnv bool `yaml:"replace_env,omitempty"`
|
|
|
|
ReplaceArgs bool `yaml:"replace_args,omitempty"`
|
|
|
|
Args []string `yaml:"args,omitempty"`
|
|
|
|
Enabled bool `yaml:"enabled,omitempty"`
|
|
|
|
}
|