diff --git a/bootstrap/kubeadm/main.go b/bootstrap/kubeadm/main.go index 624afdf7d333..819a5c31ccec 100644 --- a/bootstrap/kubeadm/main.go +++ b/bootstrap/kubeadm/main.go @@ -165,6 +165,11 @@ func main() { InitFlags(pflag.CommandLine) pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) + // Set log level 2 as default. + if err := pflag.CommandLine.Set("v", "2"); err != nil { + setupLog.Error(err, "failed to set log level: %v") + os.Exit(1) + } pflag.Parse() if err := logsv1.ValidateAndApply(logOptions, nil); err != nil { diff --git a/controlplane/kubeadm/main.go b/controlplane/kubeadm/main.go index 4b4e40670acb..f9a6bfab188f 100644 --- a/controlplane/kubeadm/main.go +++ b/controlplane/kubeadm/main.go @@ -169,6 +169,11 @@ func main() { InitFlags(pflag.CommandLine) pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) + // Set log level 2 as default. + if err := pflag.CommandLine.Set("v", "2"); err != nil { + setupLog.Error(err, "failed to set log level: %v") + os.Exit(1) + } pflag.Parse() if err := logsv1.ValidateAndApply(logOptions, nil); err != nil { diff --git a/docs/book/src/developer/logging.md b/docs/book/src/developer/logging.md index 1da2b7e34daf..da39f7531c65 100644 --- a/docs/book/src/developer/logging.md +++ b/docs/book/src/developer/logging.md @@ -117,7 +117,7 @@ for log levels; as a small integration on the above guidelines we would like to the code; a person reading those logs usually has deep knowledge of the codebase. - Don’t use verbosity higher than 5. -Ideally, in a future release of Cluster API we will switch to use 2 as a default verbosity (currently it is 0) for all the Cluster API +We are using log level 2 as a default verbosity for all core Cluster API controllers as recommended by the Kubernetes guidelines. ## Trade-offs diff --git a/docs/book/src/tasks/experimental-features/runtime-sdk/implement-extensions.md b/docs/book/src/tasks/experimental-features/runtime-sdk/implement-extensions.md index a4c1f7b68816..cf81e06304ce 100644 --- a/docs/book/src/tasks/experimental-features/runtime-sdk/implement-extensions.md +++ b/docs/book/src/tasks/experimental-features/runtime-sdk/implement-extensions.md @@ -95,6 +95,11 @@ func main() { InitFlags(pflag.CommandLine) pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) + // Set log level 2 as default. + if err := pflag.CommandLine.Set("v", "2"); err != nil { + setupLog.Error(err, "failed to set log level: %v") + os.Exit(1) + } pflag.Parse() // Validates logs flags using Kubernetes component-base machinery and applies them diff --git a/main.go b/main.go index bf46399b8804..7cb437958372 100644 --- a/main.go +++ b/main.go @@ -228,6 +228,11 @@ func main() { InitFlags(pflag.CommandLine) pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) + // Set log level 2 as default. + if err := pflag.CommandLine.Set("v", "2"); err != nil { + setupLog.Error(err, "failed to set log level: %v") + os.Exit(1) + } pflag.Parse() if err := logsv1.ValidateAndApply(logOptions, nil); err != nil { diff --git a/test/extension/main.go b/test/extension/main.go index 9d64f9711113..82af08549d13 100644 --- a/test/extension/main.go +++ b/test/extension/main.go @@ -106,6 +106,11 @@ func main() { InitFlags(pflag.CommandLine) pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) + // Set log level 2 as default. + if err := pflag.CommandLine.Set("v", "2"); err != nil { + setupLog.Error(err, "failed to set log level: %v") + os.Exit(1) + } pflag.Parse() // Validates logs flags using Kubernetes component-base machinery and apply them diff --git a/test/infrastructure/docker/main.go b/test/infrastructure/docker/main.go index ac1ab3e3ce8c..f87d8c777fab 100644 --- a/test/infrastructure/docker/main.go +++ b/test/infrastructure/docker/main.go @@ -167,6 +167,11 @@ func main() { initFlags(pflag.CommandLine) pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) + // Set log level 2 as default. + if err := pflag.CommandLine.Set("v", "2"); err != nil { + setupLog.Error(err, "failed to set log level: %v") + os.Exit(1) + } pflag.Parse() if err := logsv1.ValidateAndApply(logOptions, nil); err != nil { diff --git a/test/infrastructure/inmemory/main.go b/test/infrastructure/inmemory/main.go index 595f58549062..577a513ad22c 100644 --- a/test/infrastructure/inmemory/main.go +++ b/test/infrastructure/inmemory/main.go @@ -159,6 +159,11 @@ func main() { InitFlags(pflag.CommandLine) pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) + // Set log level 2 as default. + if err := pflag.CommandLine.Set("v", "2"); err != nil { + setupLog.Error(err, "failed to set log level: %v") + os.Exit(1) + } pflag.Parse() if err := logsv1.ValidateAndApply(logOptions, nil); err != nil {