@@ -79,17 +79,69 @@ func main() {
7979 flag .BoolVar (& enableLeaderElection , "enable-leader-election" , false ,
8080 "Enable leader election for controller manager. " +
8181 "Enabling this will ensure there is only one active controller manager." )
82- flag .Parse ()
8382
84- utils .CreateConfigMap (controller .OperatorName )
83+ // var metricsCertPath, metricsCertName, metricsCertKey string
84+ // var webhookCertPath, webhookCertName, webhookCertKey string
85+ // var secureMetrics bool
86+ // var enableHTTP2 bool
87+ // var tlsOpts []func(*tls.Config)
88+ // flag.BoolVar(&secureMetrics, "metrics-secure", true,
89+ // "If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.")
90+ // flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")
91+ // flag.StringVar(&webhookCertName, "webhook-cert-name", "tls.crt", "The name of the webhook certificate file.")
92+ // flag.StringVar(&webhookCertKey, "webhook-cert-key", "tls.key", "The name of the webhook key file.")
93+ // flag.StringVar(&metricsCertPath, "metrics-cert-path", "",
94+ // "The directory that contains the metrics server certificate.")
95+ // flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
96+ // flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
97+ // flag.BoolVar(&enableHTTP2, "enable-http2", false,
98+ // "If set, HTTP/2 will be enabled for the metrics and webhook servers")
8599
86100 opts := zap.Options {
87101 Level : common .LevelFunc ,
88102 StacktraceLevel : common .StackLevelFunc ,
89103 Development : true ,
90104 }
105+ // opts.BindFlags(flag.CommandLine)
106+ flag .Parse ()
107+
108+ utils .CreateConfigMap (controller .OperatorName )
91109 ctrl .SetLogger (zap .New (zap .UseFlagOptions (& opts )))
92110
111+ // disableHTTP2 := func(c *tls.Config) {
112+ // setupLog.Info("disabling http/2")
113+ // c.NextProtos = []string{"http/1.1"}
114+ // }
115+
116+ // if !enableHTTP2 {
117+ // tlsOpts = append(tlsOpts, disableHTTP2)
118+ // }
119+
120+ // // Create watchers for metrics and webhooks certificates
121+ // var metricsCertWatcher, webhookCertWatcher *certwatcher.CertWatcher
122+
123+ // // Initial webhook TLS options
124+ // webhookTLSOpts := tlsOpts
125+
126+ // if len(webhookCertPath) > 0 {
127+ // setupLog.Info("Initializing webhook certificate watcher using provided certificates",
128+ // "webhook-cert-path", webhookCertPath, "webhook-cert-name", webhookCertName, "webhook-cert-key", webhookCertKey)
129+
130+ // var err error
131+ // webhookCertWatcher, err = certwatcher.New(
132+ // filepath.Join(webhookCertPath, webhookCertName),
133+ // filepath.Join(webhookCertPath, webhookCertKey),
134+ // )
135+ // if err != nil {
136+ // setupLog.Error(err, "Failed to initialize webhook certificate watcher")
137+ // os.Exit(1)
138+ // }
139+
140+ // webhookTLSOpts = append(webhookTLSOpts, func(config *tls.Config) {
141+ // config.GetCertificate = webhookCertWatcher.GetCertificate
142+ // })
143+ // }
144+
93145 // see https://github.com/operator-framework/operator-sdk/issues/1813
94146 leaseDuration := 30 * time .Second
95147 renewDeadline := 20 * time .Second
@@ -102,8 +154,33 @@ func main() {
102154
103155 metricsServerOptions := metricsserver.Options {
104156 BindAddress : metricsAddr ,
157+ // SecureServing: secureMetrics,
158+ // TLSOpts: tlsOpts,
105159 }
106160
161+ // if secureMetrics {
162+ // metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization
163+ // }
164+
165+ // if len(metricsCertPath) > 0 {
166+ // setupLog.Info("Initializing metrics certificate watcher using provided certificates",
167+ // "metrics-cert-path", metricsCertPath, "metrics-cert-name", metricsCertName, "metrics-cert-key", metricsCertKey)
168+
169+ // var err error
170+ // metricsCertWatcher, err = certwatcher.New(
171+ // filepath.Join(metricsCertPath, metricsCertName),
172+ // filepath.Join(metricsCertPath, metricsCertKey),
173+ // )
174+ // if err != nil {
175+ // setupLog.Error(err, "to initialize metrics certificate watcher", "error", err)
176+ // os.Exit(1)
177+ // }
178+
179+ // metricsServerOptions.TLSOpts = append(metricsServerOptions.TLSOpts, func(config *tls.Config) {
180+ // config.GetCertificate = metricsCertWatcher.GetCertificate
181+ // })
182+ // }
183+
107184 mgr , err := ctrl .NewManager (ctrl .GetConfigOrDie (), ctrl.Options {
108185 Scheme : scheme ,
109186 Metrics : metricsServerOptions ,
@@ -162,6 +239,21 @@ func main() {
162239 os .Exit (1 )
163240 }
164241 // +kubebuilder:scaffold:builder
242+ // if metricsCertWatcher != nil {
243+ // setupLog.Info("Adding metrics certificate watcher to manager")
244+ // if err := mgr.Add(metricsCertWatcher); err != nil {
245+ // setupLog.Error(err, "unable to add metrics certificate watcher to manager")
246+ // os.Exit(1)
247+ // }
248+ // }
249+
250+ // if webhookCertWatcher != nil {
251+ // setupLog.Info("Adding webhook certificate watcher to manager")
252+ // if err := mgr.Add(webhookCertWatcher); err != nil {
253+ // setupLog.Error(err, "unable to add webhook certificate watcher to manager")
254+ // os.Exit(1)
255+ // }
256+ // }
165257
166258 if err := mgr .AddHealthzCheck ("healthz" , healthz .Ping ); err != nil {
167259 setupLog .Error (err , "unable to set up health check" )
0 commit comments