How to push a helm chart to Harbor using Helm CLI V3.7.2 and Harbor 2.4.0-d4affc2
Asked Answered
D

3

14

Struggling finding documentation around this that works with specific versions of Harbor and Helm.

Ive tried adding my repo...

Helm repo add harbor https://myharbor.mydomain.com/chartrepo/myproject --username myusername --password mypassword

No issues so far

Then I try to push a chart in the local directory (.tgz file)

Helm push myhelmchart.tgz harbor 

I get an error 'Error: scheme prefix missing from remote (e.g. "oci://")'

If I try

Helm push myhelmchart.tgz oci://harbor 

I get an error 'dial tcp: lookup harbor: no such host'

I tried

helm repo add harbor oci://myharbor.mydomain.com/chartrepo/myproject --username myusername --password 

I get an error 'looks like oci://myharbor.mydomain.com/chartrepo/myproject is not a valid chart repository'

If I just try and push directly and not use a registered repo

helm push myhelmchart.tgz oci://myharbor.mydomain.com/chartrepo/myproject

I get and error 'Error: unexpected status: 401 Unauthorized'

If I login first...

helm registry login myharbor.mydomain.com/chartrepo/myproject
Username: myusername
Password: mypassword
Login Succeeded

The attempt to push again

helm push myhelmchart.tgz oci://myharbor.mydomain.com/chartrepo/myproject

Same error 'Error: unexpected status: 401 Unauthorized'

My goal is to be able to push helm charts into Harbor and have them show up in this area... enter image description here

Dichromatism answered 16/2, 2022 at 16:51 Comment(0)
D
19

There are three options how helm charts can be pushed to Harbor

  1. As you correctly found out yourself, you can install the helm addon chartmuseum/helm-push and use that to push Helm chart to Harbor
  2. You create the Helm Chart locally with helm package and upload the tgz file via the Harbor UI
  3. Since version 3.8 Helm support pushing and pulling Charts from OCI compliant container registries such as Harbor.

To be safe for the future, I recommend you switch to option 3, as Chartmuseum is already marked as deprecated in Harbor.

Here is a quick rundown how to push/pull Helm Chart to OCI compliant Registries

Push Helm Chart to OCI registry:

helm registry login -u user container-registry.com
helm push harbor-1.7.4.tgz oci://container-registry.com/container-registry

Pull and Install Helm Chart from OCI registry:

helm pull oci://container-registry.com/container-registry/harbor --version 1.7.4

This is pulling to tgz file to your current directory. Unlike with the common approach where you would first add a repo and the pull from it in order to be able to install a Chart you can do it all in one go with an OCI registry:

helm install myrelease  oci://container-registry.com/container-registry/harbor --version 1.7.4

Same procedure for template and upgrade

The oci:// protocol is also available in various other subcommands. Here is a complete list:

helm pull
helm show
helm template
helm install
helm upgrade

The Helm documentation has a page with more OCI related examples.

Deckle answered 17/2, 2022 at 16:52 Comment(4)
Thanks for you response, for number 3, if you check my question, this is what I needed help with and could not get to work. I would just get the 401 unauthorized, even after successfully doing the helm registry login command. 2 is irrelevant because if you look at my question I am specifically asking about using the helm CLIDichromatism
if you are using OCI registry chart are stored as images in your project not in the chartrepo. speciall namespace The URL you provided is wrong it should be like this for OCI. oci://myharbor.mydomain.com/project/image --version x.y.zDeckle
also you login to the registry so just keep the domain without the path e.g.helm registry login -u user container-registry.com Deckle
are you using OIDC? If yes, get the CLI token you can't use the password you are using for the IDP. But if you have a successful login, you are doing it right.Deckle
T
10

add harbor repo

helm repo add --username=username --password=xxxx myrepo https://harbor.xxxx.cn/chartrepo/xxxx

create chart

helm create  xxxxxx

lint chart in chart dir

helm lint . 

package chart in chart dir

helm package .

install push plugin

helm plugin install https://github.com/chartmuseum/helm-push

push chart to repo

helm cm-push xxxxxx-0.1.0.tgz myrepo
Tay answered 7/6, 2022 at 11:28 Comment(0)
D
8

Found a solution, it does require a helm plugin but it works!

Download and install the helm-push plugin using the following command:

helm plugin install https://github.com/chartmuseum/helm-push

Ensure you have added your Harbor repo to helm using the following command:

Helm repo add harbor https://myharbor.mydomain.com/chartrepo/myproject --username myusername --password mypassword

Note the /chartrepo in the url, this is important and not well documented but it is required to get the charts to show up under Helm Charts in Harbor

Use the following command to push your chart to Harbor:

Helm cm-push myhelmchart.tgz harbor

Check Harbor project - helm charts

enter image description here

Dichromatism answered 16/2, 2022 at 18:55 Comment(1)
If this is a windows 10 machine you'll probably have to make adjustments to how you run the helm plugin install command. See github.com/chartmuseum/helm-push/issues/24 for solution to run this successfully on windows.Virescent

© 2022 - 2024 — McMap. All rights reserved.