From 8edd004f8b2059c7865934ba4225ed77e5b5d23d Mon Sep 17 00:00:00 2001 From: avivl Date: Thu, 30 May 2019 10:57:21 +0300 Subject: [PATCH] Add support for monitoring all node pools A new variable AllNodePools was introduced. Defaults to False. Once set to true all node pools in the cluster will be monitored and will get an available static ip from the pool Fixes #52 --- deploy/kubeip-configmap.yaml | 1 + deploy/kubeip-deployment.yaml | 6 ++++++ pkg/config/config.go | 3 +++ pkg/controller/controller.go | 3 +++ 4 files changed, 13 insertions(+) diff --git a/deploy/kubeip-configmap.yaml b/deploy/kubeip-configmap.yaml index 16fc4cf..55dca2d 100644 --- a/deploy/kubeip-configmap.yaml +++ b/deploy/kubeip-configmap.yaml @@ -6,6 +6,7 @@ data: KUBEIP_FORCEASSIGNMENT: "true" KUBEIP_ADDITIONALNODEPOOLS: "" KUBEIP_TICKER: "5" + KUBEIP_ALLNODEPOOLS: "false" kind: ConfigMap metadata: labels: diff --git a/deploy/kubeip-deployment.yaml b/deploy/kubeip-deployment.yaml index f4ffe99..054a899 100644 --- a/deploy/kubeip-deployment.yaml +++ b/deploy/kubeip-deployment.yaml @@ -58,6 +58,12 @@ spec: configMapKeyRef: key: "KUBEIP_TICKER" name: "kubeip-config" + - name: "KUBEIP_ALLNODEPOOLS" + valueFrom: + configMapKeyRef: + key: "KUBEIP_ALLNODEPOOLS" + name: "kubeip-config" + - name: GOOGLE_APPLICATION_CREDENTIALS diff --git a/pkg/config/config.go b/pkg/config/config.go index ae2babb..e754369 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -34,6 +34,7 @@ type Config struct { ForceAssignment bool AdditionalNodePools[] string Ticker time.Duration + AllNodePools bool } func setConfigDefaults() { @@ -44,6 +45,7 @@ func setConfigDefaults() { viper.SetDefault("ForceAssignment", true) viper.SetDefault("AdditionalNodePools", "") viper.SetDefault("Ticker", 5) + viper.SetDefault("AllNodePools", false) } func NewConfig() (*Config, error) { @@ -63,6 +65,7 @@ func NewConfig() (*Config, error) { ForceAssignment: viper.GetBool("forceassignment"), AdditionalNodePools: AdditionalNodePools, Ticker: viper.GetDuration("ticker"), + AllNodePools: viper.GetBool("allnodepools"), } return &c, nil } diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 3e953fe..61bfd83 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -209,6 +209,9 @@ func (c *Controller) processNextItem() bool { } func (c *Controller) isNodePollMonitored(pool string) bool { + if c.config.AllNodePools == true { + return true + } if strings.ToLower(pool) == strings.ToLower(c.config.NodePool) { return true }