Introduction
Helm facilitates Kubernetes application deployment and management by introducing the Helm chart, a collection of YAML files describing a related Kubernetes resource set.
Helm charts are stored in chart repositories that are hosted in container registries, either on a local system or online.
In this tutorial, you will learn how to push and pull Helm charts to container registries.
Prerequisites
- Access to a Container Registry
- Helm 3 installed
Note: If you are unsure which version of Helm is running on your system, use the helm version
command to find out.
How to Push a Helm Chart to Registry
Helm 3 supports storing and sharing across Open Container Initiative (OCI) registries. However, the support is still considered experimental, and you need to enable it by setting HELM_EXPERIMENTAL_OCI
variable to 1
.
To do so, type the following in the command line:
export HELM_EXPERIMENTAL_OCI=1
If properly issued, the command returns no output.
1. Create an Example Chart
Create an example Helm chart to make it easier to follow the tutorial.
- First, create a directory for the chart:
mkdir helm-testing
2. Next, move into the directory:
cd helm-testing
3. Use the helm create
command to generate a simple Helm chart:
helm create test-chart
4. Navigate to the templates
directory of the newly created chart:
cd test-chart/templates
5. Remove the contents of the directory:
rm -rf *
6. While in the directory, use a text editor to create a file named configmap.yaml
:
nano configmap.yaml
7. Copy the following contents into the file:
apiVersion: v1
kind: ConfigMap
metadata:
name: test-chart-configmap
data:
myvalue: "This is a test chart"
8. Save and exit the file.
2. Save and Authenticate
- Use the
cd ..
command to navigate back to the main chart directory. Now save the chart locally:
helm chart save . test-chart:v1
2. Also, create a chart alias containing the registry URI. The example uses a registry set up for test purposes at localhost:5000
:
helm chart save . localhost:5000/helm/test-chart:0.1.0
3. List available charts to confirm the success of the previous two steps:
helm chart list
The output shows the saved charts.
4. Now login into the registry using your credentials.
helm registry login -u [username] [registry]
The system prompts you for a password. Type the password and press Enter.
3. Push the Chart to Registry
Use the following command to push your Helm chart to the registry:
helm chart push localhost:5000/helm/test-chart:0.1.0
The output confirms the successful push action and provides additional information about the chart.
Note: To learn the basics of repository management in Helm, read How to Add, Update or Remove a Helm Repo.
How to Pull a Helm Chart
Once you pushed the chart to the registry, you can remove the local version by typing:
helm chart remove localhost:5000/helm/test-chart:0.1.0
Helm removes the chart from the local storage.
To install the chart, pull it from the registry with the helm chart pull
command:
helm chart pull localhost:5000/helm/test-chart:0.1.0
The output confirms that the chart has been downloaded. Export it to a directory by using the export
sub-command and the --destination
flag:
helm chart export localhost:5000/helm/test-chart:0.1.0 \
--destination ./install
As the screenshot above shows, the chart is now exported to the install directory and you can proceed to install it. For more information about the installation process, refer to How to Use the helm install Command.
Conclusion
This tutorial demonstrated Helm 3 commands for creating, saving, pushing, and pulling Helm charts. For more Helm commands designed to manage and deploy charts, read Helm Commands Cheat Sheet.