Helmの基本的な使い方
chartの検索
helm search repo <repo名>
helm search hub <hub名>
% helm search hub bitnami
repoはローカル環境に追加されたレポジトリ。
インストールしたいchartを探し、それがローカルのレポジトリにない場合は、そのレポジトリをローカルに落としてくる必要がある。
repoの確認
% helm repo list
repoの追加
helm repo add <repo名>
% helm repo add bitnami https://charts.bitnami.com/bitnami
追加後は定期的に、レポジトリのupdateが必要。この辺りはaptとかhomebrewとかと同じ概念。
% helm repo update
デプロイ
helm install <リリース名> -f custom-values.yaml <chart名>
helm install <リリース名> --set key=value <chart名>
% helm install sample-nginx -f custom-values.yaml bitnami/nginx % helm install sample-nginx --set imagePullPolicy=Always bitnami/nginx
テンプレートに対してのデフォルトの設定がvalues.yaml
に記述されている。直接values.yaml
を編集しても良いが、上書きしたい設定を別ファイルにして-f
で指定するのが一般的。
更新
% helm upgrade sample-nginx -f values.yaml bitnami/nginx % helm upgrade sample-nginx --set imagePullPolicy=Always bitnami/nginx
helmによりデプロイされたリリースの確認
% helm list
リリースの詳細情報
Usage: helm get [command] Available Commands: all download all information for a named release hooks download all hooks for a named release manifest download the manifest for a named release notes download the notes for a named release values download the values file for a named release
# マニフェストを確認 helm get manifest sample-nginx # chartに渡したvaluesを確認 helm get values sample-nginx
チャート自体の詳細確認
Usage: helm show [command] Aliases: show, inspect Available Commands: all show all information of the chart chart show the chart's definition crds show the chart's CRDs readme show the chart's README values show the chart's values
# チャートに設定可能なvaluesの確認
% helm show values bitnami/nginx
history確認
helm history <リリース名>
% helm history sample-nginx
helmはhistoryを管理するので、REVISIONを確認することができるし、rollbackすることもできる。
rollback
helm rollback <リリース名> <REVISION>
% helm rollback sample-nginx 2
ロールバックしても、ロールバック対象のリビジョンが新しいリビジョンとしてデプロイされるので注意。
アンデプロイ
helm uninstall <リリース名>
% helm uninstall sample-nginx
historyも全て削除されるので、rollbackで戻せない。
historyを残したい場合は、--keep-history
をつける。
既存のchartをダウンロードする
helm pull <chart名>
% helm pull bitnami/nginx % tar xvzf nginx-9.9.3.tgz # 色々編集する % helm install sample-nginx ./nginx