-
Notifications
You must be signed in to change notification settings - Fork 65
Allow skipping loading all apigroups on startup #722
Description
Which project are you requesting an enhancement for?
kr8s
What do you need?
As part of the startup of a kr8s Api, async_api_resources_uncached will make an API query for every apigroup in the cluster. If there are many clusters that are far away and have many api-groups this can take a few seconds. We have many small cli tools that leverage kr8s, so this loading time sometimes takes most of the execution time. It would be nice if we could bypass this.
A few thoughts on how we could proceed:
- allow manually loading APIObjects
- prime the cache with the results similar to
_walk_subclasses(APIObject). This will provide a reasonable default - kubectl already caches the responses from these endpoints. We could load them directly
Having an incomplete cache should be fine, since we could fall through and do a full load. I think there is a risk in loading something that is possibly stale (such as the builtin APIObjects) since they could contain incorrect data. But we could mitigate that the way kubectl does.
I think we would need to expose the cache of async_api_resources. If you're OK modifying the vendored asyncache, that's a single-line change.