harbor: Failed to add the chart repo

Expected behavior and actual behavior: Got following error messages when trying to add the chart repo:

Error: looks like "<harbor server>" is not a valid chart repository or cannot be reached: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type repo.IndexFile

Steps to reproduce the problem: helm repo add myrepo <harbor server>

Versions: Please specify the versions of following systems.

  • harbor version: v2.0.2-e91b4ff1

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 6
  • Comments: 36 (2 by maintainers)

Most upvoted comments

With Helm 3.7 deprecating helm chart commands, this hotfix no longer works. I am desperately searching for any way to push and pull charts with Harbor and Helm 3.7.

@will-beta I read the harbor doc, and find that the command helm repo add is wrong,we should use the commands as below :

helm registry login  xx.xx.xx.xx
helm chart save dummy-chart xx.xx.xx.xx/library/dummy-chart
helm chart push xx.xx.xx.xx/library/dummy-chart:version

from office doc, you can search OCI-Compatible words, you will find it.

I try this without chartmuseum and notary service, and it works well.

The only thing to note that the OCI Helm Charts only support https when push harts. helm/helm#6324.

If you use Self-signed certificate , you can append your ca file to /etc/pki/tls/certs/ca-bundle.crt(for centos), use command like : cat self-signed.ca >>/etc/pki/tls/certs/ca-bundle.crt. and there is no options for helm chart push to add your own ca certificate.

I can login with Docker and pull images just fine. But when trying to add the repo, I see the following (even if I try oci:// or no https://)

helm repo add mychart https://harbor.company.com/myproject/mychart

Error: looks like “https://harbor.company.com/myproject/mychart” is not a valid chart repository or cannot be reached: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type repo.IndexFile

Simply pulling the chart by absolute path gives the same error. helm pull mychart https://harbor.company.com/myproject/mychart

I can have people downgrade their Helm installation to deal with this, but it’s not a great longterm solution.

I’m seeing the same thing. I can login and push a chart but can’t pull that chart. Error: looks like "https://myharborinstance.us/helm" is not a valid chart repository or cannot be reached: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type repo.IndexFile

@will-beta I read the harbor doc, and find that the command helm repo add is wrong,we should use the commands as below :

helm registry login  xx.xx.xx.xx
helm chart save dummy-chart xx.xx.xx.xx/library/dummy-chart
helm chart push xx.xx.xx.xx/library/dummy-chart:version

from office doc, you can search OCI-Compatible words, you will find it.

I try this without chartmuseum and notary service, and it works well.

The only thing to note that the OCI Helm Charts only support https when push harts. https://github.com/helm/helm/issues/6324.

If you use Self-signed certificate , you can append your ca file to /etc/pki/tls/certs/ca-bundle.crt(for centos), use command like : cat self-signed.ca >>/etc/pki/tls/certs/ca-bundle.crt.
and there is no options for helm chart push to add your own ca certificate.

I had issues with Helm 3.8 on Harbor 2.2 and while i was able to use helm package ... helm push pulling those pacakges back was a problem till i changed the https:// protocol on my chart depndencies to oci:// as shown;

dependencies
    - name: dymmytest
       version: 1.0
      repository: oci://my.domain/library

This appears to work.

So my full flow is (in gitlab-ci stages)

helm-push:
  image:
    name: alpine/helm:3.8.0
  stage: build
  variables:
    HELM_EXPERIMENTAL_OCI: 1 # For OCI Support on harbor
  script:
    - helm registry login ${OCI_REGISTRY} --username=${OCI_REGISTRY_USER} --password=${OCI_REGISTRY_PASSWORD}
    - helm package my-chart --version=${CI_COMMIT_TAG}
    - helm push my-chart-${CI_COMMIT_TAG}.tgz oci://harbor.mydomain.com/${CI_PROJECT_NAMESPACE}/
  rules:
    - if: $CI_COMMIT_TAG =~ /^(?:\d+.){2}(?:\d+)$/ # semvers only

And then reference it with;

...
dependencies:
- name: my-chart
  version: "0.1.0"
  repository: "oci://harbor.mydomain.com/my-group/"

Thats solve for me, have the same issue.

In my ci/cd workflow i changed the mode for deploy. Instead use helm repo add. I pull the package.

Example: ` - helm registry login https://harbor.url/repository --username admin --password ${{ secrets.HARBOR_PASS }}

  • helm package example --version=1.0.0
  • helm push example-1.0.0.tgz oci://harbor.url/repository/
  • helm pull oci://harbor.url/repository/example --version 1.0.0
  • tar -zxvf example-1.0.0.tgz`

And so i can install or upgrade

I had issues with Helm 3.8 on Harbor 2.2 and while i was able to use helm package ... helm push pulling those pacakges back was a problem till i changed the https:// protocol on my chart depndencies to oci:// as shown;

dependencies
    - name: dymmytest
       version: 1.0
      repository: oci://my.domain/library

This appears to work.

So my full flow is (in gitlab-ci stages)

helm-push:
  image:
    name: alpine/helm:3.8.0
  stage: build
  variables:
    HELM_EXPERIMENTAL_OCI: 1 # For OCI Support on harbor
  script:
    - helm registry login ${OCI_REGISTRY} --username=${OCI_REGISTRY_USER} --password=${OCI_REGISTRY_PASSWORD}
    - helm package my-chart --version=${CI_COMMIT_TAG}
    - helm push my-chart-${CI_COMMIT_TAG}.tgz oci://harbor.mydomain.com/${CI_PROJECT_NAMESPACE}/
  rules:
    - if: $CI_COMMIT_TAG =~ /^(?:\d+.){2}(?:\d+)$/ # semvers only

And then reference it with;

...
dependencies:
- name: my-chart
  version: "0.1.0"
  repository: "oci://harbor.mydomain.com/my-group/"

When will this issue be fixed? We do not want to use helm in version 3.6.x for this to work.