13.2. 使用 Quay 的 Helm chart
作为 Cloud Native Computing Foundation(CNCF)的研究项目,Helm 已成为 Kubernetes 的事实软件包管理器,因为它简化了应用被打包和部署的方式。Helm 使用名为 Charts 的打包格式,其中包含代表应用程序的 Kubernetes 资源。可以为存储库中的常规分发和使用提供 chart。Helm 仓库是提供 index.yaml 元数据文件的 HTTP 服务器,以及一组可选的打包 chart。从 Helm 版本 3 开始,支持以替代传统仓库的方式在 OCI registry 中分发 chart。要演示如何将 Quay 用作 Helm chart 的 registry,会使用 Helm 仓库中的现有 chart 来展示与 OCI registry for Chart 开发者和用户的交互。
在以下示例中,从红帽实践(CoP)软件仓库中下载了一个 etherpad chart 示例,并使用以下步骤将其推送到本地 Red Hat Quay 存储库:
- 添加适当的软件仓库
- 使用最新的元数据更新存储库
-
下载并解压缩 chart,以创建名为
etherpad的本地目录
例如:
$ helm repo add redhat-cop https://redhat-cop.github.io/helm-charts
$ helm repo update
$ helm pull redhat-cop/etherpad --version=0.0.4 --untar
标记 chart 需要使用 helm chart save 命令 - 这与使用 podman tag 进行标记镜像。
$ helm chart save ./etherpad example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad:0.0.4
ref: example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad:0.0.4
digest: 6850d9b21dd4b87cf20ad49f2e2c7def9655c52ea573e1ddb9d1464eeb6a46a6
size: 3.5 KiB
name: etherpad
version: 0.0.4
0.0.4: saved
使用 helm chart list 命令查看 chart 的本地实例:
helm chart list
REF NAME VERSION DIGEST SIZE CREATED
example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad:0.0.4 etherpad 0.0.4 ce0233f 3.5 KiB 23 seconds
在推送 chart 前,使用 helm registry login 命令登录到存储库:
$ helm registry login example-registry-quay-quay-enterprise.apps.user1.example.com
Username: quayadmin
Password:
Login succeeded
使用 helm chart push 命令将 chart 推送到本地 Quay 存储库:
$ helm chart push example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad:0.0.4
The push refers to repository [example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad]
ref: example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad:0.0.4
digest: ce0233fd014992b8e27cc648cdabbebd4dd6850aca8fb8e50f7eef6f2f49833d
size: 3.5 KiB
name: etherpad
version: 0.0.4
0.0.4: pushed to remote (1 layer, 3.5 KiB total)
要测试推送是否正常工作,请删除本地副本,然后从存储库中拉取 chart:
$ helm chart rm example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad:0.0.4
$ rm -rf etherpad
$ helm chart pull example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad:0.0.4
0.0.4: Pulling from example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad
ref: example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad:0.0.4
digest: 6850d9b21dd4b87cf20ad49f2e2c7def9655c52ea573e1ddb9d1464eeb6a46a6
size: 3.5 KiB
name: etherpad
version: 0.0.4
Status: Downloaded newer chart for example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad:0.0.4
使用 helm chart 导出 命令提取 chart 文件:
$ helm chart export example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad:0.0.4
ref: example-registry-quay-quay-enterprise.apps.user1.example.com/helm/etherpad:0.0.4
digest: ce0233fd014992b8e27cc648cdabbebd4dd6850aca8fb8e50f7eef6f2f49833d
size: 3.5 KiB
name: etherpad
version: 0.0.4
Exported chart to etherpad/