リソースがあるのにリソースが無いとエラーが起きる⇒argoCDのsyncが生きていてdeployを削除してもすぐに起動してしまっていた事例

スポンサーリンク
Uncategorized

はじめに

リリースしたものがあるのに、それらを消そうとしたら、「Error: uninstall: Release not loaded: ref-voice-backend: release: not found」と言われる事象が発生しました。

以下のような感じ。

$ kubectl get pod -n ref-voice
NAME                                  READY   STATUS             RESTARTS          AGE
ref-voice-backend-7b8bfdc95c-b9k59    1/1     Running            0                 23h
ref-voice-backend-7b8bfdc95c-mwhr9    1/1     Running            0                 23h
・・・【略】・・・
ref-voice-ollama-5d86bccddc-9lnf6     1/1     Running            0                 23h

$ helm uninstall ref-voice-backend -n ref-voice
Error: uninstall: Release not loaded: ref-voice-backend: release: not found

今回はこの事象に対応します。

対応

この状態で、installを使用と試してみました。

$ helm install ref-voice-backend ./go_slim_backend --namespace ref-voice
Error: INSTALLATION FAILED: unable to continue with install: Service "ref-voice-backend-svc" in namespace "ref-voice" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "ref-voice-backend"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "ref-voice"

あれ?できない。

これはHelm管理ではなく、ArgoCD管理となっていたためでした。

以下の確認をすると分かります。

$ kubectl get applications -n argocd
NAME                          SYNC STATUS   HEALTH STATUS
ref-voice-backend             Synced        Healthy
ref-voice-frontend            Synced        Healthy
ref-voice-ollama              Synced        Healthy

ArgoCDのauto-syncをOFFにする必要があります。

しかし、CLIでauto-syncをOFFにしようと、普通に実行すると失敗しました。

$ argocd app set ref-voice-backend --sync-policy none
argocd app set ref-voice-frontend --sync-policy none
argocd app set ref-voice-ollama --sync-policy none
argocd app set ref-voice-postgresql-vector --sync-policy none
{"level":"fatal","msg":"Argo CD server address unspecified","time":"2025-11-29T18:21:06+09:00"}
{"level":"fatal","msg":"Argo CD server address unspecified","time":"2025-11-29T18:21:06+09:00"}
{"level":"fatal","msg":"Argo CD server address unspecified","time":"2025-11-29T18:21:06+09:00"}
{"level":"fatal","msg":"Argo CD server address unspecified","time":"2025-11-29T18:21:06+09:00"}

このため、事前にログインする必要があります。

argocd-serverのpodに入ってログインを実施し、そしてsync-policyをnoneに設定します。

以下のようになります。(パスワードについては、kubectl -n argocd get secrets argocd-initial-admin-secret -ojsonpath={.data.password} | base64 -d で求められます。)

$ kubectl -n argocd exec -it pod/argocd-server-77d799c5fb-b6hnn /bin/bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
argocd@argocd-server-77d799c5fb-b6hnn:~$ argocd login localhost:8080 --username admin --password xxxxxx --insecure
'admin:login' logged in successfully
Context 'localhost:8080' updated
argocd@argocd-server-77d799c5fb-b6hnn:~$ argocd app set ref-voice-backend --sync-policy none

これで削除できた。

$ kubectl delete deploy ref-voice-backend -n ref-voice
deployment.apps "ref-voice-backend" deleted

このsync-policyを再度、自動に設定するには以下をargocd-serverのpodに入って実施すればいいらしいです。

argocd app set ref-voice-backend --sync-policy automated

最後に

色んなサービスの設定があるので、どこがどう影響しているのかを切り分けるのが大変ですね。

しかし、これを一つ一つこなしていくと成長に繋がると信じています。

タイトルとURLをコピーしました