@@ -18,27 +18,29 @@ import (
18
18
)
19
19
20
20
const (
21
- flagMetricsBindAddr = "metrics-bind-addr"
22
- flagHealthProbeBindAddr = "health-probe-bind-addr"
23
- flagWebhookBindPort = "webhook-bind-port"
24
- flagEnableLeaderElection = "enable-leader-election"
25
- flagLeaderElectionID = "leader-election-id"
26
- flagLeaderElectionNamespace = "leader-election-namespace"
27
- flagWatchNamespace = "watch-namespace"
28
- flagSyncPeriod = "sync-period"
29
- flagKubeconfig = "kubeconfig"
30
- flagWebhookCertDir = "webhook-cert-dir"
31
- flagWebhookCertName = "webhook-cert-file"
32
- flagWebhookKeyName = "webhook-key-file"
21
+ flagMetricsBindAddr = "metrics-bind-addr"
22
+ flagHealthProbeBindAddr = "health-probe-bind-addr"
23
+ flagWebhookBindPort = "webhook-bind-port"
24
+ flagEnableLeaderElection = "enable-leader-election"
25
+ flagLeaderElectionID = "leader-election-id"
26
+ flagLeaderElectionNamespace = "leader-election-namespace"
27
+ flagLeaderElectionLeaseDuration = "leader-election-lease-duration"
28
+ flagWatchNamespace = "watch-namespace"
29
+ flagSyncPeriod = "sync-period"
30
+ flagKubeconfig = "kubeconfig"
31
+ flagWebhookCertDir = "webhook-cert-dir"
32
+ flagWebhookCertName = "webhook-cert-file"
33
+ flagWebhookKeyName = "webhook-key-file"
33
34
34
- defaultKubeconfig = ""
35
- defaultLeaderElectionID = "aws-load-balancer-controller-leader"
36
- defaultLeaderElectionNamespace = ""
37
- defaultWatchNamespace = corev1 .NamespaceAll
38
- defaultMetricsAddr = ":8080"
39
- defaultHealthProbeBindAddress = ":61779"
40
- defaultSyncPeriod = 10 * time .Hour
41
- defaultWebhookBindPort = 9443
35
+ defaultKubeconfig = ""
36
+ defaultLeaderElectionID = "aws-load-balancer-controller-leader"
37
+ defaultLeaderElectionNamespace = ""
38
+ defaultLeaderElectionLeaseDuration = 15 * time .Second
39
+ defaultWatchNamespace = corev1 .NamespaceAll
40
+ defaultMetricsAddr = ":8080"
41
+ defaultHealthProbeBindAddress = ":61779"
42
+ defaultSyncPeriod = 10 * time .Hour
43
+ defaultWebhookBindPort = 9443
42
44
// High enough QPS to fit all expected use cases. QPS=0 is not set here, because
43
45
// client code is overriding it.
44
46
defaultQPS = 1e6
@@ -52,19 +54,20 @@ const (
52
54
53
55
// RuntimeConfig stores the configuration for the controller-runtime
54
56
type RuntimeConfig struct {
55
- APIServer string
56
- KubeConfig string
57
- WebhookBindPort int
58
- MetricsBindAddress string
59
- HealthProbeBindAddress string
60
- EnableLeaderElection bool
61
- LeaderElectionID string
62
- LeaderElectionNamespace string
63
- WatchNamespace string
64
- SyncPeriod time.Duration
65
- WebhookCertDir string
66
- WebhookCertName string
67
- WebhookKeyName string
57
+ APIServer string
58
+ KubeConfig string
59
+ WebhookBindPort int
60
+ MetricsBindAddress string
61
+ HealthProbeBindAddress string
62
+ EnableLeaderElection bool
63
+ LeaderElectionID string
64
+ LeaderElectionNamespace string
65
+ LeaderElectionLeaseDuration time.Duration
66
+ WatchNamespace string
67
+ SyncPeriod time.Duration
68
+ WebhookCertDir string
69
+ WebhookCertName string
70
+ WebhookKeyName string
68
71
}
69
72
70
73
// BindFlags binds the command line flags to the fields in the config object
@@ -91,7 +94,8 @@ func (c *RuntimeConfig) BindFlags(fs *pflag.FlagSet) {
91
94
fs .StringVar (& c .WebhookCertDir , flagWebhookCertDir , defaultWebhookCertDir , "WebhookCertDir is the directory that contains the webhook server key and certificate." )
92
95
fs .StringVar (& c .WebhookCertName , flagWebhookCertName , defaultWebhookCertName , "WebhookCertName is the webhook server certificate name." )
93
96
fs .StringVar (& c .WebhookKeyName , flagWebhookKeyName , defaultWebhookKeyName , "WebhookKeyName is the webhook server key name." )
94
-
97
+ fs .DurationVar (& c .LeaderElectionLeaseDuration , flagLeaderElectionLeaseDuration , defaultLeaderElectionLeaseDuration ,
98
+ "The duration that non-leader candidates will wait to force acquire leadership." )
95
99
}
96
100
97
101
// BuildRestConfig builds the REST config for the controller runtime
@@ -122,6 +126,7 @@ func BuildRuntimeOptions(rtCfg RuntimeConfig, scheme *runtime.Scheme) ctrl.Optio
122
126
LeaderElectionResourceLock : resourcelock .LeasesResourceLock ,
123
127
LeaderElectionID : rtCfg .LeaderElectionID ,
124
128
LeaderElectionNamespace : rtCfg .LeaderElectionNamespace ,
129
+ LeaseDuration : & rtCfg .LeaderElectionLeaseDuration ,
125
130
Cache : cache.Options {
126
131
SyncPeriod : & rtCfg .SyncPeriod ,
127
132
},
0 commit comments