Add disable leader election flag (#109)

Signed-off-by: Jian Qiu <jqiu@redhat.com>
This commit is contained in:
Jian Qiu
2022-01-18 11:16:05 +08:00
committed by GitHub
parent 5d86a958cb
commit 4334762add
2 changed files with 9 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ spec:
- "agent"
- "--spoke-cluster-name=cluster1"
- "--hub-kubeconfig=/spoke/hub-kubeconfig/kubeconfig"
- "--disable-leader-election"
securityContext:
allowPrivilegeEscalation: false
capabilities:

View File

@@ -12,12 +12,17 @@ import (
// NewWorkloadAgent generates a command to start workload agent
func NewWorkloadAgent() *cobra.Command {
o := spoke.NewWorkloadAgentOptions()
cmd := controllercmd.
NewControllerCommandConfig("work-agent", version.Get(), o.RunWorkloadAgent).
NewCommand()
cmdConfig := controllercmd.
NewControllerCommandConfig("work-agent", version.Get(), o.RunWorkloadAgent)
cmd := cmdConfig.NewCommand()
cmd.Use = "agent"
cmd.Short = "Start the Cluster Registration Agent"
o.AddFlags(cmd)
// add disable leader election flag
flags := cmd.Flags()
flags.BoolVar(&cmdConfig.DisableLeaderElection, "disable-leader-election", false, "Disable leader election for the agent.")
return cmd
}