简体   繁体   English

如何使用 Helm CLI V3.7.2 和 Harbor 2.4.0-d4affc2 将 helm chart 推送到 Harbor

[英]How to push a helm chart to Harbor using Helm CLI V3.7.2 and Harbor 2.4.0-d4affc2

Struggling finding documentation around this that works with specific versions of Harbor and Helm.正在努力寻找适用于特定版本的 Harbor 和 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)然后我尝试在本地目录(.tgz 文件)中推送图表

Helm push myhelmchart.tgz harbor 

I get an error 'Error: scheme prefix missing from remote (eg "oci://")'我收到一个错误“错误:远程缺少方案前缀(例如“oci://”)

If I try如果我尝试

Helm push myhelmchart.tgz oci://harbor 

I get an error 'dial tcp: lookup harbor: no such host'我收到错误“拨号 tcp:查找港口:没有这样的主机”

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'我收到一个错误“看起来 oci://myharbor.mydomain.com/chartrepo/myproject 不是有效的图表存储库”

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'我收到错误“错误:意外状态:401 未经授权”

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'相同的错误“错误:意外状态:401 未经授权”

My goal is to be able to push helm charts into Harbor and have them show up in this area...我的目标是能够将掌舵图推入 Harbour 并让它们出现在该区域... 在此处输入图像描述

Found a solution, it does require a helm plugin but it works!找到了一个解决方案,它确实需要一个 helm 插件,但它可以工作!

Download and install the helm-push plugin using the following command:使用以下命令下载并安装 helm-push 插件:

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

Ensure you have added your Harbor repo to helm using the following command:确保您已使用以下命令将 Harbor 存储库添加到 helm:

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请注意 url 中的 /chartrepo,这很重要并且没有很好的文档记录,但需要让图表显示在 Harbor 的 Helm Charts 下

Use the following command to push your chart to Harbor:使用以下命令将您的图表推送到 Harbor:

Helm cm-push myhelmchart.tgz harbor

Check Harbor project - helm charts检查 Harbor 项目 - helm 图表

在此处输入图像描述

There are three options how helm charts can be pushed to Harbor舵图可以通过三种方式推送到 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正如您正确发现的那样,您可以安装 helm 插件chartmuseum/helm-push并使用它将 Helm chart 推送到 Harbor
  2. You create the Helm Chart locally with helm package and upload the tgz file via the Harbor UI您使用helm package在本地创建 Helm Chart 并通过 Harbor UI 上传tgz文件
  3. Since version 3.8 Helm support pushing and pulling Charts from OCI compliant container registries such as Harbor.从 3.8 版开始,Helm 支持从符合 OCI 的容器注册中心(如 Harbor)推送和拉取图表。

To be safe for the future, I recommend you switch to option 3, as Chartmuseum is already marked as deprecated in Harbor.为了将来的安全,我建议您切换到选项 3,因为 Chartmuseum 在 Harbor 中已被标记为已弃用。

Here is a quick rundown how to push/pull Helm Chart to OCI compliant Registries以下是如何将 Helm Chart 推/拉到符合 OCI 的注册中心的简要说明

Push Helm Chart to OCI registry:将 Helm Chart 推送到 OCI 注册表:

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:从 OCI 注册表中提取并安装 Helm Chart:

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

This is pulling to tgz file to your current directory.tgz文件拉到您的当前目录。 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:与您首先添加一个 repo 并从中提取以便能够安装 Chart 的常见方法不同,您可以使用 OCI 注册表一次性完成所有操作:

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

Same procedure for template and upgrade templateupgrade过程相同

The oci:// protocol is also available in various other subcommands. oci://协议也可用于各种其他子命令。 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 . Helm 文档有一页包含更多与 OCI 相关的示例

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图表目录中的 lint 图表

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM