provider-kairos/internal/provider/config/config.go
tyzbit 40e8666450
feat(kubevip): static pod support (#520)
Closes https://github.com/kairos-io/kairos/issues/1993

To use:

```
kubevip:
  static_pod: true
```

I'm still getting my build environment set up so unfortunately I can't
test this functionality myself but the change should be straightforward.
Please review with this in mind, I definitely could have missed
something.

Signed-off-by: Tyler Hawkins <3319104+tyzbit@users.noreply.github.com>
2024-01-24 09:35:24 +01:00

81 lines
2.4 KiB
Go

package config
type P2P struct {
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"`
VPN VPN `yaml:"vpn,omitempty"`
MinimumNodes int `yaml:"minimum_nodes,omitempty"`
DisableDHT bool `yaml:"disable_dht,omitempty"`
Auto Auto `yaml:"auto,omitempty"`
DynamicRoles bool `yaml:"dynamic_roles,omitempty"`
}
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
}
type Config struct {
P2P *P2P `yaml:"p2p,omitempty"`
K3sAgent K3s `yaml:"k3s-agent,omitempty"`
K3s K3s `yaml:"k3s,omitempty"`
KubeVIP KubeVIP `yaml:"kubevip,omitempty"`
}
type KubeVIP struct {
Args []string `yaml:"args,omitempty"`
EIP string `yaml:"eip,omitempty"`
ManifestURL string `yaml:"manifest_url,omitempty"`
Interface string `yaml:"interface,omitempty"`
Enable *bool `yaml:"enable,omitempty"`
StaticPod bool `yaml:"static_pod,omitempty"`
}
func (k KubeVIP) IsEnabled() bool {
return (k.Enable == nil && k.EIP != "") || (k.Enable != nil && *k.Enable)
}
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"`
ExternalDB string `yaml:"external_db,omitempty"`
MasterNodes *int `yaml:"master_nodes,omitempty"`
}
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"`
}