kubernetes-sigs / kubebuilder

Kubebuilder - SDK for building Kubernetes APIs using CRDs
http://book.kubebuilder.io
Apache License 2.0
7.9k stars 1.45k forks source link

Document helpers and options to write plugins #2874

Closed camilamacedo86 closed 2 years ago

camilamacedo86 commented 2 years ago

What do you want to happen?

Would be nice if we could add to docs the following info to help those that are looking to build their own plugins:

If you are looking to create an external plugin that will add code on top of what is scaffold by default with the create API see that we do that in deploy-image here and you have many ways to achieve this goal:

Another option also is to use the Bundle Plugin which will build a new plugin done by composition that does the call in chain as we can do by --plugins=a/v1,b/v2 and, see: https://book.kubebuilder.io/plugins/creating-plugins.html

  mylanguagev1Bundle, _ := plugin.NewBundle(language.DefaultNameQualifier, plugin.Version{Number: 1},
        kustomizecommonv1.Plugin{}, // extend the common base from Kuebebuilder
        mylanguagev1.Plugin{}, // your plugin language which will do the scaffolds for the specific language on top of the common base
    )

Motivated by: https://github.com/kubernetes-sigs/kubebuilder/issues/2871

Extra Labels

/kind documentation

camilamacedo86 commented 2 years ago

Hi @Kavinjsir,

This one is to doc how to use the helper and options. You did some docs already, so you might want to look if we can improve the docs for we finish this one.

Kavinjsir commented 2 years ago

Hi @camilamacedo86 , the idea here looks good to me. Since you've already provided rich context above, it looks a great support for me to start. Before moving on, I have some questions:

  1. Where would you like to have the documentation in book? Maybe add a new section in create-your-own-plugin?
  2. Are you suggesting that we may provide two recommended patterns (as you mentioned above) to developers, so that they would create plugins following the ideas without misunderstanding?
  3. Is that the first pattern consists of 3 steps (a -> b -> c) , and, that is to say, creating a new external plugin can be similar as how deploy-image is implemented?
  4. For the another option as you mentioned, is that to instruct developers to create a bundle of plugins chains if necessary; that is to say: apply an integration work between kb plugins and the external one?
Kavinjsir commented 2 years ago

/assign

camilamacedo86 commented 2 years ago

HI @Kavinjsir,

My idea here would to be supplement the docs (I think create-your-own-plugin is a good place for that) to provide the info in the description. So that, we can help out those that are looking to build their own plugins.

See that it was required to help out in the discussion topic linked here.