|
| 1 | +# Declarative Plugin |
| 2 | + |
| 3 | +The declarative plugin allows you to create [controllers][controller-runtime] using the [kubebuilder-declarative-pattern][kubebuilder-declarative-pattern]. |
| 4 | +By using the declarative plugin, you can make the required changes on top of what is scaffolded by default when you create a Go project with Kubebuilder and the Golang plugins (i.e. go/v2, go/v3). |
| 5 | + |
| 6 | +<aside class="note"> |
| 7 | +<h1>Examples</h1> |
| 8 | + |
| 9 | +You can check samples using this plugin by looking at the "addon" samples inside the [testdata][testdata] directory of the Kubebuilder project. |
| 10 | + |
| 11 | +</aside> |
| 12 | + |
| 13 | + |
| 14 | +## When to use it |
| 15 | + |
| 16 | +- If you are looking to scaffold one or more [controllers][controller-runtime] following [the pattern][kubebuilder-declarative-pattern] ( See an e.g. of the reconcile method implemented [here][addon-v3-controller]) |
| 17 | +- If you want to have manifests shipped inside your Manager container. The declarative plugin works with channels, which allow you to push manifests. [More info][addon-channels-info] |
| 18 | + |
| 19 | +## How to use it |
| 20 | + |
| 21 | +The declarative plugin requires to be used with one of the available Golang plugins |
| 22 | +If you want that any API(s) and its respective controller(s) generate to reconcile them of your project adopt this partner then: |
| 23 | + |
| 24 | +```sh |
| 25 | +kubebuilder init --plugins=go/v3,declarative/v1 --domain example.org --repo example.org/guestbook-operator |
| 26 | +``` |
| 27 | + |
| 28 | +If you want to adopt this pattern for specific API(s) and its respective controller(s) (not for any API/controller scaffold using Kubebuilder CLI) then: |
| 29 | + |
| 30 | +```sh |
| 31 | +kubebuilder create api --plugins=go/v3,declarative/v1 --version v1 --kind Guestbook |
| 32 | +``` |
| 33 | + |
| 34 | +## Subcommands |
| 35 | + |
| 36 | +The declarative plugin implements the following subcommands: |
| 37 | + |
| 38 | +* init (`$ kubebuilder init [OPTIONS]`) |
| 39 | +* create api (`$ kubebuilder create api [OPTIONS]`) |
| 40 | + |
| 41 | +## Affected files |
| 42 | + |
| 43 | +The following scaffolds will be created or updated by this plugin: |
| 44 | + |
| 45 | +* `controllers/*_controller.go` |
| 46 | +* `api/*_types.go` |
| 47 | +* `channels/packages/<packagename>/<version>/manifest.yaml` |
| 48 | +* `channels/stable` |
| 49 | +* `Dockerfile` |
| 50 | + |
| 51 | +## Further ressources |
| 52 | + |
| 53 | +* Read more about the [declarative pattern][kubebuilder-declarative-pattern] |
| 54 | +* Watch the KubeCon 2018 Video [Managing Addons with Operators][kubecon-video] |
| 55 | +* Check the [plugin implementation][plugin-implementation] |
| 56 | + |
| 57 | +[dockerfile-addon]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v3-addon/Dockerfile#L16-L19 |
| 58 | +[addon-channels-info]: https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/blob/master/docs/addon/walkthrough/README.md#adding-a-manifest |
| 59 | +[controller-runtime]: https://github.com/kubernetes-sigs/controller-runtime |
| 60 | +[kubebuilder-declarative-pattern]: https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern |
| 61 | +[testdata]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/testdata/ |
| 62 | +[kubecon-video]: https://www.youtube.com/watch?v=LPejvfBR5_w |
| 63 | +[plugin-implementation]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/pkg/plugins/golang/declarative |
| 64 | +[addon-v3-controller]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/testdata/project-v3-addon |
0 commit comments