From 2497028659b5968b60d7122a4b8bdac5ed393fa7 Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Wed, 8 May 2019 03:37:04 -0700 Subject: [PATCH] Add the ability to configure klog from VK (#595) All of Kubernetes logging is based on klog. Klog currently does not output any logging information to logrus, so you're flying somewhat blind to Kubernetes internals. This exposes the full set of configurables that klog offers, but decorates (prefixes) the klog configuration with "klog". --- virtual-kubelet/commands/root/flag.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/virtual-kubelet/commands/root/flag.go b/virtual-kubelet/commands/root/flag.go index e599fd9..f2d1e97 100644 --- a/virtual-kubelet/commands/root/flag.go +++ b/virtual-kubelet/commands/root/flag.go @@ -15,6 +15,7 @@ package root import ( + "flag" "fmt" "os" "strings" @@ -22,6 +23,7 @@ import ( "github.com/pkg/errors" "github.com/spf13/pflag" "github.com/virtual-kubelet/virtual-kubelet/trace/opencensus" + "k8s.io/klog" ) type mapVar map[string]string @@ -79,6 +81,13 @@ func installFlags(flags *pflag.FlagSet, c *Opts) { flags.DurationVar(&c.InformerResyncPeriod, "full-resync-period", c.InformerResyncPeriod, "how often to perform a full resync of pods between kubernetes and the provider") flags.DurationVar(&c.StartupTimeout, "startup-timeout", c.StartupTimeout, "How long to wait for the virtual-kubelet to start") + + flagset := flag.NewFlagSet("klog", flag.PanicOnError) + klog.InitFlags(flagset) + flagset.VisitAll(func(f *flag.Flag) { + f.Name = "klog." + f.Name + flags.AddGoFlag(f) + }) } func getEnv(key, defaultValue string) string {