Skip to content

Informer based CustomResourceEventSource #567

Closed
@csviri

Description

@csviri

Using informer instead of a simple Watch in the custom resource event source will make it more reliable. Also it will serve as a cache for, replacing our current approach for caching.

In general informers does the watching little differently then the current approach. First lists the resources then starts watching but just from the last seen resource version (this eliminates some watcher related issues) also handles the watch reconnect in the same way.
Informers also provide caches and other nice features for indexing (+custom indexes, although the custom indexing is not relevant for this issue)

This fits very much into the picture where we want to be with the CustomResourceEventSource and it's not our code that we have to maintain.

Fabric8 provides a nice implementation: https://github.com/fabric8io/kubernetes-client/tree/master/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers

Notes:

  • For this we will have to make few significant changes to the the framework. One of them is how we address internally custom resources, for now it's by UID. We will have to change this to namespace (optional) and name pair. Since this is how these resources are addressed in informer cache (store). Also this is a more future-proof mechanism, in case we want to implement in future transient caches we would not able to do it with UID, since a resource uid is not indexed (at least for now) in K8S. So in case of a cache miss, reading from api should be based on namespace and name (type we already know based on controller).

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions