diff --git a/app/caps-controller-manager/main.go b/app/caps-controller-manager/main.go index 14f9742a..d30e0477 100644 --- a/app/caps-controller-manager/main.go +++ b/app/caps-controller-manager/main.go @@ -17,6 +17,7 @@ import ( cgrecord "k8s.io/client-go/tools/record" "k8s.io/component-base/logs" logsv1 "k8s.io/component-base/logs/api/v1" + "k8s.io/klog/v2" capiv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/controllers/remote" "sigs.k8s.io/cluster-api/util/flags" @@ -89,6 +90,9 @@ func main() { os.Exit(1) } + // klog.Background will automatically use the right logger. + ctrl.SetLogger(klog.Background()) + diagnosticsOpts := flags.GetDiagnosticsOptions(diagnosticsOptions) tlsOptionOverrides, err := flags.GetTLSOptionOverrideFuncs(tlsOptions) diff --git a/app/sidero-controller-manager/main.go b/app/sidero-controller-manager/main.go index 1d2a52c6..19ed696c 100644 --- a/app/sidero-controller-manager/main.go +++ b/app/sidero-controller-manager/main.go @@ -26,6 +26,7 @@ import ( "k8s.io/client-go/tools/record" "k8s.io/component-base/logs" logsv1 "k8s.io/component-base/logs/api/v1" + "k8s.io/klog/v2" capi "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util/flags" ctrl "sigs.k8s.io/controller-runtime" @@ -137,6 +138,9 @@ func main() { os.Exit(1) } + // klog.Background will automatically use the right logger. + ctrl.SetLogger(klog.Background()) + diagnosticsOpts := flags.GetDiagnosticsOptions(diagnosticsOptions) tlsOptionOverrides, err := flags.GetTLSOptionOverrideFuncs(tlsOptions)