同步图表库

注意:此示例专门用于 Google Cloud Storage (GCS) 存储桶,该存储桶用作图表库。

先决条件

  • 安装 gsutil 工具。我们非常依赖 gsutil rsync 功能
  • 确保可以访问 Helm 二进制文件
  • 可选:建议您在 GCS 存储桶上设置 对象版本控制,以防您意外删除某些内容。

设置本地图表库目录

创建一个本地目录,就像我们在 图表库指南 中所做的那样,并将您的打包图表放置在该目录中。

例如

$ mkdir fantastic-charts
$ mv alpine-0.1.0.tgz fantastic-charts/

生成更新的 index.yaml

使用 Helm 通过将目录路径和远程库的 URL 传递给 helm repo index 命令来生成更新的 index.yaml 文件,如下所示

$ helm repo index fantastic-charts/ --url https://fantastic-charts.storage.googleapis.com

这将生成一个更新的 index.yaml 文件,并将其放置在 fantastic-charts/ 目录中。

同步本地和远程图表库

通过运行 scripts/sync-repo.sh 并传入本地目录名和 GCS 存储桶名,将目录的内容上传到您的 GCS 存储桶。

例如

$ pwd
/Users/me/code/go/src/helm.sh/helm
$ scripts/sync-repo.sh fantastic-charts/ fantastic-charts
Getting ready to sync your local directory (fantastic-charts/) to a remote repository at gs://fantastic-charts
Verifying Prerequisites....
Thumbs up! Looks like you have gsutil. Let's continue.
Building synchronization state...
Starting synchronization
Would copy file://fantastic-charts/alpine-0.1.0.tgz to gs://fantastic-charts/alpine-0.1.0.tgz
Would copy file://fantastic-charts/index.yaml to gs://fantastic-charts/index.yaml
Are you sure you would like to continue with these changes?? [y/N]} y
Building synchronization state...
Starting synchronization
Copying file://fantastic-charts/alpine-0.1.0.tgz [Content-Type=application/x-tar]...
Uploading   gs://fantastic-charts/alpine-0.1.0.tgz:              740 B/740 B
Copying file://fantastic-charts/index.yaml [Content-Type=application/octet-stream]...
Uploading   gs://fantastic-charts/index.yaml:                    347 B/347 B
Congratulations your remote chart repository now matches the contents of fantastic-charts/

更新图表库

您需要保留图表库内容的本地副本,或者使用 gsutil rsync 将远程图表库的内容复制到本地目录。

例如

$ gsutil rsync -d -n gs://bucket-name local-dir/    # the -n flag does a dry run
Building synchronization state...
Starting synchronization
Would copy gs://bucket-name/alpine-0.1.0.tgz to file://local-dir/alpine-0.1.0.tgz
Would copy gs://bucket-name/index.yaml to file://local-dir/index.yaml

$ gsutil rsync -d gs://bucket-name local-dir/       # performs the copy actions
Building synchronization state...
Starting synchronization
Copying gs://bucket-name/alpine-0.1.0.tgz...
Downloading file://local-dir/alpine-0.1.0.tgz:                        740 B/740 B
Copying gs://bucket-name/index.yaml...
Downloading file://local-dir/index.yaml:                              346 B/346 B

有用链接