diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c1c66383..a37595aba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ NOTE: all releases may include dependency updates, not specifically mentioned - feat: integrate try-as library [#912](https://github.com/hypermodeinc/modus/pull/912) - fix: sentry source context [#940](https://github.com/hypermodeinc/modus/pull/940) +- fix: connect kubernetes logger [#945](https://github.com/hypermodeinc/modus/pull/945) ## 2025-07-09 - Runtime v0.18.4 diff --git a/runtime/go.mod b/runtime/go.mod index a21379c95..0d7babb78 100644 --- a/runtime/go.mod +++ b/runtime/go.mod @@ -16,6 +16,7 @@ require ( github.com/docker/go-connections v0.5.0 github.com/fatih/color v1.18.0 github.com/getsentry/sentry-go v0.34.1 + github.com/go-logr/zerologr v1.2.3 github.com/go-sql-driver/mysql v1.9.3 github.com/go-viper/mapstructure/v2 v2.3.0 github.com/goccy/go-json v0.10.5 diff --git a/runtime/go.sum b/runtime/go.sum index d36360017..f55171b68 100644 --- a/runtime/go.sum +++ b/runtime/go.sum @@ -309,6 +309,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= +github.com/go-logr/zerologr v1.2.3 h1:up5N9vcH9Xck3jJkXzgyOxozT14R47IyDODz8LM1KSs= +github.com/go-logr/zerologr v1.2.3/go.mod h1:BxwGo7y5zgSHYR1BjbnHPyF/5ZjVKfKxAZANVu6E8Ho= github.com/go-openapi/jsonpointer v0.21.1 h1:whnzv/pNXtK2FbX/W9yJfRmE2gsmkfahjMKB0fZvcic= github.com/go-openapi/jsonpointer v0.21.1/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk= github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= diff --git a/runtime/secrets/kubernetes.go b/runtime/secrets/kubernetes.go index ac3b18cfd..5d826c3da 100644 --- a/runtime/secrets/kubernetes.go +++ b/runtime/secrets/kubernetes.go @@ -10,6 +10,7 @@ import ( "fmt" "strings" + "github.com/go-logr/zerologr" "github.com/hypermodeinc/modus/lib/manifest" "github.com/hypermodeinc/modus/runtime/app" "github.com/hypermodeinc/modus/runtime/logger" @@ -52,7 +53,7 @@ func (sp *kubernetesSecretsProvider) initialize(ctx context.Context) { sp.secretNamespace = parts[0] sp.secretName = parts[1] - cli, cache, err := newK8sClientForSecret(sp.secretNamespace, sp.secretName) + cli, cache, err := newK8sClientForSecret(ctx, sp.secretNamespace, sp.secretName) if err != nil { const msg = "Failed to initialize Kubernetes client." sentryutils.CaptureError(ctx, err, msg, @@ -157,12 +158,14 @@ func (sp *kubernetesSecretsProvider) hasSecret(ctx context.Context, name string) // newK8sClientForSecret creates a new Kubernetes client that watches // only a single secret `name` in namespace `ns`. -func newK8sClientForSecret(ns, name string) (client.Client, pkgcache.Cache, error) { +func newK8sClientForSecret(ctx context.Context, ns, name string) (client.Client, pkgcache.Cache, error) { scheme := runtime.NewScheme() if err := clientgoscheme.AddToScheme(scheme); err != nil { return nil, nil, err } + ctrl.SetLogger(zerologr.New(logger.Get(ctx))) + cl, err := cluster.New(ctrl.GetConfigOrDie(), func(clusterOptions *cluster.Options) { clusterOptions.Scheme = scheme clusterOptions.Cache.DefaultNamespaces = make(map[string]pkgcache.Config)