Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow resourceVersion to be specified when creating a watcher #1419

Open
thedodd opened this issue Mar 6, 2024 · 1 comment
Open

Allow resourceVersion to be specified when creating a watcher #1419

thedodd opened this issue Mar 6, 2024 · 1 comment

Comments

@thedodd
Copy link

thedodd commented Mar 6, 2024

Would you like to work on this feature?

maybe

What problem are you trying to solve?

I would like to be able to specify an initial value for resourceVersion when building a kube::runtime::watcher::watcher(..).

Use case: watch various resources (pods, events, &c) and sync them to Kafka. Use the bookmarks to establish a stable restart point when application restarts.

Describe the solution you'd like

I would like to be able to specify a previously returned resourceVersion from the K8s API to establish a starting location for watcher streams.

This framework is already utilizing this feature internally. I would like to be able to provide the initial state for this value in order to achieve this objective.

Describe alternatives you've considered

N/A

Documentation, Adoption, Migration Strategy

As can be seen in the K8s documentation here, the K8s API maybe be called via: GET /api/v1/namespaces/default/pods?watch=1&resourceVersion=987654&allowWatchBookmarks=true. This framework is already using this feature, but the starting value for resourceVersion is not exposed.

Target crate for feature

kube-runtime

@clux
Copy link
Member

clux commented Mar 6, 2024

hm, while you could possibly use watch bookmarks for this type of bookkeeping (at least the KEP for bookmarks intends them for this), the watcher in kube is designed for the long-lived controller/reflector use case, where you keep the full set of what you need in memory, rather than some partial watch state. Partial watch state is generally not something we want to pass around because we want controllers to always have complete state available when ready (so allowing them to start with partial state is a footgun to us).

If your use case is mainly to avoid duplicating uploads, then you could consider trying to run an Api::watch directly with WatchParams::streaming_lists (say) and do the book-keeping from that. Have never tried to rely on bookmarks myself like this, but I expect that will be an easier approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants