5
1

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.

Kubernetes + ArgoCD で HPA する時は ignore が必要

Last updated at Posted at 2022-04-07

TL;DR

  • ArgoCD で HPA を設定した場合、常に OutOfSync となり、pods の増加・減少が繰り返されてしまう
  • 特に AverageValue の場合、関係ない値 spec.metrics[].object.target.value が HPA によって差し込まれてしまう問題がある
  • 上記含め、HPA が変更する箇所は ignore してやる必要がある
  • ドキュメント

個別設定

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  namespace: argocd
  name: hogehoge
spec:
 ignoreDifferences:
   - group: apps
     kind: Deployment
     jqPathExpressions:
       - .spec.replicas
   - group: autoscaling
     kind: HorizontalPodAutoscaler
     jqPathExpressions:
       - .spec.metrics[].object.target | select(.type == "AverageValue") | .value
...

グローバル設定

  • グローバルに設定しておけば個別に設定しなくてよい。
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: argocd
  name: argocd-cm
  labels:
    app.kubernetes.io/name: argocd-cm
    app.kubernetes.io/part-of: argocd
data:
  resource.customizations.ignoreDifferences.apps_Deployment: |
    jqPathExpressions:
        - .spec.replicas
  resource.customizations.ignoreDifferences.autoscaling_HorizontalPodAutoscaler: |
    jqPathExpressions:
        - .spec.metrics[].object.target | select(.type == "AverageValue") | .value
5
1
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
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?