Creating and uploading Helm packages
Manually create and upload Helm packages
Helm packages are just TAR files. Helm repositories are simple file hierarchies with an extra index.yaml. You can run custom commands and manually upload indexes and packages to a Helm repo.
NOTE
This article shows some non-standard Helm examples.
For the basic use cases, or if you are just getting started with Helm, see our Helm quick start guide and Using Helm in pipelines.
Package a Helm chart
Below is an example of a freestyle step in a Codefresh pipeline that packages the Helm chart and then extracts the chart name from the command output. It also saves that package name in an environment variable for later use.
YAML
The helm package
command expects a path to an unpacked chart. Replace <mychart>
in the example with the directory that holds your chart files. Note that this directory must have the same name as the chart name, as per Helm requirements.
See Helm package docs and Helm charts overview for more information.
NOTE
To usecf_export
and make the variable available to other steps in the pipeline, see Variables in pipelines.
Example 1: Push the chart to GCS based Helm Repository
The first example pushes the packaged chart into a public cloud storage service, like AWS S3, Azure Storage, or Google Cloud Storage. We chose Google Cloud Storage (GCS) for this example. Our pipeline has three steps:
- download_index: download the Helm
index.yaml
file from GCS, or create one of it’s not there.
- helm_package_merge: package the chart as described earlier, and also merge the new package into the downloaded
index.yaml
file, using thehelm repo index --merge
command.
- push_gcs: upload the updated
index.yaml
file and the newly created package to GCS.
YAML
Environment setup
This pipeline references some predefined environment variables such as GOOGLE_BUCKET_NAME
, GOOGLE_PROJECT_ID
and GOOGLE_CREDENTIALS
.
For this example, we created a service account with appropriate permissions in Google Cloud, and saved the credentials into GOOGLE_CREDENTIALS
as a Codefresh Secret.
For more information, see:
Authenticating with Google services
Codefresh pipeline configuration and secrets
Example 2: Push the chart to Chart Museum
Chart Museum is a Helm repository server that has an HTTP API, pluggable backends, authentication, and more. Read more about Chart Museum.
In this example, we already have a Chart Museum server running, so we’ll push the packaged chart to it.
The steps will be:
- helm_package: package the chart as described earlier.
- get_repo_url: In order to avoid hard-coding the repository URL into the pipeline, we will retrieve it from the Codefresh Helm integration.
In this case, we have added our repository with Codefresh as described in Using external Helml repos in Codefresh pipelines.
Replace
<reponame>
in the example with the name you gave to your repository when you added it to Codefresh.
- helm_push: call the Chart Museum HTTP api to just upload the package. Chart Museum will take care of the rest.
YAML
Related articles
Using Helm in a Codefresh pipeline
Using a managed Helm repository
Promoting Helm environments