Dev > CaaS > Kubernetes > Helm
Dec 11, 2024
Dec 11, 2024
N/A Views
MD

Warning

This article was automatically translated by OpenAI (gpt-4o-mini).It may be edited eventually, but please be aware that it may contain incorrect information at this time.

This is a note on relocating Helm Charts along with their images.

We will use the Helm plugin "Distribution Tooling for Helm".

I tested it with the following Helm version.

$ helm version
version.BuildInfo{Version:"v3.16.3", GitCommit:"cfd07493f46efc9debd9cc1b02a0961186df7fdf", GitTreeState:"dirty", GoVersion:"go1.23.3"}

Install "Distribution Tooling for Helm".

helm plugin install https://github.com/vmware-labs/distribution-tooling-for-helm

I tested it with the following version.

$ helm dt version
Distribution Tooling for Helm v0.4.3
Built on: 2024-09-17T09:13:12Z

You can package an existing Helm Chart, including images, into a tar.gz file using the helm dt wrap command. The command arguments are as follows.

helm dt wrap CHART_PATH|OCI_URI [flags]

As an example, I would like to relocate https://github.com/bitnami/charts/tree/contour/19.3.2/bitnami/contour to GHCR.

Note

To relocate the images, you need to enumerate the definitions of image in the annotations of Chart.yaml as shown in https://github.com/vmware-labs/distribution-tooling-for-helm?tab=readme-ov-file#creating-an-images-lock. The Bitnami Helm Chart has this annotation set.

Specify version 19.3.2 and compress it into a tar.gz file.

helm dt wrap oci://registry-1.docker.io/bitnamicharts/contour --version 19.3.2

The following log will be output.

 »  Wrapping Helm chart "oci://registry-1.docker.io/bitnamicharts/contour"
    ✔  Helm chart downloaded to "/var/folders/6m/jnyp8461431g15qf217pmth40000gn/T/chart-2060331826/chart-4156122159/contour"                                                                                                                                   
    ✔  Images.lock file written to "/var/folders/6m/jnyp8461431g15qf217pmth40000gn/T/chart-2060331826/wrap/chart/Images.lock"                                                                                                                                  
    »  Pulling images into "/var/folders/6m/jnyp8461431g15qf217pmth40000gn/T/chart-2060331826/wrap/images"
       ✔  All images pulled successfully                                                                                                                                                                                                                       
    ✔  Compressed into "/tmp/contour-19.3.2.wrap.tgz"                                                                                                                                                                                                          
    
 🎉  Helm chart wrapped into "/tmp/contour-19.3.2.wrap.tgz"

The file size is large because it contains images.

$ ls -lh contour-19.3.2.wrap.tgz
-rw-r--r--  1 toshiaki  wheel   377M 12 11 10:08 contour-19.3.2.wrap.tgz

You can check the contents of the packaged Chart with the helm dt info command.

$ helm dt info contour-19.3.2.wrap.tgz 
 »  Wrap Information
       Chart: contour
       Version: 19.3.2
       App Version: 1.30.1
    »  Metadata
          - generatedBy: Distribution Tooling for Helm
          - generatedAt: 2024-12-11T01:08:06.006607Z
    »  Images
          docker.io/bitnami/contour:1.30.1-debian-12-r3 (linux/amd64, linux/arm64)
          docker.io/bitnami/envoy:1.31.3-debian-12-r1 (linux/amd64, linux/arm64)
          docker.io/bitnami/nginx:1.27.3-debian-12-r0 (linux/amd64, linux/arm64)

If you want to relocate it to an air-gapped environment, you can copy this tar.gz file using a USB memory or something similar.

Now, let's relocate this to GHCR. First, log in to GHCR.

docker login ghcr.io

Relocate using the helm dt unwrap command.

helm dt unwrap contour-19.3.2.wrap.tgz ghcr.io/making/bitnamicharts --yes

The following log will be output.

 »  Unwrapping Helm chart "contour-19.3.2.wrap.tgz"
    ✔  Helm chart uncompressed to "/var/folders/6m/jnyp8461431g15qf217pmth40000gn/T/chart-302831319/dt-wrap1453374076"                                                                                                                                         
    ✔  Helm chart relocated successfully                                                                                                                                                                                                                       
    »  The wrap includes the following 3 images:

       ghcr.io/making/bitnamicharts/bitnami/contour:1.30.1-debian-12-r3
       ghcr.io/making/bitnamicharts/bitnami/envoy:1.31.3-debian-12-r1
       ghcr.io/making/bitnamicharts/bitnami/nginx:1.27.3-debian-12-r0
       
    »  Pushing Images
       ✔  All images pushed successfully                                                                                                                                                                                                                       
       ✔  Chart "/var/folders/6m/jnyp8461431g15qf217pmth40000gn/T/chart-302831319/dt-wrap1453374076/chart" lock is valid                                                                                                                                       
       
    ✔  Helm chart successfully pushed                                                                                                                                                                                                                          
    
 🎉  Helm chart unwrapped successfully: You can use it now by running "helm install oci://ghcr.io/making/bitnamicharts/contour --generate-name"

When generating YAML using the relocated Chart, you can see that the image has changed to GHCR.

$ helm template contour oci://ghcr.io/making/bitnamicharts/contour --version 19.3.2 2>/dev/null | grep 'image: '
          image: ghcr.io/making/bitnamicharts/bitnami/contour:1.30.1-debian-12-r3
          image: ghcr.io/making/bitnamicharts/bitnami/envoy:1.31.3-debian-12-r1
          image: ghcr.io/making/bitnamicharts/bitnami/contour:1.30.1-debian-12-r3
          image: ghcr.io/making/bitnamicharts/bitnami/contour:1.30.1-debian-12-r3
          image: ghcr.io/making/bitnamicharts/bitnami/contour:1.30.1-debian-12-r3

The images relocated this time have been made public, so you can check them from the following link.

https://github.com/making?tab=packages&tab=packages&q=bitnamicharts

Found a mistake? Update the entry.
Share this article: