Skip to content

Commit

Permalink
chore(leader-election): make leader election optional
Browse files Browse the repository at this point in the history
Signed-off-by: Clément Nussbaumer <[email protected]>
  • Loading branch information
clementnuss committed May 31, 2023
1 parent 161a3e0 commit 9a047cb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func CreateControllerManager(config *controller.Config, logger logr.Logger) (
mgrOptions := ctrl.Options{
MetricsBindAddress: config.MetricsAddr,
HealthProbeBindAddress: config.ProbeAddr,
LeaderElection: true,
LeaderElection: config.LeaderElection,
LeaderElectionID: "kubelet-csr-approver",
}

Expand Down Expand Up @@ -152,6 +152,7 @@ func prepareCmdlineConfig() *controller.Config {
logLevel = fs.Int("level", 0, "level ranges from -5 (Fatal) to 10 (Verbose)")
metricsAddr = fs.String("metrics-bind-address", ":8080", "address the metric endpoint binds to.")
probeAddr = fs.String("health-probe-bind-address", ":8081", "address the probe endpoint binds to.")
leaderElection = fs.Bool("leader-election", false, "set this parameter to true to enable leader election")
regexStr = fs.String("provider-regex", ".*", "provider-specified regex to validate CSR SAN names against. accepts everything unless specified")
maxSec = fs.Int("max-expiration-sec", 367*24*3600, "maximum seconds a CSR can request a cerficate for. defaults to 367 days")
bypassDNSResolution = fs.Bool("bypass-dns-resolution", false, "set this parameter to true to bypass DNS resolution checks")
Expand Down Expand Up @@ -186,6 +187,7 @@ func prepareCmdlineConfig() *controller.Config {
LogLevel: *logLevel,
MetricsAddr: *metricsAddr,
ProbeAddr: *probeAddr,
LeaderElection: *leaderElection,
RegexStr: *regexStr,
IPPrefixesStr: *ipPrefixesStr,
BypassDNSResolution: *bypassDNSResolution,
Expand Down
1 change: 1 addition & 0 deletions internal/controller/csr_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Config struct {
LogLevel int
MetricsAddr string
ProbeAddr string
LeaderElection bool
RegexStr string
ProviderRegexp func(string) bool
IPPrefixesStr string
Expand Down
1 change: 1 addition & 0 deletions internal/controller/testenv_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ func packageSetup() {
}

testingConfig := controller.Config{
LeaderElection: true,
RegexStr: `^[\w-]*\.test\.ch$`,
MaxExpirationSeconds: 367 * 24 * 3600,
AllowedDNSNames: 3,
Expand Down

0 comments on commit 9a047cb

Please sign in to comment.