@@ -56,6 +56,8 @@ import (
5656 "kubevirt.io/kubevirt-migration-controller/internal/controller/multinamespacestoragemigplan"
5757 storagemig "kubevirt.io/kubevirt-migration-controller/internal/controller/storagemig"
5858 storagemigplan "kubevirt.io/kubevirt-migration-controller/internal/controller/storagemigplan"
59+ componenthelpers "kubevirt.io/kubevirt-migration-controller/pkg/component-helpers"
60+ migrationsv1alpha1 "kubevirt.io/kubevirt-migration-operator/api/v1alpha1"
5961 // +kubebuilder:scaffold:imports
6062)
6163
@@ -71,6 +73,7 @@ func init() {
7173 utilruntime .Must (routev1 .AddToScheme (scheme ))
7274 utilruntime .Must (ocpconfigv1 .AddToScheme (scheme ))
7375 utilruntime .Must (migrations .AddToScheme (scheme ))
76+ utilruntime .Must (migrationsv1alpha1 .AddToScheme (scheme ))
7477 // +kubebuilder:scaffold:scheme
7578}
7679
@@ -124,6 +127,23 @@ func main() {
124127 tlsOpts = append (tlsOpts , disableHTTP2 )
125128 }
126129
130+ managedTLSWatcher := componenthelpers .NewManagedTLSWatcher ()
131+
132+ cryptoPolicyOpt := func (c * tls.Config ) {
133+ c .GetConfigForClient = func (t * tls.ClientHelloInfo ) (* tls.Config , error ) {
134+ config := c .Clone ()
135+ if managedTLSWatcher != nil {
136+ ctx := t .Context ()
137+ cc := managedTLSWatcher .GetTLSConfig (ctx )
138+ config .CipherSuites = cc .CipherSuites
139+ config .MinVersion = cc .MinVersion
140+ }
141+ return config , nil
142+ }
143+ }
144+
145+ tlsOpts = append (tlsOpts , cryptoPolicyOpt )
146+
127147 // Create watchers for metrics and webhooks certificates
128148 var metricsCertWatcher , webhookCertWatcher * certwatcher.CertWatcher
129149
@@ -261,6 +281,12 @@ func main() {
261281 setupLog .Error (err , "unable to create controller" , "controller" , "MultiNamespaceStorageMigration" )
262282 os .Exit (1 )
263283 }
284+
285+ managedTLSWatcher .SetCache (mgr .GetCache ())
286+ if err := mgr .Add (managedTLSWatcher ); err != nil {
287+ setupLog .Error (err , "unable to add TLS watcher to manager" )
288+ os .Exit (1 )
289+ }
264290 // +kubebuilder:scaffold:builder
265291
266292 if metricsCertWatcher != nil {
@@ -301,6 +327,11 @@ func main() {
301327func getCacheOptions (apiClient client.Client ) cache.Options {
302328 ns := getNamespace ("/var/run/secrets/kubernetes.io/serviceaccount/namespace" )
303329
330+ // MigController is intentionally not listed in ByObject.
331+ // controller-runtime iterates ByObject entries at cache init
332+ // time and calls apiutil.IsObjectNamespaced for each, which
333+ // fails if the CRD is not registered in the API server.
334+ // See: https://github.com/kubernetes-sigs/controller-runtime/issues/2456
304335 cacheOptions := cache.Options {
305336 ByObject : map [client.Object ]cache.ByObject {
306337 & v1.ConfigMap {}: {
0 commit comments