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

External IPs not being assigned if node's access config name != 'external-nat'

ureesoriano opened this issue · comments

1. Describe the bug:

After successfully - and VERY easily :kudos: - deploying Kubeip on my GKE cluster, I noticed it wasn't assigning free external IPs to nodes with ephemeral IPs. In the logs, the following error was appearing:

level=error msg="AddAccessConfig \"googleapi: Error 400: At most one access config currently supported., badRequest\"

2. Cause:

The steps that Kubeip follows to replace an ephemeral IP with an external IP on a given node are, among others:

The cause of the error in the log is that Kubeip was not successfully deleting the node's access config. And this happened because, in my case, the access config's name was not 'external-nat' (interestingly enough though, the gcloud API did return a 200).
Due to this, when Kubeip later attempted to add another access config with the external IP, the gcloud API returned the aforementioned error in my logs, stating that 1 is the max number of access configs allowed.

3. Expected behavior

IMHO, Kubeip should assign free external IPs to nodes with ephemeral IPs independently of the nodes' access config name.

4. Proposed solution:

Although my experience with go is scarce, building products on top of AWS/Azure/GCloud/Kubernetes APIs is my daily job :)
My preffered approach of this case would be, instead of assuming that the state of the resources on GCloud will be X (IE: the name of the access config will be 'external-nat'), query the API and actively retrieve the state of, in this case, the node's access config. Finally, rely on the access config 's state retrieved from the API (more specifically, its name) to issue the DeleteAccessConfig request.

I have submitted a MR implementing this solution: #60
I'd appreciate if you could review it and please, feel free to suggest any change you see fit.
(the "patched" version is already running on my cluster and producing the expected results)

@ureesoriano PR approved and merged. Thank you!