From ce5f049401c676bd9a7fcc3d44a1517077553858 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". --- Gopkg.lock | 1 + cmd/virtual-kubelet/commands/root/flag.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Gopkg.lock b/Gopkg.lock index 0d446a983..de6eefda4 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1397,6 +1397,7 @@ "k8s.io/client-go/tools/remotecommand", "k8s.io/client-go/tools/watch", "k8s.io/client-go/util/workqueue", + "k8s.io/klog", "k8s.io/kubernetes/pkg/api/v1/pod", "k8s.io/kubernetes/pkg/apis/core", "k8s.io/kubernetes/pkg/apis/core/pods", diff --git a/cmd/virtual-kubelet/commands/root/flag.go b/cmd/virtual-kubelet/commands/root/flag.go index e599fd9c3..f2d1e9794 100644 --- a/cmd/virtual-kubelet/commands/root/flag.go +++ b/cmd/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 {