kiwigrid / k8s-sidecar

This is a docker container intended to run inside a kubernetes cluster to collect config maps with a specified label and store the included files in a local folder.
MIT License
580 stars 181 forks source link

#minor An option to send reload request only after watch cycle #327

Closed ahtohio closed 2 months ago

ahtohio commented 8 months ago

Reloading on each received event (with watch method) can be quite costly. I run Grafana provisioning and asking it to reload all my provisioned configmaps (>300) on each event is not needed and only increases cpu load.

Furthermore, due to k8s events internal workings, with each Watch cycle start we receive all existing watched resources as ADDED events and (provided this is a sidecar startup with no saved files to volume yet) for each of this event we trigger reload. Multiple times a second. Those multiple reload requests just add additional load for no reason and it makes much sense to just reload once after some time. Each WATCH_SERVER_TIMEOUT seconds, for example.

I've added an option RELOAD_ONCE_PER_BATCH that can toggle this reload-once-per-watch-cycle reload behaviour, false by default to not interfere with existing logic.