cloudnativelabs / kube-router

Kube-router, a turnkey solution for Kubernetes networking.
https://kube-router.io
Apache License 2.0
2.33k stars 471 forks source link

Refactor: Abstract Node Info #1739

Closed aauren closed 1 month ago

aauren commented 2 months ago

@jnummelin @rbrtbnfgl @mrueg

This prepares the way for broader refactors in the way that we handle nodes by:

Eventually the changes here should better support the work that will need to happen to fix #1738 #676

aauren commented 2 months ago

Refactors are always a bit of a slog to review.

But the gist of this one is that instead of storing all of the physical node data as individual data sets like nodeIPs, nodeIPv4Addrs, nodeHostName, etc. on each of the many kube-router controllers, I moved it into a single abstraction KRNode that now holds all of that data and has appropriate interfaces for only exposing specific subsets based upon need.

The ultimate goal of this refactor is to stop the need of constantly either attaching functions to the main controllers (NetworkServicesController, NetworkRouterController, NetworkPolicyController) or passing the entire controllers around the code base just because functions need a specific subset of data contained on the controllers.

Right now, my mid-term goal is to refactor injectRoute() in order to resolve #1738 in a way that doesn't perpetrate bad coding practices.

But eventually I think that more abstractions are going to be needed like this as there is quite a bit of cruft in the code base.