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

Initial addons via plugin model #943

Merged
merged 1 commit into from
Sep 16, 2019

Conversation

justinsb
Copy link
Contributor

@justinsb justinsb commented Aug 15, 2019

Plugin model; --pattern=addon flag that generates an addon operator

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

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 15, 2019
@justinsb justinsb force-pushed the plugin_addon_pattern branch 2 times, most recently from f9c87d1 to f96bee5 Compare August 15, 2019 14:55
@justinsb
Copy link
Contributor Author

/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!

Copy link
Contributor

@DirectXMan12 DirectXMan12 left a 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?)

@@ -42,6 +42,8 @@ module {{ .Repo }}

go 1.12

replace sigs.k8s.io/kubebuilder-declarative-pattern => ../../kubebuilder-declarative-pattern
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - removed!


type File struct {
// Type is an identifier for the class of the generator
Type string `json:"type"`
Copy link
Contributor

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?

Copy link
Contributor Author

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!

@justinsb justinsb changed the title WIP: Addons via plugin model Initial addons via plugin model Aug 20, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 20, 2019
@justinsb
Copy link
Contributor Author

justinsb commented Aug 20, 2019

Thanks for the review @DirectXMan12 . I made the "whoopsie" changes - thanks for spotting them. I also put --pattern=addon behind a (currently undocumented) feature flag KUBEBUILDER_ENABLE_PLUGINS - does that work?

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!

@justinsb justinsb force-pushed the plugin_addon_pattern branch 2 times, most recently from 1e4038f to 49679f8 Compare August 20, 2019 13:52
@shawn-hurley
Copy link

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?

@DirectXMan12

packageName := getPackageName(u)

m := &model.File{
Path: filepath.Join("channels", "packages", packageName, exampleManifestVersion, "manifest.yaml"),

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?

Copy link
Contributor Author

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!

@jwforres
Copy link

  1. I agree with @DirectXMan12 that this should be going to the experimental branch for kubebuilder.

  2. I think this PR is overloading two sets of changes, one set of changes to introduce plugins generally, and one set of changes to propose an experimental concept for an addons plugin

@justinsb
Copy link
Contributor Author

justinsb commented Aug 20, 2019

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!

@DirectXMan12
Copy link
Contributor

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:

  • Do this, make sure it works fine, and that we're good with the interface
  • Add exec, make sure that works with OSDK
  • Split the addon stuff back into exec in kubebuilder-declarative-pattern again

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.

@jwforres
Copy link

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?

@DirectXMan12
Copy link
Contributor

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
@justinsb
Copy link
Contributor Author

Added a readme to the plugins folder! The env-var to enable is currently KUBEBUILDER_ENABLE_PLUGINS but we could rename that to KUBEBUILDER_ENABLE_EXPERIMENTAL_PLUGINS if anyone is worried.

Copy link
Contributor

@droot droot left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

emacs competitor 😆

Copy link

@briantopping briantopping left a 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.

@DirectXMan12
Copy link
Contributor

@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 :-)

@DirectXMan12
Copy link
Contributor

/lgtm
/approve

as per discussion in the monthly meeting and the discussions on this thread

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 16, 2019
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 16, 2019
@k8s-ci-robot k8s-ci-robot merged commit fd0aab7 into kubernetes-sigs:master Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants