> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/helm/use-a-local-helm-chart.md).

# Use a local Helm chart

Use a Helm chart installed on the Harness Delegate disk to avoid repeated identical downloads

Harness supports Helm charts stored in a remote Helm Chart Repository, such as ChartMuseum. When you deploy the same Helm chart and version to many clusters or namespaces in parallel, identical downloads can hurt performance.

To support this use case, Harness can use a local chart installed on the Harness Delegate disk. Harness checks for the chart on the local Delegate disk, then downloads from the remote repository only if the chart is not found. Using a local Helm chart eliminates identical downloads and related performance issues.

***

## What you will learn from this topic

* How to meet the [prerequisites](#before-you-begin) for a local Helm chart on the Delegate
* How to [add an installation script](#add-an-installation-script-to-the-delegate-yaml) with `INIT_SCRIPT`
* How to set [`HELM_LOCAL_REPOSITORY`](#add-the-helm-local-repo-environment-variable-to-the-delegate-yaml) on the Delegate
* How to apply the [important notes](#important-notes) for delegate selection, version paths, cleanup, and logs

***

## Before you begin

Confirm the following before you configure a local Helm chart:

* **Helm on the Delegate host**: The Delegate host must have Helm installed. Harness installs Helm with the Delegate automatically unless you removed it. Go to [Supported platforms and technologies](https://developer.harness.io/docs/platform/platform-whats-supported) for default Helm binary details.
* **Helm deployment context**: This topic assumes a Kubernetes or Native Helm deployment that already uses a Helm chart. Go to [Helm chart deployment tutorial](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/helm/helm-cd-quickstart.md), [Native Helm deployment tutorial](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/helm/native-helm-quickstart.md), and [Deploy Helm charts](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/helm/deploy-helm-charts.md) for background.
* **Delegate YAML access**: You need access to edit the Delegate StatefulSet (legacy Delegate) or Deployment (immutable Delegate image) manifest.

***

## Add an installation script to the Delegate YAML

Perform the following steps to install the chart on the Delegate host:

1. Install the chart on the Delegate host. You can install it manually, or use the `INIT_SCRIPT` environment variable in the Delegate YAML (recommended).
2. Add the `INIT_SCRIPT` environment variable to the StatefulSet (legacy Delegate) or Deployment (immutable Delegate image) object in the Delegate YAML, and add your Helm chart installation script.

Go to [Build custom Delegate images with third-party tools](https://developer.harness.io/docs/platform/delegates/install-delegates/build-custom-delegate-images-with-third-party-tools) to configure `INIT_SCRIPT`.

Go to the Helm documentation for [Helm Install](https://helm.sh/docs/helm/helm_install/) for chart installation commands.

***

## Add the Helm local repo environment variable to the Delegate YAML

Provide the path to the local chart in the Delegate YAML using the `HELM_LOCAL_REPOSITORY` environment variable.

Perform the following steps to set the path:

1. Add the `HELM_LOCAL_REPOSITORY` environment variable to the StatefulSet (legacy Delegate) or Deployment (immutable Delegate image) object in the Delegate YAML.

Use this path format:

`<basePath>/<repoName(encoded)>/<chartName>/<version>/chartName/`

The following example sets a full chart path:

```yaml
        env:
        - name: HELM_LOCAL_REPOSITORY
          value: "./repository/helm/source/69434bd8-4b9d-37d8-a61f-63df65cd8206/nginx/0.1.0/nginx"
```

If the chart version is not included, Harness fetches the `latest` version.

The `HELM_LOCAL_REPOSITORY` environment variable is the same for both Delegate types.

You can also set `value` to a base path. For example:

```yaml
       env:
        - name: HELM_LOCAL_REPOSITORY
          value: "/opt"
```

***

## Important notes

Review the following notes when you use a local Helm chart.

<details>

<summary>Use the same Delegate for fetching the chart and for deployment steps</summary>

Chart fetching and deployment run in the same step. For example, in a Kubernetes Rolling deployment strategy, the Rolling step performs both.

You can select a Delegate for a step in the step **Advanced** settings, under **Delegate Selector**.

![Delegate Selector in step Advanced settings](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-676e68f42e4814635a6fc7d703b420d2edcdcea8%2Fuse-a-local-helm-chart-00.png?alt=media)

Ensure that the Delegate selected here is the same Delegate that has the local Helm chart installed and the updated Delegate YAML.

</details>

<details>

<summary>Version selection</summary>

If the chart version is left blank, Harness fetches the latest chart on the first deployment. On later runs, Harness checks whether the chart is present in the location specified with this format:

`<basePath>/<repoName(encoded)>/<chartName>/latest/chartName/`

</details>

<details>

<summary>Delegate local disk cleanup</summary>

If you use a local Helm chart, Harness does not clean up the downloaded files after deployment. You must perform any Delegate local disk cleanup yourself.

</details>

<details>

<summary>Logs</summary>

Local and remote Helm chart logs differ slightly. For example, if Harness does not find the chart on the local Delegate disk at first deployment, the logs include `Did not find the chart and version in local repo`:

![Pipeline logs showing chart not found in local repo](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-cfa435a43a7aaf50b059f4b48bc9ffefb4cd8129%2Fuse-a-local-helm-chart-01.png?alt=media)

When Harness finds the charts, the logs show `Found the chart at local repo at path`.

</details>

***

## Next steps

* [Helm chart deployment tutorial](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/helm/helm-cd-quickstart.md): Deploy with a Helm chart in a Kubernetes pipeline.
* [Native Helm deployment tutorial](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/helm/native-helm-quickstart.md): Deploy with Native Helm.
* [Deploy Helm charts](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/helm/deploy-helm-charts.md): Review Helm chart deployment options in Harness.

{% @harness-feedback/feedback %}
