Skip to content

Commit

Permalink
Merge pull request #4291 from twz123/keepalied-debug
Browse files Browse the repository at this point in the history
Enable console logging for keepalived
  • Loading branch information
twz123 authored Apr 12, 2024
2 parents 66b144c + 856126b commit fc8a8fe
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
5 changes: 3 additions & 2 deletions cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down
29 changes: 19 additions & 10 deletions pkg/component/controller/cplb_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions pkg/component/controller/cplb_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit fc8a8fe

Please sign in to comment.