解决 ArgoCD 报错 Application sync failed K8s API 限流降级
分析 ArgoCD 管理成百上千应用时因触发 K8s client-side throttling 报 sync failed 根因,提供 QPS 与 Burst 调优步骤。
问题现象
当 ArgoCD 托管的 Application 数量超过数百个,或在批量同步(Sync All)时,应用大面积处于 OutOfSync 或 Unknown 状态,Controller 日志中疯狂打印限流降级告警:
level=warning msg="Client-side throttling is occurring, the rate of requests to the cluster
is greater than the capacity of the client-side throttling token bucket: 20.000000 QPS, burst: 30"
rpc error: code = ResourceExhausted desc = Rate limit exceeded
应用同步耗时从数秒暴涨至数十分钟。
触发根因
Kubernetes client-go 库内置了客户端令牌桶限流器(Client-side Throttler):
- ArgoCD Application Controller 默认 QPS/Burst 参数过于保守:默认通常仅为 20~50 QPS,面对大规模集群状态轮询时,令牌桶被瞬间抽干。
- 应用自动同步间隔过短:成百上千个应用同时触发定时刷新(Reconciliation)。
- K8s API Server 端启用了 API Priority and Fairness (APF) 限流。
诊断排查步骤
- 查看 ArgoCD 控制器日志中的限流事件:
kubectl logs -n argocd -l app.kubernetes.io/name=argocd-application-controller --tail=100 | grep "throttling"
解决步骤与操作命令
步骤一:调大 Application Controller 的客户端 QPS 与 Burst
编辑 ArgoCD 控制器启动参数(或修改 argocd-cmd-params-cm ConfigMap):
kubectl edit configmap argocd-cmd-params-cm -n argocd
在 data 字段下添加:
data:
# 将客户端 QPS 提升至 100,突发提升至 200
controller.k8s.client.qps: "100"
controller.k8s.client.burst: "200"
controller.status.processors: "50"
controller.operation.processors: "25"
步骤二:调大集群发现服务(Repo Server)缓存时间
防止对 Git 仓库进行频繁重复比对,编辑 argocd-cm:
data:
timeout.reconciliation: "300s" # 调整为 5 分钟
步骤三:重启 ArgoCD 控制器实例生效
kubectl rollout restart deployment argocd-application-controller -n argocd
kubectl rollout restart deployment argocd-repo-server -n argocd
步骤四:验证同步吞吐
再次查看控制器日志:
kubectl logs -n argocd -l app.kubernetes.io/name=argocd-application-controller -f
确认不再出现 Client-side throttling 警告,成百上千个应用在数十秒内全部完成秒级同步(Synced / Healthy)。


