mirror of
https://github.com/kairos-io/provider-kairos.git
synced 2025-09-12 21:30:17 +00:00
commit before using cursor
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
This commit is contained in:
1
.go-version
Normal file
1
.go-version
Normal file
@@ -0,0 +1 @@
|
||||
1.23.6
|
@@ -49,8 +49,8 @@ func Bootstrap(e *pluggable.Event) pluggable.EventResponse {
|
||||
tokenNotDefined := (p2pBlockDefined && prvConfig.P2P.NetworkToken == "") || !p2pBlockDefined
|
||||
skipAuto := p2pBlockDefined && !prvConfig.P2P.Auto.IsEnabled()
|
||||
|
||||
worker, _ := p2p.NewK8sWorker(prvConfig)
|
||||
if prvConfig.P2P == nil && worker == nil {
|
||||
sd, _ := p2p.NewServiceDefinition(prvConfig)
|
||||
if prvConfig.P2P == nil && sd == nil {
|
||||
return pluggable.EventResponse{State: fmt.Sprintf("no kubernetes distribution configuration. nothing to do: %s", cfg.Config)}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func Bootstrap(e *pluggable.Event) pluggable.EventResponse {
|
||||
// Do onetimebootstrap if a Kubernetes distribution is enabled.
|
||||
// Those blocks are not required to be enabled in case of a kairos
|
||||
// full automated setup. Otherwise, they must be explicitly enabled.
|
||||
if (tokenNotDefined && worker != nil) || skipAuto {
|
||||
if (tokenNotDefined && sd != nil) || skipAuto {
|
||||
err := oneTimeBootstrap(logger, prvConfig, func() error {
|
||||
return SetupVPN(services.EdgeVPNDefaultInstance, cfg.APIAddress, "/", true, prvConfig)
|
||||
})
|
||||
@@ -134,6 +134,18 @@ func Bootstrap(e *pluggable.Event) pluggable.EventResponse {
|
||||
Role: common.RoleAuto,
|
||||
RoleHandler: role.Auto(c, prvConfig),
|
||||
},
|
||||
service.RoleKey{
|
||||
Role: common.RoleControlPlane,
|
||||
RoleHandler: p2p.ControlPlane(c, prvConfig, common.RoleControlPlane),
|
||||
},
|
||||
service.RoleKey{
|
||||
Role: common.RoleMasterInit,
|
||||
RoleHandler: p2p.ControlPlane(c, prvConfig, common.RoleControlPlaneClusterInit),
|
||||
},
|
||||
service.RoleKey{
|
||||
Role: common.RoleMasterHA,
|
||||
RoleHandler: p2p.ControlPlane(c, prvConfig, common.RoleControlPlaneHA),
|
||||
},
|
||||
),
|
||||
}
|
||||
|
||||
|
@@ -8,10 +8,14 @@ import (
|
||||
|
||||
const (
|
||||
RoleWorker = "worker"
|
||||
RoleControlPlane = "master"
|
||||
RoleControlPlaneHA = "master/ha"
|
||||
RoleControlPlaneClusterInit = "master/clusterinit"
|
||||
RoleControlPlane = "control-plane"
|
||||
RoleControlPlaneHA = "control-plane/ha"
|
||||
RoleControlPlaneClusterInit = "control-plane/clusterinit"
|
||||
RoleAuto = "auto"
|
||||
// these are kept for backwards compatibility with old configs
|
||||
RoleMaster = "master"
|
||||
RoleMasterHA = "master/ha"
|
||||
RoleMasterInit = "master/clusterinit"
|
||||
)
|
||||
|
||||
type Role func(*service.RoleConfig) error
|
||||
|
@@ -52,6 +52,10 @@ func (k *K0sControlPlane) DeployKubeVIP() error {
|
||||
func (k *K0sControlPlane) Args() ([]string, error) {
|
||||
var args []string
|
||||
|
||||
// if k.IsSingleNode() {
|
||||
// args = append(args, "--single")
|
||||
// }
|
||||
|
||||
// Generate a new k0s config
|
||||
_, err := utils.SH("k0s config create > /etc/k0s/k0s.yaml")
|
||||
if err != nil {
|
||||
@@ -213,6 +217,10 @@ func (k *K0sWorker) RoleConfig() *service.RoleConfig {
|
||||
return k.roleConfig
|
||||
}
|
||||
|
||||
func (k *K0sControlPlane) IsSingleNode() bool {
|
||||
return k.role == common.RoleControlPlane
|
||||
}
|
||||
|
||||
func (k *K0sControlPlane) HA() bool {
|
||||
return k.role == common.RoleControlPlaneHA
|
||||
}
|
||||
@@ -364,10 +372,6 @@ func (k *K0sControlPlane) GuessInterface() {
|
||||
// not used in k0s
|
||||
}
|
||||
|
||||
func (k *K0sWorker) GuessInterface() {
|
||||
// not used in k0s
|
||||
}
|
||||
|
||||
func (k *K0sControlPlane) Distro() string {
|
||||
return K0sDistroName
|
||||
}
|
||||
|
@@ -357,14 +357,6 @@ func (k *K3sControlPlane) GuessInterface() {
|
||||
k.ifaceIP = ifaceIP
|
||||
}
|
||||
|
||||
func (k *K3sWorker) GuessInterface() {
|
||||
iface := guessInterface(k.ProviderConfig())
|
||||
ifaceIP := utils.GetInterfaceIP(iface)
|
||||
|
||||
k.iface = iface
|
||||
k.ifaceIP = ifaceIP
|
||||
}
|
||||
|
||||
func (k *K3sControlPlane) Distro() string {
|
||||
return K3sDistroName
|
||||
}
|
||||
|
@@ -67,6 +67,11 @@ func NewServiceDefinition(c *providerConfig.Config) (ServiceDefinition, error) {
|
||||
return &K3sWorker{providerConfig: c}, nil
|
||||
case c.K0sWorker.Enabled:
|
||||
return &K0sWorker{providerConfig: c}, nil
|
||||
// we don't know if it's a control plane or a worker
|
||||
case utils.K3sBin() != "":
|
||||
return &K3sControlPlane{providerConfig: c}, nil
|
||||
case utils.K0sBin() != "":
|
||||
return &K0sControlPlane{providerConfig: c}, nil
|
||||
}
|
||||
|
||||
return nil, errors.New("no k8s distro found")
|
||||
@@ -75,9 +80,9 @@ func NewServiceDefinition(c *providerConfig.Config) (ServiceDefinition, error) {
|
||||
func NewK8sControlPlane(c *providerConfig.Config) (K8sControlPlane, error) {
|
||||
switch {
|
||||
case c.K3s.Enabled:
|
||||
return &K3sControlPlane{providerConfig: c, role: "control-plane"}, nil
|
||||
return &K3sControlPlane{providerConfig: c}, nil
|
||||
case c.K0s.Enabled:
|
||||
return &K0sControlPlane{providerConfig: c, role: "control-plane"}, nil
|
||||
return &K0sControlPlane{providerConfig: c}, nil
|
||||
case utils.K3sBin() != "":
|
||||
return &K3sControlPlane{providerConfig: c}, nil
|
||||
case utils.K0sBin() != "":
|
||||
@@ -90,9 +95,9 @@ func NewK8sControlPlane(c *providerConfig.Config) (K8sControlPlane, error) {
|
||||
func NewK8sWorker(c *providerConfig.Config) (K8sWorker, error) {
|
||||
switch {
|
||||
case c.K3sAgent.Enabled:
|
||||
return &K3sWorker{providerConfig: c, role: "worker"}, nil
|
||||
return &K3sWorker{providerConfig: c}, nil
|
||||
case c.K0sWorker.Enabled:
|
||||
return &K0sWorker{providerConfig: c, role: "worker"}, nil
|
||||
return &K0sWorker{providerConfig: c}, nil
|
||||
case utils.K3sBin() != "":
|
||||
return &K3sWorker{providerConfig: c}, nil
|
||||
case utils.K0sBin() != "":
|
||||
|
@@ -33,10 +33,10 @@ func scheduleRoles(nodes []string, c *service.RoleConfig, cc *config.Config, pco
|
||||
|
||||
hasControlPlane := false
|
||||
|
||||
controlPlaneRole := "master"
|
||||
controlPlaneRole := RoleControlPlane
|
||||
|
||||
if pconfig.P2P.Auto.HA.IsEnabled() {
|
||||
controlPlaneRole = "master/clusterinit"
|
||||
controlPlaneRole = RoleControlPlaneClusterInit
|
||||
}
|
||||
controlPlaneCounter := 1 // Start at 1 to account for the init node
|
||||
|
||||
@@ -79,7 +79,7 @@ func scheduleRoles(nodes []string, c *service.RoleConfig, cc *config.Config, pco
|
||||
c.Logger.Infof("-> Set %s to %s", controlPlaneRole, selected)
|
||||
currentRoles[selected] = controlPlaneRole
|
||||
// Return here, so next time we get called
|
||||
// makes sure master is set.
|
||||
// makes sure control-plane is set.
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user