Skip to content

Commit

Permalink
feat: ctrl runtime manglet logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrremann committed Feb 19, 2025
1 parent e09543d commit 85dc67e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmd/naiserator_webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import (
"github.com/nais/naiserator/pkg/metrics"
"github.com/nais/naiserator/pkg/naiserator/config"
log "github.com/sirupsen/logrus"
_ "k8s.io/client-go/plugin/pkg/client/auth"
ctrl "sigs.k8s.io/controller-runtime"
ctrl_log "sigs.k8s.io/controller-runtime/pkg/log"
kubemetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

_ "k8s.io/client-go/plugin/pkg/client/auth"
)

func main() {
Expand Down Expand Up @@ -54,6 +56,9 @@ func run() error {
return err
}

logSink := &logrus2logr.Logrus2Logr{Logger: log.StandardLogger()}
ctrl_log.SetLogger(logr.New(logSink.WithName("controller-runtime")))

kconfig, err := ctrl.GetConfig()
if err != nil {
return err
Expand All @@ -62,7 +67,6 @@ func run() error {
kconfig.Burst = cfg.Ratelimit.Burst

metrics.Register(kubemetrics.Registry)
logSink := &logrus2logr.Logrus2Logr{Logger: log.StandardLogger()}
mgr, err := ctrl.NewManager(kconfig, ctrl.Options{
Scheme: kscheme,
Metrics: metricsserver.Options{
Expand All @@ -72,7 +76,7 @@ func run() error {
Host: "0.0.0.0",
Port: 8443,
}),
Logger: logr.New(logSink),
Logger: logr.New(logSink.WithName("controller")),
})
if err != nil {
return err
Expand Down

0 comments on commit 85dc67e

Please sign in to comment.