ARTIFACTORY: How to fix Helm remote repository not caching Helm charts

ARTIFACTORY: How to fix Helm remote repository not caching Helm charts

AuthorFullName__c
Shisiya Sebastian
articleNumber
000005697
FirstPublishedDate
2023-04-27T15:31:22Z
lastModifiedDate
2025-08-26
VersionNumber
6

In this article, we will find the various cases where Helm Charts are not getting cached and their solutions. 


Causes for not caching helm charts
  1. Helm Charts are directly fetched using the Remote repository instead of virtual.
  2. Virtual repository is used, but the base URL where index.yaml is stored and download URL where Charts are stored are different. And the “Chart Base URL” is not set to the download URL path.
  3. Chart Base URL is set, but there are multiple download URLs

Solutions
For case 1:

In order for Artifactory to properly cache Helm charts, resolve the charts only through a virtual repository. That means, if we directly pull via the remote repository, it will not be cached for helm type. We need to pull via virtual repository in which the above remote repository is added.  Whenever a remote repository is added to a virtual repository, it will either rewrite the URL or Charts Base URL (if specified). Hence, the index.yaml generated under virtual repository will have the download URL pointing to the Artifactory URL. Thus, when a Chart is fetched, request goes through the Artifactory and caches there.


For case 2:

While configuring a Helm remote repository, it is important to note the below: 

  • The repository URL should point to the root path where the index.yaml is found. 
  • The  "Chart Base URL" should point to the path where the charts are stored. 

Artifactory by default rewrites the upstream “URL” specified while generating the metadata for virtual repository. However, when the Charts are stored in a different path, and no Chart Base URL is specified, metadata won’t rewrite the download path with the Artifactory URL. Thus, Charts are fetched directly from the upstream, not via Artifactory, and hence Charts won’t get cached.


For case 3:

The issue mainly occurs when charts from the provider have more than one download URLs for its Charts. The Artifactory will either rewrite the URL or Charts Base URL (if specified). It won’t support rewriting multiple URLs. For this reason, the Charts stored in the path other than the one specified as the Charts Base URL, will not get cached. 

However, in order to support such Charts, Artifactory provides a work around. You can enable external dependency in the remote Repository, and then all the dependency package requests will go through the Artifactory URL. Thus it solves the problem with the caching as well. 


Sample Case

Chart: opensearch-operator 
Repo : https://opster.github.io/opensearch-k8s-operator-chart/
Index.yaml : https://opensearch-project.github.io/opensearch-k8s-operator/index.yaml

From the index.yaml, you will see that Charts are stored in two different locations. The versions of the opensearch-operator from 2.1.1 are located at https://github.com/opensearch-project/opensearch-k8s-operator/ . And all the previous versions are at the location "https://github.com/opensearch-project/opensearch-k8s-operator/releases/download/".

User-added image


Hence, the Helm repository should be configured as follows in the Artifactory.

1. Create a new Helm Remote repository
URL : https://opensearch-project.github.io/opensearch-k8s-operator/
Chart Base URL : https://opensearch-project.github.io/opensearch-k8s-operator/
Click on advanced tab and Enable the option “External Dependency Rewrite” and allow the pattern “https://github.com/**”.
2. Add the new remote repository to a virtual repository, here ‘helm-release’
3. Go to UI → Application → Artifacts → <helm virtual repo name> → download index.yaml and verify whether all the external URLs are rewritten by the Artifactory URLs
4. Add the Virtual repository to the Helm client
helm repo add helm-release https://localhost:443/artifactory/api/helm/helm-release --username <username> --password <encoded_password>
5. Perform the below commands to update the metadata and fetch the Charts.
helm repo update
helm search repo helm-release --versions
helm fetch helm-release/opensearch-operator
helm fetch helm-release/opensearch-operator --version 1.0.3 (if you want to download a specific version)
You will be able to find them cached in your virtual repository cache. The packages with different download URL than Chart base URL specified, here for Example version: 1.0.3, the URL rewriting is done via the external dependency option we enabled. You can find those under the “external” folder with the path similar to the download URL path.

 

Configuration Snippets

Remote Repo configuration:
User-added imageUser-added image

Index.yaml snippet:

User-added image


Cached Artifacts:
User-added image


Reference: 
https://jfrog.com/help/r/jfrog-artifactory-documentation/kubernetes-helm-chart-repositories