manifoldco / kubernetes-credentials

Kubernetes CRD to load Manifold Credentials as Secrets
https://www.manifold.co
BSD 3-Clause "New" or "Revised" License
21 stars 4 forks source link

Start using Cache Informers #30

Open jelmersnoeck opened 6 years ago

jelmersnoeck commented 6 years ago

Currently, for every resync we're talking to the Kubernetes API Server to get the latest state. On it's own, this is fine, but having multiple applications do this means the API Server gets overloaded.

We'll want to implement Cache Informers, allowing us to store a local copy of the state of our tracked objects (k8s secrets + our own CRDs). We'll want to use these informers to query the API as well to perform updates.

To do this, we'll need to have Generated Clients in place first. We can then configure these generated clients when we initiate our controller using the generated versioned clients (example).

Once we have the clients available, we can inject this into our controller and set up the desired Informers (some will come from the k8s client, others from the CRD Client). We'll then need to start the Informers and ensure their caches are synced.

An example of what is needed to start the informers can be found in the Grafana Operator.

Once we've started the informers, we'll want to update our controller to use the informers instead of kubekit.

jelmersnoeck commented 6 years ago

For review purposes, it might be easier if we split this up into multiple PRs. Where we do one PR to inject the client and set up the informers. The next one would then be replace all occurrences of kubekit with the correct informer.