@@ -32,6 +32,7 @@ import (
32
32
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
33
33
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
34
34
_ "k8s.io/client-go/plugin/pkg/client/auth"
35
+ "k8s.io/client-go/rest"
35
36
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
36
37
"k8s.io/utils/pointer"
37
38
ctrl "sigs.k8s.io/controller-runtime"
@@ -56,12 +57,6 @@ func init() {
56
57
}
57
58
58
59
func 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
-
65
60
zapOptions := zap.Options {
66
61
Development : true ,
67
62
TimeEncoder : zapcore .TimeEncoderOfLayout (time .RFC3339 ),
@@ -73,15 +68,27 @@ func main() {
73
68
ctx := ctrl .SetupSignalHandler ()
74
69
75
70
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 {},
79
76
}
80
77
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 {
82
89
Scheme : scheme ,
83
- MetricsBindAddress : metricsAddr ,
84
- HealthProbeBindAddress : probeAddr ,
90
+ MetricsBindAddress : cfg . Metrics . BindAddress ,
91
+ HealthProbeBindAddress : cfg . Health . BindAddress ,
85
92
LeaderElection : pointer .BoolDeref (cfg .LeaderElection .LeaderElect , false ),
86
93
LeaderElectionID : cfg .LeaderElection .ResourceName ,
87
94
LeaderElectionNamespace : cfg .LeaderElection .ResourceNamespace ,
@@ -90,10 +97,7 @@ func main() {
90
97
RetryPeriod : & cfg .LeaderElection .RetryPeriod .Duration ,
91
98
RenewDeadline : & cfg .LeaderElection .RenewDeadline .Duration ,
92
99
})
93
- if err != nil {
94
- setupLog .Error (err , "unable to start manager" )
95
- os .Exit (1 )
96
- }
100
+ exitOnError (err , "unable to start manager" )
97
101
98
102
mcadQueueController := mcad .NewJobController (mgr .GetConfig (), cfg .MCAD , & mcadconfig.MCADConfigurationExtended {})
99
103
if mcadQueueController == nil {
@@ -111,20 +115,11 @@ func main() {
111
115
exitOnError (instaScaleController .SetupWithManager (mgr ), "Error setting up InstaScale controller" )
112
116
}
113
117
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" )
122
120
123
121
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" )
128
123
}
129
124
130
125
func exitOnError (err error , msg string ) {
0 commit comments