@@ -32,6 +32,7 @@ import (
3232 utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3333 clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3434 _ "k8s.io/client-go/plugin/pkg/client/auth"
35+ "k8s.io/client-go/rest"
3536 configv1alpha1 "k8s.io/component-base/config/v1alpha1"
3637 "k8s.io/utils/pointer"
3738 ctrl "sigs.k8s.io/controller-runtime"
@@ -56,12 +57,6 @@ func init() {
5657}
5758
5859func main () {
59- var metricsAddr string
60- var probeAddr string
61-
62- flag .StringVar (& metricsAddr , "metrics-bind-address" , ":8080" , "The address the metric endpoint binds to." )
63- flag .StringVar (& probeAddr , "health-probe-bind-address" , ":8081" , "The address the probe endpoint binds to." )
64-
6560 zapOptions := zap.Options {
6661 Development : true ,
6762 TimeEncoder : zapcore .TimeEncoderOfLayout (time .RFC3339 ),
@@ -73,15 +68,27 @@ func main() {
7368 ctx := ctrl .SetupSignalHandler ()
7469
7570 cfg := config.CodeFlareOperatorConfiguration {
76- LeaderElection : & configv1alpha1.LeaderElectionConfiguration {},
77- MCAD : & mcadconfig.MCADConfiguration {},
78- InstaScale : & config.InstaScaleConfiguration {},
71+ ControllerManager : config.ControllerManager {
72+ LeaderElection : & configv1alpha1.LeaderElectionConfiguration {},
73+ },
74+ MCAD : & mcadconfig.MCADConfiguration {},
75+ InstaScale : & config.InstaScaleConfiguration {},
7976 }
8077
81- mgr , err := ctrl .NewManager (ctrl .GetConfigOrDie (), ctrl.Options {
78+ kubeConfig , err := ctrl .GetConfig ()
79+ exitOnError (err , "unable to get client config" )
80+
81+ if kubeConfig .UserAgent == "" {
82+ kubeConfig .UserAgent = "codeflare-operator"
83+ }
84+ kubeConfig .Burst = int (pointer .Int32Deref (cfg .ClientConnection .Burst , int32 (rest .DefaultBurst )))
85+ kubeConfig .QPS = pointer .Float32Deref (cfg .ClientConnection .QPS , rest .DefaultQPS )
86+ setupLog .V (2 ).Info ("REST client" , "qps" , kubeConfig .QPS , "burst" , kubeConfig .Burst )
87+
88+ mgr , err := ctrl .NewManager (kubeConfig , ctrl.Options {
8289 Scheme : scheme ,
83- MetricsBindAddress : metricsAddr ,
84- HealthProbeBindAddress : probeAddr ,
90+ MetricsBindAddress : cfg . Metrics . BindAddress ,
91+ HealthProbeBindAddress : cfg . Health . BindAddress ,
8592 LeaderElection : pointer .BoolDeref (cfg .LeaderElection .LeaderElect , false ),
8693 LeaderElectionID : cfg .LeaderElection .ResourceName ,
8794 LeaderElectionNamespace : cfg .LeaderElection .ResourceNamespace ,
@@ -90,10 +97,7 @@ func main() {
9097 RetryPeriod : & cfg .LeaderElection .RetryPeriod .Duration ,
9198 RenewDeadline : & cfg .LeaderElection .RenewDeadline .Duration ,
9299 })
93- if err != nil {
94- setupLog .Error (err , "unable to start manager" )
95- os .Exit (1 )
96- }
100+ exitOnError (err , "unable to start manager" )
97101
98102 mcadQueueController := mcad .NewJobController (mgr .GetConfig (), cfg .MCAD , & mcadconfig.MCADConfigurationExtended {})
99103 if mcadQueueController == nil {
@@ -111,20 +115,11 @@ func main() {
111115 exitOnError (instaScaleController .SetupWithManager (mgr ), "Error setting up InstaScale controller" )
112116 }
113117
114- if err := mgr .AddHealthzCheck ("healthz" , healthz .Ping ); err != nil {
115- setupLog .Error (err , "unable to set up health check" )
116- os .Exit (1 )
117- }
118- if err := mgr .AddReadyzCheck ("readyz" , healthz .Ping ); err != nil {
119- setupLog .Error (err , "unable to set up ready check" )
120- os .Exit (1 )
121- }
118+ exitOnError (mgr .AddHealthzCheck (cfg .Health .LivenessEndpointName , healthz .Ping ), "unable to set up health check" )
119+ exitOnError (mgr .AddReadyzCheck (cfg .Health .ReadinessEndpointName , healthz .Ping ), "unable to set up ready check" )
122120
123121 setupLog .Info ("starting manager" )
124- if err := mgr .Start (ctx ); err != nil {
125- setupLog .Error (err , "problem running manager" )
126- os .Exit (1 )
127- }
122+ exitOnError (mgr .Start (ctx ), "error running manager" )
128123}
129124
130125func exitOnError (err error , msg string ) {
0 commit comments