|
| 1 | +# Helm Plugin (`helm/v1-alpha`) |
| 2 | + |
| 3 | +The Helm plugin is an optional plugin that can be used to scaffold a Helm chart, allowing you to distribute the project using Helm. |
| 4 | + |
| 5 | +By default, users can generate a bundle with all the manifests by running the following command: |
| 6 | + |
| 7 | +```bash |
| 8 | +make build-installer IMG=<some-registry>/<project-name:tag> |
| 9 | +``` |
| 10 | + |
| 11 | +This allows the project consumer to install the solution by applying the bundle with: |
| 12 | + |
| 13 | +```bash |
| 14 | +kubectl apply -f https://raw.githubusercontent.com/<org>/project-v4/<tag or branch>/dist/install.yaml |
| 15 | +``` |
| 16 | + |
| 17 | +However, in many scenarios, you might prefer to provide a Helm chart to package your solution. |
| 18 | +If so, you can use this plugin to generate the Helm chart under the `dist` directory. |
| 19 | + |
| 20 | +<aside class="note"> |
| 21 | +<h1>Examples</h1> |
| 22 | + |
| 23 | +You can check the plugin usage by looking at `project-v4-with-plugins` samples |
| 24 | +under the [testdata][testdata] directory on the root directory of the Kubebuilder project. |
| 25 | + |
| 26 | +</aside> |
| 27 | + |
| 28 | +## When to use it |
| 29 | + |
| 30 | +- If you want to provide a Helm chart for users to install and manage your project. |
| 31 | +- If you need to update the Helm chart generated under `dist/chart/` with the latest project changes: |
| 32 | + - After generating new manifests, use the `edit` option to sync the Helm chart. |
| 33 | + - **IMPORTANT:** If you have created a webhook or an API using the [DeployImage][deployImage-plugin] plugin, |
| 34 | + you must run the `edit` command with the `--force` flag to regenerate the Helm chart values based |
| 35 | + on the latest manifests (_after running `make manifests`_) to ensure that the HelmChart values are |
| 36 | + updated accordingly. In this case, if you have customized the files |
| 37 | + under `dist/chart/values.yaml`, and the `templates/manager/manager.yaml`, you will need to manually reapply your customizations on top |
| 38 | + of the latest changes after regenerating the Helm chart. |
| 39 | + |
| 40 | +## How to use it ? |
| 41 | + |
| 42 | +### Basic Usage |
| 43 | + |
| 44 | +The Helm plugin is attached to the `init` subcommand and the `edit` subcommand: |
| 45 | + |
| 46 | +```sh |
| 47 | + |
| 48 | +# Initialize a new project with helm chart |
| 49 | +kubebuilder init --plugins=helm/v1-alpha |
| 50 | + |
| 51 | +# Enable or Update the helm chart via the helm plugin to an existing project |
| 52 | +# Before run the edit command, run `make manifests` to generate the manifest under `config/` |
| 53 | +make manifests |
| 54 | +kubebuilder edit --plugins=helm/v1-alpha |
| 55 | +``` |
| 56 | +<aside class="note"> |
| 57 | + <h1>Use the edit command to update the Helm Chart with the latest changes</h1> |
| 58 | + |
| 59 | + After making changes to your project, ensure that you run `make manifests` and then |
| 60 | + use the command `kubebuilder edit --plugins=helm/v1-alpha` to update the Helm Chart. |
| 61 | + |
| 62 | + Note that the following files will **not** be updated unless you use the `--force` flag: |
| 63 | + |
| 64 | + <pre> |
| 65 | + dist/chart/ |
| 66 | + ├── values.yaml |
| 67 | + └── templates/ |
| 68 | + └── manager/ |
| 69 | + └── manager.yaml |
| 70 | + </pre> |
| 71 | + |
| 72 | + The files `chart/Chart.yaml`, `chart/templates/_helpers.tpl`, and `chart/.helmignore` are never updated |
| 73 | + after their initial creation unless you remove them. |
| 74 | + |
| 75 | +</aside> |
| 76 | + |
| 77 | +## Subcommands |
| 78 | + |
| 79 | +The Helm plugin implements the following subcommands: |
| 80 | + |
| 81 | +- edit (`$ kubebuilder edit [OPTIONS]`) |
| 82 | + |
| 83 | +- init (`$ kubebuilder init [OPTIONS]`) |
| 84 | + |
| 85 | +## Affected files |
| 86 | + |
| 87 | +The following scaffolds will be created or updated by this plugin: |
| 88 | + |
| 89 | +- `dist/chart/*` |
| 90 | + |
| 91 | +[testdata]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/testdata/project-v4-with-plugins |
| 92 | +[deployImage-plugin]: ./deploy-image-plugin-v1-alpha.md |
0 commit comments