@@ -21,13 +21,11 @@ import (
2121 "flag"
2222 "fmt"
2323 "os"
24- "path/filepath"
2524 "time"
2625
2726 intController "github.com/splunk/splunk-operator/internal/controller"
2827 "github.com/splunk/splunk-operator/internal/controller/debug"
2928 "github.com/splunk/splunk-operator/pkg/config"
30- "sigs.k8s.io/controller-runtime/pkg/certwatcher"
3129 "sigs.k8s.io/controller-runtime/pkg/metrics/filters"
3230
3331 // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
@@ -82,9 +80,6 @@ func main() {
8280
8381 var tlsOpts []func (* tls.Config )
8482
85- var metricsCertPath , metricsCertName , metricsCertKey string
86- var webhookCertPath , webhookCertName , webhookCertKey string
87-
8883 flag .StringVar (& logEncoder , "log-encoder" , "json" , "log encoding ('json' or 'console')" )
8984 flag .StringVar (& probeAddr , "health-probe-bind-address" , ":8081" , "The address the probe endpoint binds to." )
9085 flag .BoolVar (& enableLeaderElection , "leader-elect" , false ,
@@ -98,34 +93,6 @@ func main() {
9893 "Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service." )
9994 flag .BoolVar (& secureMetrics , "metrics-secure" , false ,
10095 "If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead." )
101- flag .StringVar (& webhookCertPath , "webhook-cert-path" , "" , "The directory that contains the webhook certificate." )
102- flag .StringVar (& webhookCertName , "webhook-cert-name" , "tls.crt" , "The name of the webhook certificate file." )
103- flag .StringVar (& webhookCertKey , "webhook-cert-key" , "tls.key" , "The name of the webhook key file." )
104- flag .StringVar (& metricsCertPath , "metrics-cert-path" , "" , "The directory that contains the metrics server certificate." )
105- flag .StringVar (& metricsCertName , "metrics-cert-name" , "tls.crt" , "The name of the metrics server certificate file." )
106- flag .StringVar (& metricsCertKey , "metrics-cert-key" , "tls.key" , "The name of the metrics server key file." )
107-
108- var metricsCertWatcher , webhookCertWatcher * certwatcher.CertWatcher
109- webhookTLSOpts := tlsOpts
110-
111- if len (webhookCertPath ) > 0 {
112- setupLog .Info ("Initializing webhook certificate watcher using provided certificates" ,
113- "webhook-cert-path" , webhookCertPath , "webhook-cert-name" , webhookCertName , "webhook-cert-key" , webhookCertKey )
114-
115- var err error
116- webhookCertWatcher , err = certwatcher .New (
117- filepath .Join (webhookCertPath , webhookCertName ),
118- filepath .Join (webhookCertPath , webhookCertKey ),
119- )
120- if err != nil {
121- setupLog .Error (err , "Failed to initialize webhook certificate watcher" )
122- os .Exit (1 )
123- }
124-
125- webhookTLSOpts = append (webhookTLSOpts , func (config * tls.Config ) {
126- config .GetCertificate = webhookCertWatcher .GetCertificate
127- })
128- }
12996
13097 // Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
13198 // More info:
@@ -140,7 +107,7 @@ func main() {
140107 // as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing
141108 // unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName
142109 // to provide certificates, ensuring the server communicates using trusted and secure certificates.
143- TLSOpts : webhookTLSOpts ,
110+ TLSOpts : tlsOpts ,
144111 FilterProvider : filters .WithAuthenticationAndAuthorization ,
145112 }
146113
@@ -189,25 +156,6 @@ func main() {
189156 // Apply namespace-specific configuration
190157 managerOptions := config .ManagerOptionsWithNamespaces (setupLog , baseOptions )
191158
192- if len (metricsCertPath ) > 0 {
193- setupLog .Info ("Initializing metrics certificate watcher using provided certificates" ,
194- "metrics-cert-path" , metricsCertPath , "metrics-cert-name" , metricsCertName , "metrics-cert-key" , metricsCertKey )
195-
196- var err error
197- metricsCertWatcher , err = certwatcher .New (
198- filepath .Join (metricsCertPath , metricsCertName ),
199- filepath .Join (metricsCertPath , metricsCertKey ),
200- )
201- if err != nil {
202- setupLog .Error (err , "Failed to initialize metrics certificate watcher" )
203- os .Exit (1 )
204- }
205-
206- metricsServerOptions .TLSOpts = append (metricsServerOptions .TLSOpts , func (config * tls.Config ) {
207- config .GetCertificate = metricsCertWatcher .GetCertificate
208- })
209- }
210-
211159 mgr , err := ctrl .NewManager (ctrl .GetConfigOrDie (), managerOptions )
212160
213161 if err != nil {
@@ -275,22 +223,6 @@ func main() {
275223 }
276224 //+kubebuilder:scaffold:builder
277225
278- if metricsCertWatcher != nil {
279- setupLog .Info ("Adding metrics certificate watcher to manager" )
280- if err := mgr .Add (metricsCertWatcher ); err != nil {
281- setupLog .Error (err , "Unable to add metrics certificate watcher to manager" )
282- os .Exit (1 )
283- }
284- }
285-
286- if webhookCertWatcher != nil {
287- setupLog .Info ("Adding webhook certificate watcher to manager" )
288- if err := mgr .Add (webhookCertWatcher ); err != nil {
289- setupLog .Error (err , "Unable to add webhook certificate watcher to manager" )
290- os .Exit (1 )
291- }
292- }
293-
294226 if err := mgr .AddHealthzCheck ("healthz" , healthz .Ping ); err != nil {
295227 setupLog .Error (err , "unable to set up health check" )
296228 os .Exit (1 )
0 commit comments