同步你的圖表儲存庫

注意:此範例專為提供圖表儲存庫的 Google Cloud Storage (GCS) 儲存區而設。

必要條件

  • 安裝 gsutil 工具。我們高度依賴 gsutil rsync 功能
  • 務必存取 Helm 二進位檔案
  • 選用:建議您對 GCS 儲存區設定 物件版本控制,以防您意外刪除任何東西。

設定本機圖表儲存庫目錄

建立一個本機目錄,就像我们在 圖表儲存庫指南 中所做的那樣,並將您的套件圖表放在該目錄中。

例如

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

產生更新的 index.yaml

使用 Helm 產生更新的 index.yaml 檔案,方法是將目錄路徑和遠端儲存庫網址傳遞至 helm repo index 指令,如下所示

$ 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

有用連結