1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Helmfileの特定のリリースを消したい

Last updated at Posted at 2023-06-30

やりたいこと

helmfile.yamlを使って複数のHelmチャートをデプロイしていて、不要になったものを削除したくなりました。例えば以下の2つをリリースしており、haproxyだけ削除したいです。

$ ls .
helmfile.yaml
$ helmfile list
NAME    NAMESPACE       ENABLED INSTALLED       LABELS  CHART           VERSION
nginx   nginx           true    true                    bitnami/nginx   15.1.0
haproxy haproxy         true    true                    bitnami/haproxy 0.8.3

参考情報

$ helmfile --version
helmfile version 0.152.0
helmfile.yaml
repositories:

- name: bitnami
  url: https://charts.bitnami.com/bitnami

releases:

- name: nginx
  namespace: nginx
  createNamespace: true
  chart: bitnami/nginx
  version: 15.1.0

- name: haproxy
  namespace: haproxy
  createNamespace: true
  chart: bitnami/haproxy
  version: 0.8.3

helmfile destroyを誤用してしまう...

helmfile --helpを見るとdestroyというサブコマンドが用意されていました。

$ helmfile --help | grep destroy
  destroy      Destroys and then purges releases

そこで「helmfile destroy haproxyとか実行すれば消せるんだろうなあ」と安易に考えて実行してみます。

【警告】実際にこのコマンドを実行すると全リリースが消えてしまうので、決してたやすく実行しないでください!!

$ helmfile destroy haproxy
Adding repo bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories

Listing releases matching ^haproxy$
haproxy haproxy         1               2023-07-01 05:39:20.532555249 +0900 JST deployed        haproxy-0.8.3   2.8.0

Listing releases matching ^nginx$
nginx   nginx           1               2023-07-01 05:39:20.866827715 +0900 JST deployed        nginx-15.1.0    1.25.1

Deleting haproxy
Deleting nginx
release "haproxy" uninstalled

release "nginx" uninstalled


DELETED RELEASES:
NAME
haproxy
nginx

なんとhaproxyだけではなくて、nginxも消されてしまっています。。。
helmfile destroy(またはdelete)はhelmfile.yamlに記載されたリリース全てを有無を言わさず削除する恐ろしいコマンド だったのです。

現バージョン(0.152.0)の挙動なので、今後改善される可能性はあります。

同様の報告は以下のようにされており、誤用の可能性とその危険性が非常に高いのがわかります。

特定のリリースのみを消すにはどうすればいい?

小一時間調べてみたのですがよさげな情報は見つからず、結局以下のように消したいリリースのみを書いたhelmfileを用意してhelmfile destroyを実行することで対処しました。

helmfile-delete.yaml
repositories:

- name: bitnami
  url: https://charts.bitnami.com/bitnami

releases:

- name: haproxy
  namespace: haproxy
  createNamespace: true
  chart: bitnami/haproxy
  version: 0.8.3

実行コマンドとその出力

$ helmfile destroy --file helmfile-delete.yaml
Adding repo bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories

Listing releases matching ^haproxy$
haproxy haproxy         1               2023-07-01 06:06:53.924671604 +0900 JST deployed        haproxy-0.8.3   2.8.0

Deleting haproxy
release "haproxy" uninstalled


DELETED RELEASES:
NAME
haproxy

おわりに

helmfile destroy(or delete)コマンドを何らかの事情で使って、かつ~/.bash_historyにその履歴が残っている場合は、履歴ごと削除する(または履歴に記録されない設定にする)ことを推奨します。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?