@@ -51,16 +51,24 @@ func init() {
51
51
func main () {
52
52
53
53
var (
54
- enableLeaderElection bool
55
- healthAddr string
56
- metricsAddr string
57
- webhookPort int
54
+ enableLeaderElection bool
55
+ leaderElectionNamespace string
56
+ healthAddr string
57
+ metricsAddr string
58
+ webhookPort int
58
59
)
59
60
60
61
flag .BoolVar (& enableLeaderElection , "enable-leader-election" , false ,
61
62
"Enable leader election for controller manager. " +
62
63
"Enabling this will ensure there is only one active controller manager." )
63
64
65
+ flag .StringVar (
66
+ & leaderElectionNamespace ,
67
+ "leader-election-namespace" ,
68
+ "" ,
69
+ "Namespace that the controller performs leader election in. If unspecified, the controller will discover which namespace it is running in." ,
70
+ )
71
+
64
72
flag .StringVar (& healthAddr ,
65
73
"health-addr" ,
66
74
":9440" ,
@@ -86,13 +94,14 @@ func main() {
86
94
})
87
95
88
96
mgr , err := ctrl .NewManager (ctrl .GetConfigOrDie (), ctrl.Options {
89
- Scheme : scheme ,
90
- MetricsBindAddress : metricsAddr ,
91
- Port : webhookPort ,
92
- EventBroadcaster : broadcaster ,
93
- LeaderElection : enableLeaderElection ,
94
- LeaderElectionID : "cad3ba79.cluster.x-k8s.io" ,
95
- HealthProbeBindAddress : healthAddr ,
97
+ Scheme : scheme ,
98
+ MetricsBindAddress : metricsAddr ,
99
+ Port : webhookPort ,
100
+ EventBroadcaster : broadcaster ,
101
+ LeaderElection : enableLeaderElection ,
102
+ LeaderElectionID : "controller-leader-election-capp" ,
103
+ LeaderElectionNamespace : leaderElectionNamespace ,
104
+ HealthProbeBindAddress : healthAddr ,
96
105
})
97
106
if err != nil {
98
107
setupLog .Error (err , "unable to start manager" )
0 commit comments