@@ -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"
@@ -100,6 +102,7 @@ var (
100102 skipCRDMigrationPhases []string
101103 etcdDialTimeout time.Duration
102104 etcdCallTimeout time.Duration
105+ etcdLogLevel string
103106)
104107
105108func init () {
@@ -190,6 +193,9 @@ func InitFlags(fs *pflag.FlagSet) {
190193 fs .DurationVar (& etcdCallTimeout , "etcd-call-timeout-duration" , etcd .DefaultCallTimeout ,
191194 "Duration that the etcd client waits at most for read and write operations to etcd." )
192195
196+ fs .StringVar (& etcdLogLevel , "etcd-client-log-level" , zapcore .InfoLevel .String (),
197+ "Logging level for etcd client. Possible values are: debug, info, warn, error, dpanic, panic, fatal." )
198+
193199 flags .AddManagerOptions (fs , & managerOptions )
194200
195201 feature .MutableGates .AddFlag (fs )
@@ -418,13 +424,24 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {
418424 os .Exit (1 )
419425 }
420426
427+ zapLogLevel , err := zapcore .ParseLevel (etcdLogLevel )
428+ if err != nil {
429+ setupLog .Error (err , "Unable to parse etcd log level" )
430+ os .Exit (1 )
431+ }
432+ etcdLogger , err := logutil .CreateDefaultZapLogger (zapLogLevel )
433+ if err != nil {
434+ setupLog .Error (err , "unable to create etcd logger" )
435+ os .Exit (1 )
436+ }
421437 if err := (& kubeadmcontrolplanecontrollers.KubeadmControlPlaneReconciler {
422438 Client : mgr .GetClient (),
423439 SecretCachingClient : secretCachingClient ,
424440 ClusterCache : clusterCache ,
425441 WatchFilterValue : watchFilterValue ,
426442 EtcdDialTimeout : etcdDialTimeout ,
427443 EtcdCallTimeout : etcdCallTimeout ,
444+ EtcdLogger : etcdLogger ,
428445 RemoteConditionsGracePeriod : remoteConditionsGracePeriod ,
429446 }).SetupWithManager (ctx , mgr , concurrency (kubeadmControlPlaneConcurrency )); err != nil {
430447 setupLog .Error (err , "unable to create controller" , "controller" , "KubeadmControlPlane" )
0 commit comments