Use pod and node informers to reduce APIServer load #76
+92
−40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces the use of informers for listing pods and nodes. It's inspired by what is done in external-dns: https://github.com/kubernetes-sigs/external-dns/blob/805555872ee7e27ab15802a86e313120432117fa/source/ingress.go#L78
The main idea of informers are that they use an internal cache which is maintained via a watch. Whenever the operator will do a list pods or list nodes it will read from the internal cache instead of making an API call to the APIServer thus reducing the load which is usually caused by listing pods in big clusters.
This needs a bit of testing before it can be considered. I had to change a lot of
[]v1.Pod
to[]*v1.Pod
because of the informer semantics, but I don't fully understand the API yet so I won't to make sure we are still using the values in a safe way.Additionally we need to understand how this watch behaves when there are connection issues to the APIServer.