@@ -19,6 +19,7 @@ package main
19
19
import (
20
20
"flag"
21
21
"os"
22
+ "time"
22
23
23
24
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
24
25
// to ensure that exec-entrypoint and run can make use of them.
@@ -66,14 +67,34 @@ func main() {
66
67
var logEncoder string
67
68
var logLevel int
68
69
69
- flag .StringVar (& logEncoder , "logEncoder" , "json" , "log encoding ('json' or 'console')" )
70
+ var leaseDuration time.Duration
71
+ var renewDeadline time.Duration
72
+ var leaseDurationSecond int
73
+ var renewDeadlineSecond int
74
+
75
+ flag .StringVar (& logEncoder , "log-encoder" , "json" , "log encoding ('json' or 'console')" )
70
76
flag .StringVar (& metricsAddr , "metrics-bind-address" , ":8080" , "The address the metric endpoint binds to." )
71
77
flag .StringVar (& probeAddr , "health-probe-bind-address" , ":8081" , "The address the probe endpoint binds to." )
72
78
flag .BoolVar (& enableLeaderElection , "leader-elect" , false ,
73
79
"Enable leader election for controller manager. " +
74
80
"Enabling this will ensure there is only one active controller manager." )
75
81
flag .BoolVar (& pprofActive , "pprof" , true , "Enable pprof endpoint" )
76
- flag .IntVar (& logLevel , "loglevel" , int (zapcore .InfoLevel ), "set log level" )
82
+ flag .IntVar (& logLevel , "log-level" , int (zapcore .InfoLevel ), "set log level" )
83
+ flag .IntVar (& leaseDurationSecond , "lease-duration" , int (leaseDurationSecond ), "manager lease duration in seconds" )
84
+ flag .IntVar (& renewDeadlineSecond , "renew-duration" , int (renewDeadlineSecond ), "manager renew duration in seconds" )
85
+
86
+ // see https://github.com/operator-framework/operator-sdk/issues/1813
87
+ if leaseDurationSecond < 30 {
88
+ leaseDuration = 30 * time .Second
89
+ } else {
90
+ leaseDuration = time .Duration (leaseDurationSecond ) * time .Second
91
+ }
92
+
93
+ if renewDeadlineSecond < 20 {
94
+ renewDeadline = 20 * time .Second
95
+ } else {
96
+ renewDeadline = time .Duration (renewDeadlineSecond ) * time .Second
97
+ }
77
98
78
99
opts := zap.Options {
79
100
Development : true ,
@@ -92,6 +113,8 @@ func main() {
92
113
HealthProbeBindAddress : probeAddr ,
93
114
LeaderElection : enableLeaderElection ,
94
115
LeaderElectionID : "270bec8c.splunk.com" ,
116
+ LeaseDuration : & leaseDuration ,
117
+ RenewDeadline : & renewDeadline ,
95
118
}
96
119
97
120
mgr , err := ctrl .NewManager (ctrl .GetConfigOrDie (), config .ManagerOptionsWithNamespaces (setupLog , options ))
0 commit comments