doitintl / kubeip

Assign static public IPs to Kubernetes nodes (GKE, EKS)

Home Page:https://kubeip.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pool independent IPs

geekflyer opened this issue · comments

We have a gke cluster with multiple node pools. We would like to assign static IPs to all nodes in the cluster.

Currently it seems the only way to achieve this is to reserve multiple static IPs and then exlusively pre-allocate each IP to a specific nodepool via the kubeip-node-pool=<pool_name> label.

This is kind of problematic since whenever we change the number of pools or rename pools (sometimes it's necessary to replace one pool with another in order add for example a new oauth permission etc.) we also have to update the labels of all static IPs used in that cluster.

Would it be possible to simply have a single / cluster-wide "pool of ip addresses" which is used to satisfy the static IP address needs of multiple or all node pools in a specific cluster?

I.e. imagine this:

  1. We reserve 20 static IPs and label them with kubeip: <clusterName>
  2. We create a cluster with 3 nodepools with random names, each nodepool having 5 nodes (i.e. 15 total)
  3. Kubeip auto assigns static IPs to all 15 nodes.

I'm fine still having to specify KUBEIP_NODEPOOL and KUBEIP_ADDITIONALNODEPOOLS if that's really required but it'd like to avoid "exlusively" tying a set of IPs to a single nodepool.

@geekflyer 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

@avivl I just tried out the latest version of kubeip and unfortunately this still doesn't work.
I'm getting this error message when I'm trying to use KUBEIP_ALLNODEPOOLS: 'true':

kubeip-5c7888cfbb-7rwt5 kubeip time="2019-06-01T19:45:36Z" level=info msg="kubeip controller synced and ready" pkg=kubeip-node
kubeip-5c7888cfbb-7rwt5 kubeip time="2019-06-01T19:45:36Z" level=info msg="Found un assigned node gke-api-cluster-dev--default-pool-2d1-af3a5afd-m57f in pool%!(EXTRA string=default-pool-2d136f4)" function=processAllNodes pkg=kubeip
kubeip-5c7888cfbb-7rwt5 kubeip time="2019-06-01T19:45:36Z" level=info msg="Working on gke-api-cluster-dev--default-pool-2d1-af3a5afd-m57f in zone us-west1-b" function=Kubeip pkg=kubeip
kubeip-5c7888cfbb-7rwt5 kubeip time="2019-06-01T19:45:37Z" level=info msg="no free address found"

I think the problem lies here:

var filter string
if strings.ToLower(pool) == strings.ToLower(config.NodePool) {
filter = "(labels." + config.LabelKey + "=" + config.LabelValue + ")" + " AND (-labels." + config.LabelKey + "-node-pool:*)"
} else {
filter = "(labels." + config.LabelKey + "=" + config.LabelValue + ")" + " AND " + "(labels." + config.LabelKey + "-node-pool=" +pool + ")"
}

The logic there is still filtering for IPs which are labeled with the target pool name.

created a PR #54 which should fix this

@geekflyer thanks good catch!