@@ -27,6 +27,8 @@ import (
2727
2828 "github.com/pkg/errors"
2929 "github.com/spf13/pflag"
30+ "go.etcd.io/etcd/client/pkg/v3/logutil"
31+ "go.uber.org/zap/zapcore"
3032 appsv1 "k8s.io/api/apps/v1"
3133 corev1 "k8s.io/api/core/v1"
3234 apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
9698 clusterCacheConcurrency int
9799 etcdDialTimeout time.Duration
98100 etcdCallTimeout time.Duration
101+ etcdLogLevel string
99102 useDeprecatedInfraMachineNaming bool
100103)
101104
@@ -184,6 +187,9 @@ func InitFlags(fs *pflag.FlagSet) {
184187 fs .DurationVar (& etcdCallTimeout , "etcd-call-timeout-duration" , etcd .DefaultCallTimeout ,
185188 "Duration that the etcd client waits at most for read and write operations to etcd." )
186189
190+ fs .StringVar (& etcdLogLevel , "etcd-client-log-level" , zapcore .InfoLevel .String (),
191+ "Logging level for etcd client. Possible values are: debug, info, warn, error, dpanic, panic, fatal." )
192+
187193 fs .BoolVar (& useDeprecatedInfraMachineNaming , "use-deprecated-infra-machine-naming" , false ,
188194 "Use the deprecated naming convention for infra machines where they are named after the InfraMachineTemplate." )
189195 _ = fs .MarkDeprecated ("use-deprecated-infra-machine-naming" , "This flag will be removed in v1.10." )
@@ -389,13 +395,24 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {
389395 os .Exit (1 )
390396 }
391397
398+ zapLogLevel , err := zapcore .ParseLevel (etcdLogLevel )
399+ if err != nil {
400+ setupLog .Error (err , "Unable to parse etcd log level" )
401+ os .Exit (1 )
402+ }
403+ etcdLogger , err := logutil .CreateDefaultZapLogger (zapLogLevel )
404+ if err != nil {
405+ setupLog .Error (err , "unable to create etcd logger" )
406+ os .Exit (1 )
407+ }
392408 if err := (& kubeadmcontrolplanecontrollers.KubeadmControlPlaneReconciler {
393409 Client : mgr .GetClient (),
394410 SecretCachingClient : secretCachingClient ,
395411 ClusterCache : clusterCache ,
396412 WatchFilterValue : watchFilterValue ,
397413 EtcdDialTimeout : etcdDialTimeout ,
398414 EtcdCallTimeout : etcdCallTimeout ,
415+ EtcdLogger : etcdLogger ,
399416 RemoteConditionsGracePeriod : remoteConditionsGracePeriod ,
400417 DeprecatedInfraMachineNaming : useDeprecatedInfraMachineNaming ,
401418 }).SetupWithManager (ctx , mgr , concurrency (kubeadmControlPlaneConcurrency )); err != nil {
0 commit comments