It seems like you want to:
- Download a Helm chart
- Package (store) it as an artifact
- Include all container images used by that Helm chart
Could you please confirm if you want to:
- Download the Helm chart package (the
.tgz file).
- Extract all container images referenced by the Helm chart (from the values and templates).
- Pull or save those images (e.g.,
docker save) and package them somehow alongside the Helm chart.
Or do you want something else?
Assuming you want to download a Helm chart and save all referenced images as container image tarballs as an artifact, here’s a step-by-step approach:
Steps to Download Helm Chart and Store Images
1. Download the Helm Chart
Use helm pull to download the chart archive:
helm repo add stable https://charts.helm.sh/stable
helm repo update
helm pull stable/mysql --version 8.7.0
# This will download mysql-8.7.0.tgz
You can change stable/mysql and version as needed.
2. Extract Container Images from Chart
Helm charts often specify images in values.yaml. The easiest way to see image references is to:
- Extract the chart
- Inspect
values.yaml or template files to find the images.
For example:
tar zxvf mysql-8.7.0.tgz
cd mysql
grep -r image: .
Alternatively, render the chart with default values to find all container images:
helm template mysql . > output.yaml
grep image: output.yaml
3. Pull the Images
Based on the image references identified (e.g., docker.io/mysql:5.7), pull those images:
docker pull mysql:5.7
If there are multiple images, you can write a script to extract and pull them.
4. Save the Images to Files
Once pulled, save images to tarballs to store as artifacts:
docker save mysql:5.7 -o mysql_5_7.tar
You can save each image in that way.
5. Package All Artifacts
You can package the Helm chart tgz and all image tarballs together into a single archive:
tar czvf helm_and_images.tar.gz mysql-8.7.0.tgz mysql_5_7.tar
Automating the Image Extraction
For automation, there are tools like helm-chart-image-exporter or scripts that parse a Helm chart and extract image references.
Here's a simple approach using helm template + yq (or grep):
helm template mysql stable/mysql | grep image:
Then parse images and docker pull/save.
Example Script (basic)
#!/bin/bash
# Variables
CHART_NAME="stable/mysql"
CHART_VERSION="8.7.0"
# Download Chart
helm pull $CHART_NAME --version $CHART_VERSION
CHART_FILE=$(basename ${CHART_NAME##*/})-$CHART_VERSION.tgz
# Extract images from rendered manifests
IMAGES=$(helm template $CHART_FILE | grep image: | awk '{print $2}' | sort | uniq)
# Pull and save images
for image in $IMAGES; do
echo "Pulling image: $image"
docker pull $image
image_filename=$(echo $image | tr '/:' '_')
docker save $image -o ${image_filename}.tar
done
# Done
echo "Helm chart and images saved."
Let me know if you want me to help generate this script fully, or if your environment is different (e.g., use of another container runtime, or you want to store image references only, etc.).