Skip to content

Commit

Permalink
Fix passing arguments to k3s agent and k0s worker
Browse files Browse the repository at this point in the history
Signed-off-by: Mauro Morales <contact@mauromorales.com>
  • Loading branch information
mauromorales committed Jan 27, 2025
1 parent 2ec8886 commit 30825ff
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions internal/provider/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func oneTimeBootstrap(l types.KairosLogger, c *providerConfig.Config, vpnSetupFN
l.Info("One time bootstrap starting")

var svc machine.Service
var svcName, svcRole, envFile, binPath string
var svcName, svcRole, envFile, binPath, args string
var svcEnv map[string]string

if !c.IsAKubernetesDistributionEnabled() {
Expand All @@ -177,24 +177,28 @@ func oneTimeBootstrap(l types.KairosLogger, c *providerConfig.Config, vpnSetupFN
svcName = "k3s-agent"
svcRole = "agent"
svcEnv = c.K3sAgent.Env
args = strings.Join(c.K3sAgent.Args, " ")
}

if c.IsK3sEnabled() {
svcName = "k3s"
svcRole = "server"
svcEnv = c.K3s.Env
args = strings.Join(c.K3s.Args, " ")
}

if c.IsK0sEnabled() {
svcName = "k0scontroller"
svcRole = "controller"
svcEnv = c.K0s.Env
args = strings.Join(c.K0s.Args, " ")
}

if c.IsK0sWorkerEnabled() {
svcName = "k0sworker"
svcRole = "worker"
svcEnv = c.K0sWorker.Env
args = strings.Join(c.K0sWorker.Args, " ")
}

if c.IsK3sDistributionEnabled() {
Expand Down Expand Up @@ -232,14 +236,6 @@ func oneTimeBootstrap(l types.KairosLogger, c *providerConfig.Config, vpnSetupFN
return fmt.Errorf("could not detect OS")
}

// Args can come from k3s or k0s
var args string
if c.IsK3sDistributionEnabled() {
args = strings.Join(c.K3s.Args, " ")
} else if c.IsK0sDistributionEnabled() {
args = strings.Join(c.K0s.Args, " ")
}

// Override the service command and start it
if err := svc.OverrideCmd(fmt.Sprintf("%s %s %s", binPath, svcRole, args)); err != nil {
l.Errorf("Failed to override service command: %s", err.Error())
Expand Down

0 comments on commit 30825ff

Please sign in to comment.