Open2
kustomize edit fixコマンドの使い方
なんかいつも忘れてハマってしまうのでメモ。
Kustomizeでdeprecatedな記述があるファイルをbuildすると以下のようなWarningが表示される。
# Warning: 'commonLabels' is deprecated. Please use 'labels' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'commonLabels' is deprecated. Please use 'labels' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
Warningにはkustomize edit fix
コマンドを使って自動更新してと出力されている。
buildコマンドと同じノリでedit fix
を実行してみると、なぜかエラーになる。
$ kubectl kustomize edit fix k8s/overlays/dev/
error: specify one path to kustomization.yaml
kubectlのサブコマンドだからダメなのかと思い、kustomizeコマンドを実行してみてもエラーになる。
$ kustomize edit fix k8s/overlays/dev/
Error: Missing kustomization file 'kustomization.yaml'.
Usage:
kustomize edit fix [flags]
Examples:
# Fix the missing and deprecated fields in kustomization file kustomize edit fix
Flags:
-h, --help help for fix
--vars If specified, kustomize will attempt to convert vars to replacements.
We recommend doing this in a clean git repository where the change is easy to undo.
Global Flags:
--stack-trace print a stack-trace on error
色々試したところ、kustomize edit fixコマンドはパスの指定ができないため、対象のディレクトリに移動して実行する必要がある。
cd k8s/overlays/dev/
kustomize edit fix
ちなみにkubectlのサブコマンドのkustomizeだと対象ディレクトリに移動してもedit fixコマンドが同様のエラーになります...