@@ -20,7 +20,9 @@ import (
20
20
"flag"
21
21
etcd "github.com/UffizziCloud/uffizzi-cluster-operator/controllers/etcd"
22
22
"github.com/UffizziCloud/uffizzi-cluster-operator/controllers/uffizzicluster"
23
+ "k8s.io/utils/pointer"
23
24
"os"
25
+ ctrlcfg "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
24
26
25
27
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
26
28
// to ensure that exec-entrypoint and run can make use of them.
@@ -56,14 +58,19 @@ func init() {
56
58
}
57
59
58
60
func main () {
59
- var metricsAddr string
60
- var enableLeaderElection bool
61
- var probeAddr string
61
+ var (
62
+ metricsAddr string
63
+ probeAddr string
64
+ enableLeaderElection bool
65
+ concurrent int
66
+ )
67
+
62
68
flag .StringVar (& metricsAddr , "metrics-bind-address" , ":8080" , "The address the metric endpoint binds to." )
63
69
flag .StringVar (& probeAddr , "health-probe-bind-address" , ":8081" , "The address the probe endpoint binds to." )
64
70
flag .BoolVar (& enableLeaderElection , "leader-elect" , false ,
65
71
"Enable leader election for controller manager. " +
66
72
"Enabling this will ensure there is only one active controller manager." )
73
+ flag .IntVar (& concurrent , "concurrent" , 5 , "The number of concurrent reconciles per controller." )
67
74
opts := zap.Options {
68
75
Development : true ,
69
76
}
@@ -79,17 +86,12 @@ func main() {
79
86
HealthProbeBindAddress : probeAddr ,
80
87
LeaderElection : enableLeaderElection ,
81
88
LeaderElectionID : "bfbf93f2.uffizzi.com" ,
82
- // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
83
- // when the Manager ends. This requires the binary to immediately end when the
84
- // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
85
- // speeds up voluntary leader transitions as the new leader don't have to wait
86
- // LeaseDuration time first.
87
- //
88
- // In the default scaffold provided, the program ends immediately after
89
- // the manager stops, so would be fine to enable this option. However,
90
- // if you are doing or is intended to do any operation such as perform cleanups
91
- // after the manager stops then its usage might be unsafe.
92
- // LeaderElectionReleaseOnCancel: true,
89
+ Controller : ctrlcfg.ControllerConfigurationSpec {
90
+ GroupKindConcurrency : map [string ]int {
91
+ uclusteruffizzicomv1alpha1 .SchemaGroupVersion .WithKind ("UffizziCluster" ).String (): concurrent ,
92
+ },
93
+ RecoverPanic : pointer .Bool (true ),
94
+ },
93
95
})
94
96
if err != nil {
95
97
setupLog .Error (err , "unable to start manager" )
@@ -108,7 +110,7 @@ func main() {
108
110
Client : mgr .GetClient (),
109
111
Scheme : mgr .GetScheme (),
110
112
}).SetupWithManager (mgr ); err != nil {
111
- setupLog .Error (err , "unable to create controller" , "controller" , "UffizziCluster " )
113
+ setupLog .Error (err , "unable to create controller" , "controller" , "UffizziClusterEtcd " )
112
114
os .Exit (1 )
113
115
}
114
116
//+kubebuilder:scaffold:builder
0 commit comments