Skip to content

Allow skipping loading all apigroups on startup #722

@lilatomic

Description

@lilatomic

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:

  1. allow manually loading APIObjects
  2. prime the cache with the results similar to _walk_subclasses(APIObject). This will provide a reasonable default
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions