goharbor / harbor

An open source trusted cloud native registry project that stores, signs, and scans content.
https://goharbor.io
Apache License 2.0
24.31k stars 4.77k forks source link

helm v3 push error #9954

Closed wy65701436 closed 4 years ago

wy65701436 commented 5 years ago

I have tried to push a chart to Harbor with helm v3 client, which already has a push plugin installed. But, get the following error:

root@dev:~# helm push --ca-file=/ca.crt --username=admin --password=Harbor12345 /mariadb-4.3.1.tgz myrepo
Error: Couldn't load repositories file (/root/.helm/repository/repositories.yaml).
You might need to run `helm init` (or `helm init --client-only` if tiller is already installed)
Error: plugin "push" exited with error

To workaround it, use the URL to do the helm push.

helm push --ca-file=/ca.crt --username=admin --password=Harbor12345 /mariadb-4.3.1.tgz https://1.1.1.1/chartrepo/library

After that, I can push a chart into Harbor.

root@dev:~# helm version
version.BuildInfo{Version:"v3.0.0", GitCommit:"e29ce2a54e96cd02ccfce88bee4f58bb6e2a28b6", GitTreeState:"clean", GoVersion:"go1.13.4"}
root@dev:~# helm push --ca-file=/ca.crt --username=admin --password=Harbor12345 /mariadb-4.3.1.tgz https://1.1.1.1/chartrepo/library
Pushing mariadb-4.3.1.tgz to https://1.1.1.1/chartrepo/library...
Done.

The issue on the push plugin: https://github.com/chartmuseum/helm-push/issues/37

reasonerjt commented 5 years ago

Root cause seems that the push plugin tries to read repositories.yaml under helm home which no longer exists in helm v3: https://helm.sh/docs/faq/#xdg-base-directory-support

kuaiwenwu commented 5 years ago

这个问题 很简单 可以加入helm的微信交流群 ,需要交流的加我微信 easonak185

ClouDevops101 commented 5 years ago

This is a quickfix until the push pluging comes with support for helm3 You may need to declare your repositories at two different place :

hotfix for push pluging

helm repo add harbor-staging --username=${HARBOR_USER} --password=${HARBOR_PASSWORD} ${HARBOR_HELMCHART_PROJECT} --repository-config=/$HOME/.helm/repository/repositories.yaml with a tiny modification

'sed -i -e "s/apiVersion: ""/apiVersion: v1/g" /$HOME/.helm/repository/repositories.yaml'

add the repos to the standart file

helm repo add harbor-staging --username=${HARBOR_USER} --password=${HARBOR_PASSWORD} ${HARBOR_HELMCHART_PROJECT}

wantdrink commented 5 years ago

Thanks @LinuxArchitects With this workaround I can push chart to my harbor chart repo successfully with:

helm push --ca-file /data/cert/ca.crt mysql-1.4.0.tgz myharborrepo

I still need to specify --ca-file even the repositories.yml contains "- caFile: /data/cert/ca.crt". But after that when I fetch it I got the error again:

helm --ca-file /data/cert/ca.crt --username test --password Test1234! --key-file /data/cert/myharbor.test.com.key --cert-file /data/cert/myharbor.test.com.crt fetch myharborrepo/mysql

Error: Get https://myharbor.test.com/chartrepo/myharborrepo/charts/mysql-1.4.0.tgz: x509: certificate signed by unknown authority

ClouDevops101 commented 5 years ago

You don’t need to specify the certificate unless it’s a self signed one :

Please retry without specifying certificates and send the result :

helm --username test --password Test1234! fetch myharborrepo/mysql

wantdrink commented 5 years ago

@LinuxArchitects ah my local harbor is self singed cert so I have to:)

wy65701436 commented 4 years ago

Per comments, https://github.com/chartmuseum/helm-push/issues/37#issuecomment-565845431. the helm-push v0.8.0 has been fixed this issue, close the issue as resovled.

flylan commented 2 years ago

这个问题 很简单 可以加入helm的微信交流群 ,需要交流的加我微信 easonak185

make a fool of oneself