From 43eda261eeba25130219cb22f0a014f0bf8c9f5c Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 20 Feb 2018 17:38:35 +0000 Subject: [PATCH 1/2] Disable polling of Kubernetes by default We set up a "watch" on everything we need so there is no reason to poll repeatedly. --- prog/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prog/main.go b/prog/main.go index 61ede6ab2..f57aeaa28 100644 --- a/prog/main.go +++ b/prog/main.go @@ -303,7 +303,7 @@ func setupFlags(flags *flags) { // K8s flag.BoolVar(&flags.probe.kubernetesEnabled, "probe.kubernetes", false, "collect kubernetes-related attributes for containers") - flag.DurationVar(&flags.probe.kubernetesClientConfig.Interval, "probe.kubernetes.interval", 10*time.Second, "how often to do a full resync of the kubernetes data") + flag.DurationVar(&flags.probe.kubernetesClientConfig.Interval, "probe.kubernetes.interval", 0, "how often to do a full resync of the kubernetes data (zero=never)") flag.StringVar(&flags.probe.kubernetesClientConfig.Server, "probe.kubernetes.api", "", "The address and port of the Kubernetes API server (deprecated in favor of equivalent probe.kubernetes.server)") flag.StringVar(&flags.probe.kubernetesClientConfig.CertificateAuthority, "probe.kubernetes.certificate-authority", "", "Path to a cert. file for the certificate authority") flag.StringVar(&flags.probe.kubernetesClientConfig.ClientCertificate, "probe.kubernetes.client-certificate", "", "Path to a client certificate file for TLS") From 1de6d9755a6a6ac3fa638cfc5372e948828280e5 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 22 Feb 2018 15:05:20 +0000 Subject: [PATCH 2/2] Remove -probe.kubernetes.interval flag entirely --- probe/kubernetes/client.go | 9 +++------ prog/main.go | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/probe/kubernetes/client.go b/probe/kubernetes/client.go index 0545f64ac..7c869ad12 100644 --- a/probe/kubernetes/client.go +++ b/probe/kubernetes/client.go @@ -48,7 +48,6 @@ type Client interface { type client struct { quit chan struct{} - resyncPeriod time.Duration client *kubernetes.Clientset podStore cache.Store serviceStore cache.Store @@ -66,7 +65,6 @@ type client struct { // ClientConfig establishes the configuration for the kubernetes client type ClientConfig struct { - Interval time.Duration CertificateAuthority string ClientCertificate string ClientKey string @@ -129,9 +127,8 @@ func NewClient(config ClientConfig) (Client, error) { } result := &client{ - quit: make(chan struct{}), - resyncPeriod: config.Interval, - client: c, + quit: make(chan struct{}), + client: c, } result.podStore = NewEventStore(result.triggerPodWatches, cache.MetaNamespaceKeyFunc) @@ -225,7 +222,7 @@ func (c *client) runReflectorUntil(resource string, store cache.Store) { return true, nil } lw := cache.NewListWatchFromClient(kclient, resource, metav1.NamespaceAll, fields.Everything()) - r = cache.NewReflector(lw, itemType, store, c.resyncPeriod) + r = cache.NewReflector(lw, itemType, store, 0) } select { diff --git a/prog/main.go b/prog/main.go index f57aeaa28..4bf027628 100644 --- a/prog/main.go +++ b/prog/main.go @@ -303,7 +303,6 @@ func setupFlags(flags *flags) { // K8s flag.BoolVar(&flags.probe.kubernetesEnabled, "probe.kubernetes", false, "collect kubernetes-related attributes for containers") - flag.DurationVar(&flags.probe.kubernetesClientConfig.Interval, "probe.kubernetes.interval", 0, "how often to do a full resync of the kubernetes data (zero=never)") flag.StringVar(&flags.probe.kubernetesClientConfig.Server, "probe.kubernetes.api", "", "The address and port of the Kubernetes API server (deprecated in favor of equivalent probe.kubernetes.server)") flag.StringVar(&flags.probe.kubernetesClientConfig.CertificateAuthority, "probe.kubernetes.certificate-authority", "", "Path to a cert. file for the certificate authority") flag.StringVar(&flags.probe.kubernetesClientConfig.ClientCertificate, "probe.kubernetes.client-certificate", "", "Path to a client certificate file for TLS")