In this post you will learn how to setup authentication from a dev environment to access the GCP Artifact Registry to push / pull Helm packages.
What you’ll need:
- Gcloud installation
- a GCP account with adequate permissions to push / pull from Artifact Registry
- GCP Artifact Registry repo setup
- Helm installation
For reference:
https://cloud.google.com/artifact-registry/docs/helm/store-helm-charts
Configure authentication:
In this example we’re going to setup authentication so we can access GCP Artifact Registry in the ‘us-docker.pkg.dev’ location.
gcloud auth application-default login
gcloud auth print-access-token | \
helm registry login -u oauth2accesstoken --password-stdin https://us-docker.pkg.dev
Now, let’s create a sample Helm package.
Helm Package:
Create a default helm chart and give it a name (ie, example-chart) via:
helm create example-chart
For more information about helm, visit their website.
Next, we’re going to create a helm package via:
helm package example-chart
You should see output that looks similar to the following:
Successfully packaged chart and saved it to: /tmp/example-chart-0.1.0.tgz
Notes: The number appended in the name of the package is pulled from the “version” tag in the Chart.yaml file.
Interacting with GCP Artifact Registry:
Push the Package:
The next step is to push the package from your dev instance to GCP Artifact Registry within your project. In my example, I’ve setup a repo called helm-charts.
PROJECT="YOUR_PROJECT"
helm push example-chart-0.1.0.tgz oci://us-docker.pkg.dev/$PROJECT/helm-charts
Note — If you encounter an authentication error, your creds likely expired. Revisit the “Configure Authentication” section covered above.
Next, check the repo location via the portal to see the pushed helm package.
Pull the Package:
To pull the helm package from the GCP Artifact Registry to your local directory, use the following approach. Note that the version is a separate flag.
PROJECT="YOUR_PROJECT"
helm pull oci://us-docker.pkg.dev/$PROJECT/helm-charts/example-chart --version=0.1.0
Now check locally via and you should see the .tgz:
ls -la | grep *.tgz
–untar Option:
If you’d like to automatically untar the compressed file during download, add the –untar flag shown below.
helm pull oci://us-docker.pkg.dev/prj-netl-edx-dev/helm-charts/example-chart \
--version=0.1.0 \
--untar
Acknowledgements:
I’d like to give a Hat Tip to Joe and Joey for various contributions along the way.