|
| 1 | +# Custom charts |
| 2 | + |
| 3 | +Devtron includes predefined helm charts that cover the majority of use cases. |
| 4 | +For any use case not addressed by the default helm charts, you can upload your own helm chart and use it as a custom chart in Devtron. |
| 5 | + |
| 6 | +* Who can upload a custom chart - Super admins |
| 7 | +* Who can use the custom chart - All users |
| 8 | + |
| 9 | +> A super admin can upload multiple versions of a custom helm chart. |
| 10 | +
|
| 11 | + |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | + |
| 15 | +1. A valid [helm chart](#1-how-to-create-a-helm-chart), which contains `Chart.yaml` file with name and version fields. |
| 16 | +2. [Image descriptor template file - `.image_descriptor_template.json`](#2-create-the-image-descriptor-template-file---image_descriptor_templatejson). |
| 17 | +3. [Custom chart packaged in the `*.tgz` format](#3-package-the-custom-chart-in-the-tgz-format). |
| 18 | + |
| 19 | +### 1. How to create a helm chart |
| 20 | + |
| 21 | +`Chart.yaml` is the metadata file that gets created when you create a [helm chart](https://helm.sh/docs/helm/helm_create/). |
| 22 | + |
| 23 | +```bash |
| 24 | +helm create my-custom-chart |
| 25 | +``` |
| 26 | + |
| 27 | +| Field | Description | |
| 28 | +| --- | --- | |
| 29 | +| Name | Required. Name of the helm chart. | |
| 30 | +| Version | Required. This is the chart version. Update this value for each new version of the chart. | |
| 31 | +| Description | Optional. Description of the chart. | |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +### 2. Create the image descriptor template file - `.image_descriptor_template.json` |
| 36 | + |
| 37 | +It's a GO template file that should produce a valid `JSON` file upon rendering. This file is passed as the last argument in |
| 38 | +`helm install -f myvalues.yaml -f override.yaml ` command. |
| 39 | + |
| 40 | +Place the `.image_descriptor_template.json` file in the root directory of your chart. |
| 41 | + |
| 42 | +You can use the following variables in the helm template (all the placeholders are optional): |
| 43 | + |
| 44 | +> The values from the CD deployment pipeline are injected at the placeholder specified in the `.image_descriptor_template.json` template file. |
| 45 | +
|
| 46 | +```bash |
| 47 | +{ |
| 48 | + "server": { |
| 49 | + "deployment": { |
| 50 | + "image_tag": "{{.Tag}}" |
| 51 | + "image": "{{.Name}}" |
| 52 | + } |
| 53 | + }, |
| 54 | + "pipelineName": "{{.PipelineName}}", |
| 55 | + "releaseVersion": "{{.ReleaseVersion}}", |
| 56 | + "deploymentType": "{{.DeploymentType}}", ? |
| 57 | + "app": "{{.App}}", |
| 58 | + "env": "{{.Env}}", |
| 59 | + "appMetrics": { |
| 60 | + {.AppMetrics |
| 61 | + } |
| 62 | + } |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +| Field | Description | |
| 67 | +| --- | --- | |
| 68 | +| **image_tag** | The build image tag | |
| 69 | +| **image** | Repository name | |
| 70 | +| **pipelineName** | The CD pipeline name created in Devtron | |
| 71 | +| **releaseVersion** | Devtron's internal release number | |
| 72 | +| **deploymentType** | Deployment strategy used in the pipeline | |
| 73 | +| **app** | Application's ID within the Devtron ecosystem | |
| 74 | +| **env** | Environment used to deploy the chart | |
| 75 | +| **appMetrics** | For the App metrics UI feature to be effective, include the `appMetrics` placeholder. | |
| 76 | + |
| 77 | +> **For example**: |
| 78 | +> |
| 79 | +> To create a template file to allow Devtron to only render the repository name and the tag from the CI/CD pipeline that you created, edit the `.image_descriptor_template.json` file as: |
| 80 | +> ```bash |
| 81 | +> { |
| 82 | +> "image": { |
| 83 | +> "repository": "{{.Name}}", |
| 84 | +> "tag": "{{.Tag}}" |
| 85 | +> } |
| 86 | +> } |
| 87 | +> ``` |
| 88 | +
|
| 89 | +### 3. Package the custom chart in the `*.tgz` format |
| 90 | +
|
| 91 | +> Before you begin, ensure that your helm chart includes both `Chart.yaml` (with `name` and `version` fields) and `.image_descriptor_template.json` files. |
| 92 | +
|
| 93 | +The helm chart to be uploaded must be packaged as a versioned archive file in the format - `<helm-chart-name>-vx.x.x.tgz`. |
| 94 | +
|
| 95 | +``` |
| 96 | +helm package my-custom-chart |
| 97 | +``` |
| 98 | +
|
| 99 | +The above command will create a `my-custom-chart-0.1.0.tgz` file. |
| 100 | +
|
| 101 | +## Uploading a custom chart |
| 102 | +
|
| 103 | +> A custom chart can only be uploaded by a super admin. |
| 104 | +
|
| 105 | +* On the Devtron dashboard, select **Global Configurations > Custom charts**. |
| 106 | +* Select **Import Chart**. |
| 107 | +* Choose **Select tar.gz file...** and upload the [packaged custom chart](#3-package-the-custom-chart-in-the-tgz-format) in the `*.tgz` format. |
| 108 | +
|
| 109 | + |
| 110 | +
|
| 111 | +The chart is being uploaded and validated. You may also **Cancel upload** if required. |
| 112 | +
|
| 113 | + |
| 114 | +
|
| 115 | +### Validation |
| 116 | +
|
| 117 | +The uploaded archive will be validated against: |
| 118 | +
|
| 119 | +- Supported archive template should be in `*.tgz` format. |
| 120 | +- `Chart.yaml` must include the name and the version number. |
| 121 | +- `image_descriptor_template.json` file should be present and the field format must match the format listed in the [image builder template](#step-2-create-the-image-builder-template-file) section. |
| 122 | +
|
| 123 | +The following are the validation results: |
| 124 | +
|
| 125 | +| Validation status | Description | User action | |
| 126 | +| :--- | :--- | :--- | |
| 127 | +| **Success** | The files uploaded are validated. | Enter a description for the chart and select **Save** or **Cancel upload**. | |
| 128 | +| **Unsupported template** | The archive file do not match the [required template](#prerequisites). | **Upload another chart** or **Cancel upload**. | |
| 129 | +| **New version detected** | You are uploading a newer version of an existing chart | Enter a **Description** and select **Save** to continue uploading, or **Cancel upload**. | |
| 130 | +| **Already exists** | There already exists a chart with the same version. | <ul><li>Edit the version and re-upload the same chart using **Upload another chart**.</li><li>Upload a new chart with a new name using **Upload another chart**.</li><li>**Cancel upload**.</li></ul> | |
| 131 | +
|
| 132 | + |
| 133 | +
|
| 134 | + |
| 135 | +
|
| 136 | + |
| 137 | +
|
| 138 | + |
| 139 | +
|
| 140 | +## View the custom charts |
| 141 | +
|
| 142 | +> All users can view the custom charts. |
| 143 | +
|
| 144 | +To view a list of available custom charts, go to **Global Configurations > Custom charts** page. |
| 145 | +
|
| 146 | +* The charts can be searched with their name, version, or description. |
| 147 | +* New [custom charts can be uploaded](#uploading-a-custom-chart) by selecting **Upload chart**. |
| 148 | +
|
| 149 | + |
| 150 | +
|
| 151 | +## Use the custom chart in an application |
| 152 | +
|
| 153 | +The custom charts can be used from the [Deployment Template](../creating-application/deployment-template.md) section. |
| 154 | +
|
| 155 | +> **Info**: |
| 156 | +> |
| 157 | +> The deployment strategy for a custom chart is fetched from the custom chart template and cannot be configured in the [CD pipeline](../creating-application/workflow/cd-pipeline.md#deployment-strategies). |
0 commit comments