Skip to content

Add dynamic provider that accepts GVKs instead of types#81

Open
ntnn wants to merge 2 commits intokcp-dev:mainfrom
ntnn:dynamic-provider
Open

Add dynamic provider that accepts GVKs instead of types#81
ntnn wants to merge 2 commits intokcp-dev:mainfrom
ntnn:dynamic-provider

Conversation

@ntnn
Copy link
Copy Markdown
Member

@ntnn ntnn commented Feb 10, 2026

Summary

  1. dynamic provider, a coal copy of apiexport but based off of GVKs being passed in instead of diskrete types
  2. kcp-endpointslice-watcher utilizing the dynamic provider for debugging:
image

Used spew for the utility, though that moved the dep in the go.mod; we could make the utility its own go.mod [and we should check what exactly has spew in its dependencies, that feels like an error].

Overall idea for the provider is if this can be useful to help with either generic APIs and/or polymorphism, the utility is just a handy thing on top e.g. for the FilteredAPIExportWS

What Type of PR Is This?

/kind feature

Related Issue(s)

Fixes #

Release Notes

NONE

@kcp-ci-bot kcp-ci-bot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. dco-signoff: yes Indicates the PR's author has signed the DCO. labels Feb 10, 2026
@kcp-ci-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign sttts for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kcp-ci-bot kcp-ci-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 10, 2026

type logger struct{}

func (logger) OnAdd(obj client.Object) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dio we want to keep this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, but I would make it a separate module.

Comment thread dynamic/provider.go

type logger struct{}

func (logger) OnAdd(obj client.Object) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, but I would make it a separate module.

Comment thread dynamic/provider.go Outdated
Comment thread dynamic/provider.go Outdated
Comment thread test/e2e/apiexport_test.go Outdated
ntnn added 2 commits February 16, 2026 09:38
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
@kcp-ci-bot kcp-ci-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 16, 2026
func (logger) OnAdd(obj client.Object) {
log.Printf("add %q in namespace %q", obj.GetName(), obj.GetNamespace())
if *fDumpObjects {
spew.Dump(obj)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What made you choose spew over something, dare I say, more common/re-usable like YAML? Personally I find spew super helpful, but also extremely hard to read.

This cmd feels like a multi-cluster stalk 😁 if I may drop some self-advertisement.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly wanted to have it printed in some way :D I don't care about the specifics.
It's very close yeah, this is tailored to watch resources in control planes linked from the *EndpointSlice resources; we could move this into a "flavoured" version of stalk?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I don't wnt to block your progress here and sneak it another one of my shitty little tools into "official workflows" 😁
  2. I'm not yet sure how much kcp integration a random external Kube tool should have for this. Technically if you provide stalk (or any other tool) with a kubeconfig that already points to the wildcard endpoint / apiexport VW, it should already be able to just watch EndpointSlices. I guess the object key logic would need to be extended to include cluster (i.e. (cluster,namespace,name)), but beyond that, how much should be built into third-party tools? What would we like?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well @mjudeikis had PR'd kcp support to the kube mcp server, I'd see that in a similar fashion :D
But we can also try and use stalk as a library and have kcp-apiexport-watcher use it to display changes; I don't mind either way. I just would like a tool that I can point at a *EndpointSlice and follow the changes^^

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I think we can scrap the dynamic for now and just update the apiexport provider to also expose the cached object - this was just the quickest way to enable something supporting any kind of *EndpointSlice

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's forget about stalk, I never mentioned it. But can we replace spew with yaml.NewEncoder ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, lets not start pulling 3rd party libs (even if they are our own), when we can just copy 100LOC and have no dependency.

Is this logger even used? Or is it supposed to be debugLogger/developmentLogger? If so, can we rename it so it's easier to reason why it's dumping full objects into stdot (including potentially secrets).

@ntnn ntnn moved this to In review in tbd Apr 14, 2026
@ntnn ntnn added this to tbd Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. kind/feature Categorizes issue or PR as related to a new feature. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants