K8s:如何从 Helm Hub 安装图表

Phi*_*hil 6 kubernetes kubernetes-helm

免责声明:我是 Kubernetes 和 Helm 的新手。

我正在尝试使用全新的 Helm Hub 安装 Helm 图表,但在我的一生中,我无法弄清楚这应该如何工作。

仅在几个月前发布了新版本的 Helm (3.0),其中发生了重大变化,其中之一是它没有配置任何存储库。Helm 发布了 Helm Hub,它应该是一个用于查找图表的中心化服务。

我正在尝试安装 CloudBees Jenkins 图表。这是我搜索集线器时得到的:

[me@localhost tmp]$ helm search hub cloudbees -o yaml
- app_version: 2.222.1.1
  description: The Continuous Delivery Solution for Enterprises
  url: https://hub.helm.sh/charts/cloudbees/cloudbees-core
  version: 3.12.0+80c17a044bc4
- app_version: 9.2.0.139827
  description: A Helm chart for CloudBees Flow
  url: https://hub.helm.sh/charts/cloudbees/cloudbees-flow
  version: 1.1.1
- app_version: 9.2.0.139827
  description: A Helm chart for CloudBees Flow Agent
  url: https://hub.helm.sh/charts/cloudbees/cloudbees-flow-agent
  version: 1.1.1
- app_version: 2.204.3.7
  description: CloudBees Jenkins Distribution provides development teams with a highly
    dependable, secure, Jenkins environment curated from the most recent supported
    Jenkins release. The distribution comes with a recommended catalog of tested plugins
    available through the CloudBees Assurance Program.
  url: https://hub.helm.sh/charts/cloudbees/cloudbees-jenkins-distribution
  version: 2.204.307
- app_version: 2.0.2
  description: Helm chart for sidecar injector webhook deployment
  url: https://hub.helm.sh/charts/cloudbees/cloudbees-sidecar-injector
  version: 2.0.2
Run Code Online (Sandbox Code Playgroud)

所以看起来我正在寻找的图表可用:cloudbees-jenkins-distribution

但是,我找不到从集线器安装或基于集线器输出添加存储库的任何方法。我尝试过的一些事情:

[me@localhost tmp]$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "incubator" chart repository
...Successfully got an update from the "gitlab" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ? Happy Helming!? 

[me@localhost tmp]$ helm install myJenkins cloudbees-jenkins-distribution
Error: failed to download "cloudbees-jenkins-distribution" (hint: running `helm repo update` may help)

[me@localhost tmp]$ helm repo add cbRepo https://hub.helm.sh/charts/cloudbees
Error: looks like "https://hub.helm.sh/charts/cloudbees" is not a valid chart repository or cannot be reached: error converting YAML to JSON: yaml: line 8: mapping values are not allowed in this context

[me@localhost tmp]$ helm repo add cbRepo https://hub.helm.sh/charts/cloudbees/cloudbees-jenkins-distribution
Error: looks like "https://hub.helm.sh/charts/cloudbees/cloudbees-jenkins-distribution" is not a valid chart repository or cannot be reached: error converting YAML to JSON: yaml: line 8: mapping values are not allowed in this context
Run Code Online (Sandbox Code Playgroud)

文档确实没有说明我应该如何从 Helm Hub 转到已安装的图表。我在这里缺少什么?

mar*_*rio 7

Helm Hub 不像一个存储库,您可以从中添加和安装 Helm Charts。它也不公开有效的回购网址。这就是您收到如下错误消息的原因:

Error: looks like "https://hub.helm.sh/charts/cloudbees" is not a valid chart repository ...
Run Code Online (Sandbox Code Playgroud)

当您尝试helm repo addhttps://hub.helm.sh基于urls上运行时。

我知道它可能看起来很混乱,但它的设计就是这样。请参考本次讨论Github上。具体来说,此评论对其进行了更多解释,我希望它也能回答您的问题:

hub.helm.sh 不是 helm 存储库,因此在您尝试时它不起作用,它仅用于查看和搜索图表。在那里检查图表存储库,然后以这种方式安装图表。

不幸的是,官方的掌舵文档并没有很好地解释它。它只提到:

helm search hub 搜索 Helm Hub,其中包含来自数十个不同存储库的 Helm Chart。

但它显示“没有解释如何从helm search repo哪个节目hub.helm.shhelm repo add哪个神奇地显示要使用的新网址。” - 正如一位用户在上面提到的线程中所写的那样。

  • 这就是问题所在——目前**你不能**。至少**你不能像**那样直接通过命令来完成它。假设您找到了一个正在寻找的包,并将其作为问题中的示例。您可以手动复制其 **hub.helm.sh** URL,该 URL 恰好是“https://hub.helm.sh/charts/cloudbees/cloudbees-core”。如果您去那里,您可以看到添加此存储库所需的所有说明。您需要的命令恰好是:“helm repo add cloudbees https://charts.cloudbees.com/public/cloudbees”。理论上,您可以编写一个网络抓取脚本,例如用 **python** 来自动化它。 (5认同)
  • 老实说,如果 Helm Hub 在命令行中只是提供信息,那它有什么用呢?充其量它是无用的(通过 Web UI 更好、更容易),充其量是令人困惑。我希望有计划将其集成,以便它可以用于下载图表。 (2认同)

VAS*_*VAS 3

尽管 Helm hub 没有一种便捷的方法来获取存储库 URL,但它有一个github 存储库,其中在一个文件中包含所有供应商存储库。
\n我们可以利用这一事实来创建一个解决方法,您可以使用bashawksedperlpython等自动化工具来改进该解决方法。

\n\n

假设我们只想url使用 helm v3 和命令行工具来获取 helm 图表。
\n(helm3只是helm v3.1.2的符号链接)

\n\n

让我们获取供应商jenkins分发的存储库名称cloudbees

\n\n
$ helm3 search hub jenkins --max-col-width 1000 | grep cloudbees | tr "\\t" "\\n"\n\nhttps://hub.helm.sh/charts/cloudbees/cloudbees-core                \n3.12.0+80c17a044bc4\n2.222.1.1    \nThe Continuous Delivery Solution for Enterprises                                                                                                               \n\nhttps://hub.helm.sh/charts/cloudbees/cloudbees-jenkins-distribution\n2.204.307          \n2.204.3.7    \nCloudBees Jenkins Distribution provides development teams with a highly dependable, secure, Jenkins environment curated from the most recent supported Jenkins \nrelease. The distribution comes with a recommended catalog of tested plugins available through the CloudBees Assurance Program.\n
Run Code Online (Sandbox Code Playgroud)\n\n

我们可以看到 Helm hub 上的图表页面是

\n\n
# https://hub.helm.sh/charts/cloudbees/cloudbees-jenkins-distribution\n#                            ^^^^^^^^^\n
Run Code Online (Sandbox Code Playgroud)\n\n

所以我们可以假设存储库名称也是cloudbees

\n\n

让我们找到cloudbeeshelm 存储库的 url

\n\n
$ curl -s https://raw.githubusercontent.com/helm/hub/master/config/repo-values.yaml | grep cloudbees\n\n    - name: cloudbees\n      url: https://charts.cloudbees.com/public/cloudbees\n
Run Code Online (Sandbox Code Playgroud)\n\n

现在我们可以使用helm repo命令添加此存储库:

\n\n
$ helm3 repo add cloudbees https://charts.cloudbees.com/public/cloudbees\n\n"cloudbees" has been added to your repositories\n
Run Code Online (Sandbox Code Playgroud)\n\n

不要忘记更新:

\n\n
$ helm3 repo update\n\nHang tight while we grab the latest from your chart repositories...\n...Successfully got an update from the "cloudbees" chart repository\nUpdate Complete. \xe2\x8e\x88 Happy Helming!\xe2\x8e\x88 \n
Run Code Online (Sandbox Code Playgroud)\n\n

要查找图表名称,请在存储库中重复搜索

\n\n
$ helm3 search repo jenkins\n\nNAME                                            CHART VERSION           APP VERSION     DESCRIPTION                                       \ncloudbees/cloudbees-jenkins-distribution        2.204.307               2.204.3.7       CloudBees Jenkins Distribution provides develop...\ncloudbees/cloudbees-core                        3.12.0+80c17a044bc4     2.222.1.1       The Continuous Delivery Solution for Enterprises  \n
Run Code Online (Sandbox Code Playgroud)\n\n

最后我们可以安装图表:

\n\n
$ helm3 install cloudbees/cloudbees-jenkins-distribution --version 2.204.307\n
Run Code Online (Sandbox Code Playgroud)\n\n

赫尔明3快乐!:)

\n