直面した問題
manifest管理にkustomizeを利用した際、ArgoCDのargocd-repo-server
がいきなり再起動(おそらくOutOfMemoryError)したり、
ArgoCD上のApplicationのStatusがUnknownになったり、今まで発生しなかった問題が発生した。
問題①
事象
ArgoCDはkustomizeもサポートしているのかぁと感心していると、突然argocd-repo-serverが再起動!
$ kubectl get pod -n argocd -w
NAME READY STATUS RESTARTS AGE
argocd-application-controller-0 1/1 Running 0 10h
argocd-applicationset-controller-7796bb8958-2jmvg 1/1 Running 0 10h
argocd-applicationset-controller-7796bb8958-kx9n9 1/1 Running 0 10h
argocd-notifications-controller-d89bc56c-n4w22 1/1 Running 0 10h
argocd-redis-86df6b8979-zlrh2 1/1 Running 0 10h
argocd-repo-server-8457cf44dc-fws7r 1/1 Running 0 95s
argocd-server-5b68985fc5-4rt4w 1/1 Running 0 10h
argocd-server-5b68985fc5-ksxf9 1/1 Running 0 10h
argocd-repo-server-8457cf44dc-fws7r 0/1 Running 1 (3s ago) 3m59s
argocd-repo-server-8457cf44dc-fws7r 1/1 Running 1 (12s ago) 4m8s
原因
どうやら以下によると、argocd-repo-server
がmanifestの生成処理を行っているようです。
kustomizeを導入したことにより、manifest生成のために定期的にkustomze build
が実行され負荷が高まってしまったらしい。
--parallelismlimit
オプションを利用することで、並列実行数を抑制し負荷を抑えられるとのこと。
argocd-repo-server fork/exec config management tool to generate manifests. The fork can fail due to lack of memory or limit on the number of OS threads. The --parallelismlimit flag controls how many manifests generations are running concurrently and helps avoid OOM kills.
対処
以下のように--parallelismlimit
を追加して対処
(値はとりあえず適当に5並列に設定)
:
:
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: repo-server
app.kubernetes.io/name: argocd-repo-server
app.kubernetes.io/part-of: argocd
name: argocd-repo-server
:
:
containers:
- command:
- entrypoint.sh
- argocd-repo-server
- --redis
- argocd-redis:6379
- --parallelismlimit
- "5"
:
:
*ARGOCD_REPO_SERVER_PARALLELISM_LIMIT
という環境変数もあるようなので、
環境変数を設定することでも対応可能
問題②
事象
argocd-repo-server
のOutOfMemoryErrorが解決したと思ったら、今度は以下のようにArgoCD上のApplicationのStatusがUnknownに。。。
原因
以下の記載を発見。
manifestの生成に時間がかかりtimeoutしていたようです。
timeout値はargocd-application-controller
にて設定可能なようです。
The manifest generation typically takes the most time during reconciliation. The duration of manifest generation is limited to make sure the controller refresh queue does not overflow. The app reconciliation fails with Context deadline exceeded error if the manifest generation is taking too much time. As a workaround increase the value of --repo-server-timeout-seconds and consider scaling up the argocd-repo-server deployment.
以下によるとdefault値は60秒
https://github.com/argoproj/argo-cd/issues/1641#issuecomment-495425711
対処
以下のように--repo-server-timeout-seconds
を設定し、timeout値を伸ばして対処
:
:
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app.kubernetes.io/component: application-controller
app.kubernetes.io/name: argocd-application-controller
app.kubernetes.io/part-of: argocd
name: argocd-application-controller
:
:
containers:
- command:
- argocd-application-controller
- --repo-server-timeout-seconds
- "180"
:
:
*ARGOCD_APPLICATION_CONTROLLER_REPO_SERVER_TIMEOUT_SECONDS
という環境変数もあるようなので、環境変数を設定することでも対応可能