diff --git a/cmd/controller/controller.go b/cmd/controller/controller.go index f5491d006c2c..7d61df2ae888 100644 --- a/cmd/controller/controller.go +++ b/cmd/controller/controller.go @@ -231,8 +231,9 @@ func (c *command) start(ctx context.Context) error { enableCPLB := !c.SingleNode && !slices.Contains(c.DisableComponents, constant.CPLBComponentName) if enableCPLB { nodeComponents.Add(ctx, &controller.Keepalived{ - K0sVars: c.K0sVars, - Config: nodeConfig.Spec.Network.ControlPlaneLoadBalancing, + K0sVars: c.K0sVars, + Config: nodeConfig.Spec.Network.ControlPlaneLoadBalancing, + DetailedLogging: c.Debug, }) } diff --git a/pkg/component/controller/cplb_unix.go b/pkg/component/controller/cplb_unix.go index b2a1fc0be041..42e30dd344d2 100644 --- a/pkg/component/controller/cplb_unix.go +++ b/pkg/component/controller/cplb_unix.go @@ -42,11 +42,12 @@ import ( // Keepalived is the controller for the keepalived process in the control plane load balancing type Keepalived struct { - K0sVars *config.CfgVars - Config *k0sAPI.ControlPlaneLoadBalancingSpec - uid int - supervisor *supervisor.Supervisor - log *logrus.Entry + K0sVars *config.CfgVars + Config *k0sAPI.ControlPlaneLoadBalancingSpec + DetailedLogging bool + uid int + supervisor *supervisor.Supervisor + log *logrus.Entry } // Init extracts the needed binaries and creates the directories @@ -92,15 +93,23 @@ func (k *Keepalived) Start(_ context.Context) error { } + args := []string{ + "--dont-fork", + "--use-file", + k.K0sVars.KeepalivedConfigFile, + "--no-syslog", + "--log-console", + } + + if k.DetailedLogging { + args = append(args, "--log-detail") + } + k.log.Infoln("Starting keepalived") k.supervisor = &supervisor.Supervisor{ Name: "keepalived", BinPath: assets.BinPath("keepalived", k.K0sVars.BinDir), - Args: []string{ - "--dont-fork", - "--use-file", - k.K0sVars.KeepalivedConfigFile, - }, + Args: args, RunDir: filepath.Dir(k.K0sVars.KeepalivedConfigFile), DataDir: filepath.Dir(k.K0sVars.KeepalivedConfigFile), UID: k.uid, diff --git a/pkg/component/controller/cplb_windows.go b/pkg/component/controller/cplb_windows.go index a069376ec245..c6eeef5889fe 100644 --- a/pkg/component/controller/cplb_windows.go +++ b/pkg/component/controller/cplb_windows.go @@ -27,8 +27,9 @@ import ( // Keepalived doesn't work on windows, so we cannot implement it at all. // Just create the interface so that the CI doesn't complain. type Keepalived struct { - K0sVars *config.CfgVars - Config *k0sAPI.ControlPlaneLoadBalancingSpec + K0sVars *config.CfgVars + Config *k0sAPI.ControlPlaneLoadBalancingSpec + DetailedLogging bool } func (k *Keepalived) Init(_ context.Context) error {