|
| 1 | +# Deploy Image Plugin (deploy-image/v1-alpha) |
| 2 | + |
| 3 | +The deploy-image plugin allows users to create [controllers][controller-runtime] and custom resources which will deploy and manage an image on the cluster following |
| 4 | +the guidelines and best practices. It abstracts the complexities to achieve this goal while allowing users to improve and customize their projects. |
| 5 | + |
| 6 | +<aside class="note"> |
| 7 | +<h1>Examples</h1> |
| 8 | + |
| 9 | +See the "project-v3-with-deploy-image" directory under the [testdata][testdata] directory of the Kubebuilder project to check an example of a scaffolding created using this plugin. |
| 10 | + |
| 11 | +</aside> |
| 12 | + |
| 13 | +## When to use it ? |
| 14 | + |
| 15 | +- This plugin is helpful for beginners who are getting started with scaffolding and using operators. |
| 16 | +- If you are looking to Deploy and Manage an image (Operand) using [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/) and the tool the plugin will create an API/controller to be reconciled to achieve this goal |
| 17 | + |
| 18 | +## How to use it ? |
| 19 | + |
| 20 | +After you create a new project with `kubebuilder init` you can create APIs using this plugin. Ensure that you have followed the [quick start](https://book.kubebuilder.io/quick-start.html) before trying to use it. |
| 21 | + |
| 22 | +Then, by using this plugin you can [create APIs](https://book.kubebuilder.io/cronjob-tutorial/gvks.html) informing the image (Operand) that you would like to deploy on the cluster. Note that you can optionally specify the command that could be used to initialize this container via the flag `--image-container-command` and the port with `--image-container-port` flag. You can also specify the `RunAsUser` value for the Security Context of the container via the flag `--run-as-user`., i.e: |
| 23 | + |
| 24 | +```sh |
| 25 | +kubebuilder create api --group example.com --version v1alpha1 --kind Memcached --image=memcached:1.6.15-alpine --image-container-command="memcached,-m=64,modern,-v" --image-container-port="11211" --run-as-user="1001" --plugins="deploy-image/v1-alpha" |
| 26 | +``` |
| 27 | + |
| 28 | +## Subcommands |
| 29 | + |
| 30 | +The deploy-image plugin implements the following subcommands: |
| 31 | + |
| 32 | +- create api (`$ kubebuilder create api [OPTIONS]`) |
| 33 | + |
| 34 | +## Affected files |
| 35 | + |
| 36 | +With the `create api` command of this plugin, in addition to the existing scaffolding, the following files are affected: |
| 37 | + |
| 38 | +**When multigroup is not enabled** |
| 39 | + |
| 40 | +- `controllers/*_controller.go` |
| 41 | +- `controllers/*_suite_test.go` |
| 42 | +- `api/<version>/*_types.go` (scaffold the specs for the new api) |
| 43 | +- `config/samples/*_.yaml` (scaffold default values for its CR) |
| 44 | + |
| 45 | +**When multigroup is enabled** |
| 46 | + |
| 47 | +- `controllers/<group>/*_controller.go` |
| 48 | +- `controllers/<group>/*_suite_test.go` |
| 49 | +- `apis/<group>/<version>/*_types.go` (scaffold the specs for the new api) |
| 50 | +- `config/samples/*_.yaml` (scaffold default values for its CR) |
| 51 | + |
| 52 | +[controller-runtime]: https://github.com/kubernetes-sigs/controller-runtime |
| 53 | +[testdata]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/testdata/ |
0 commit comments