Skip to content

Commit 5b408e3

Browse files
committed
feat: apply TLS profile to COO
This commit passes the TLS configuration read from the cluster TLS profile to the operator's HTTPS server. Signed-off-by: Simon Pasquier <spasquie@redhat.com>
1 parent fad3bee commit 5b408e3

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

pkg/operator/operator.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ type OperatorConfiguration struct {
7272
UIPlugins uictrl.UIPluginsConfiguration
7373
FeatureGates FeatureGates
7474
ObservabilityInstaller ObservabilityInstallerConfiguration
75+
TLSProfile configv1.TLSProfileSpec
7576
// CancelFunc is called to trigger graceful shutdown (e.g., on TLS profile change).
7677
CancelFunc context.CancelFunc
7778
}
@@ -159,13 +160,15 @@ func WithCancelFunc(cancel context.CancelFunc) func(*OperatorConfiguration) {
159160

160161
func WithTLSProfile(tlsProfile configv1.TLSProfileSpec) func(*OperatorConfiguration) {
161162
return func(oc *OperatorConfiguration) {
163+
oc.TLSProfile = tlsProfile
162164
oc.UIPlugins.TLSProfile = tlsProfile
163165
}
164166
}
165167

166168
func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
167169
restConfig := ctrl.GetConfigOrDie()
168170
scheme := NewScheme(cfg)
171+
setupLog := ctrl.Log.WithName("setup")
169172

170173
metricsOpts := metricsserver.Options{
171174
BindAddress: cfg.MetricsAddr,
@@ -230,10 +233,16 @@ func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
230233
ctrl.Log.WithName("events").Info(fmt.Sprintf(format, args...))
231234
})
232235

236+
var tlsConfig tls.Config
237+
tlsConfigFn, unsupportedCiphers := openshifttls.NewTLSConfigFromProfile(cfg.TLSProfile)
238+
if len(unsupportedCiphers) > 0 {
239+
setupLog.Info("Some ciphers from TLS profile are not supported", "ciphers", unsupportedCiphers)
240+
}
241+
tlsConfigFn(&tlsConfig)
242+
tlsConfig.ClientAuth = tls.RequireAndVerifyClientCert
243+
233244
servingCertController = dynamiccertificates.NewDynamicServingCertificateController(
234-
&tls.Config{
235-
ClientAuth: tls.RequireAndVerifyClientCert,
236-
},
245+
&tlsConfig,
237246
clientCAController,
238247
certKeyProvider,
239248
nil,
@@ -326,11 +335,10 @@ func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
326335
}
327336

328337
if cfg.FeatureGates.OpenShift.Enabled {
329-
setupLog := ctrl.Log.WithName("setup")
330338

331339
watcher := &openshifttls.SecurityProfileWatcher{
332340
Client: mgr.GetClient(),
333-
InitialTLSProfileSpec: cfg.UIPlugins.TLSProfile,
341+
InitialTLSProfileSpec: cfg.TLSProfile,
334342
OnProfileChange: func(_ context.Context, _, _ configv1.TLSProfileSpec) {
335343
setupLog.Info("TLS security profile changed, triggering graceful restart")
336344
if cfg.CancelFunc != nil {
@@ -346,7 +354,6 @@ func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
346354
return nil, fmt.Errorf("unable to register observability-ui-plugin controller: %w", err)
347355
}
348356
} else {
349-
setupLog := ctrl.Log.WithName("setup")
350357
setupLog.Info("OpenShift feature gate is disabled, UIPlugins are not enabled")
351358
}
352359

@@ -355,7 +362,6 @@ func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
355362
return nil, fmt.Errorf("unable to register operator controller: %w", err)
356363
}
357364
} else {
358-
setupLog := ctrl.Log.WithName("setup")
359365
setupLog.Info("OpenShift feature gate is disabled, Operator controller is not enabled")
360366
}
361367

@@ -378,7 +384,6 @@ func New(ctx context.Context, cfg *OperatorConfiguration) (*Operator, error) {
378384
return nil, fmt.Errorf("unable to register cluster observability controller: %w", err)
379385
}
380386
} else {
381-
setupLog := ctrl.Log.WithName("setup")
382387
setupLog.Info("OpenShift feature gate is disabled, cluster observability controller is not enabled")
383388
}
384389

0 commit comments

Comments
 (0)