-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Initial addons via plugin model #943
Initial addons via plugin model #943
Conversation
f9c87d1
to
f96bee5
Compare
/assign @DirectXMan12 I think this is what you had in mind for the plugin model, but wanted to check before it got too far along! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a decent start
minor nit, minor comment inline
shall we move this to an experimental/
branch and iterate a bit (or mark it as experimental some other way?)
pkg/scaffold/v2/gomod.go
Outdated
@@ -42,6 +42,8 @@ module {{ .Repo }} | |||
|
|||
go 1.12 | |||
|
|||
replace sigs.k8s.io/kubebuilder-declarative-pattern => ../../kubebuilder-declarative-pattern |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be here any more, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - removed!
pkg/model/types.go
Outdated
|
||
type File struct { | ||
// Type is an identifier for the class of the generator | ||
Type string `json:"type"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the purpose of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops - just a leftover! Removed!
f96bee5
to
6da11ab
Compare
Thanks for the review @DirectXMan12 . I made the "whoopsie" changes - thanks for spotting them. I also put Still lots to do here, but I really like the more strongly-typed model - I know you said you wanted to rework a lot of the existing generation logic anyway - do you think this approach could help there? In any case, would be great to get this in so we can start e.g. adding tests and getting going on addons! |
1e4038f
to
49679f8
Compare
I thought that we had talked about adding this as an experimental branch to collaborate on and then submit to master? is that not the case and I am misremembering? |
packageName := getPackageName(u) | ||
|
||
m := &model.File{ | ||
Path: filepath.Join("channels", "packages", packageName, exampleManifestVersion, "manifest.yaml"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a design for manifests, channels, packages, etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just what we're discussing in the cluster-addons WG and https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern We're still in development mode, I believe!
|
I think this is throwing off some good changes @jwforres , so I was thinking we could keep it feature-flagged off (so it's not easily availably) but still in a place that people can try out. For example, I think we should look at using the strongly-typed model instead of injecting objects, and whether the existing templating code then becomes simpler. What do you think? And I'm doing an implementation of a plugin at the same time as the plugin model - otherwise the extension interface feels a little abstract... We can also see the problems with it - for example should we combine the controller & api phases so we can actually check that the expected file exists in a plugin? Is there actually any value in a single kubebuilder, vs just having a separate generator CLI .. particularly as we're not really reusing much of the kubebuilder template? I could split it into 2 commits or 2 PRs if that helps, but I am developing them together! |
I think not having a motivating usecase makes things a lot more abstract, so we'll want something to demonstrate. We could do this cross repo, but that makes things super hard in the initial stages. I think the plan is:
Cross-repo iteration is really frustrating to work with, and a demo plugin is a bit too abstract for initial development. That being said, I have a few more thoughts here on the generator/plugin parts. As for feature flag vs experimental branch: feature flag is probably fine, and we've been saying "do this in the plugin framework" on the addon PR for a while now (despite being under the KB umbrella), so I think feature flag is prob fine for the moment. |
I think what was tripping me up is that I didn't see anything obvious that indicated the addon plugin is still under development. Since @DirectXMan12 agrees with doing the feature flag I'm fine with that. Since this isn't going into experimental, can something else indicate the addons plugin is a prototype under development? I think it brings up the general question of how do you guys want to document plugins in this repo. Would something like a README in the plugin/addons folder help describe the goal of the plugin and its current development / support state? Or maybe something under a docs/plugins/addons structure? |
sure, something indicating that it's more of an experiment is fine with me 👍 on more docs too |
We implement the initial plugin model, starting with an in-process implementation that can support out-of-process later. As plugins do not yet form part of the stable interface for kubebuilder, we only enable them when the KUBEBUILDER_ENABLE_PLUGINS env var is set. We implement an initial plugin for addons: `--pattern=addon` creates a controller & resource that follow the style of https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern This style of declarative addon operators is being investigated in the cluster-addons subject, with code at https://github.com/kubernetes-sigs/addon-operators
49679f8
to
722b905
Compare
Added a readme to the plugins folder! The env-var to enable is currently |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me.
and as a real-world use case for driving development of the plugin system. We | ||
don't intend for the plugin system to become an emacs competitor, but it must be | ||
sufficiently flexible to support the various patterns of operators that | ||
kubebuilder will generate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emacs competitor 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see that plugins are per-project rather than (what appears to be) global. This is to say if two projects have unique templates, the same kubebuilder
binary would work properly in both cases by introspecting the templates directory of each project. The templates would naturally be checked in with the project, making reuse automatic.
@briantopping yep, we'd like to have pattern information stored in the project file, it's one of the next things we want to add. Feel free to submit a PR once this merges :-) |
/lgtm as per discussion in the monthly meeting and the discussions on this thread |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12, justinsb The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Plugin model; --pattern=addon flag that generates an addon operator