Argo CD periodically synchronizes your Git repository with the cluster, which may conflict with pod scaling activities performed by the Horizontal Pod Autoscaler (HPA)—including overwriting spec.replicas with whatever value is in the manifest. To prevent this conflict, exclude spec.replicas from Argo CD's sync scope. The method depends on the application's default replica count.
Applications with one replica by default
Comment out the replicas field in the Deployment manifest. Argo CD only syncs fields that are present in Git, so omitting replicas lets HPA manage it exclusively.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
# do not include replicas in the manifests if you want replicas to be controlled by HPA
# replicas: 1
template:
spec:
containers:
- image: nginx:1.7.9
name: nginx
ports:
- containerPort: 80
...
Applications with multiple replicas by default
When your manifest declares more than one replica, commenting out the field breaks the default behavior. Instead, configure Argo CD to ignore differences in spec.replicas using Diffing Customization. Argo CD then leaves that field alone during sync, letting HPA control replica counts without interference.
Two scopes are available: application-level (affects one application) and system-level (affects all applications in a Fleet instance).
Application-level configuration
Configure .spec.ignoreDifferences in the Application resource. This affects only the specified application.
By default, the rule applies to all Deployments in the application. To target a specific Deployment, uncomment and set the name and namespace fields.
Thegroupfield refers to the Kubernetes API group without the version (for example,apps, notapps/v1).
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app-test
namespace: argocd
spec:
ignoreDifferences:
- group: apps
kind: Deployment
#name: test
#namespace: default
jsonPointers:
- /spec/replicas
...
System-level configuration
Configure the argocd-cm ConfigMap to ignore spec.replicas across all applications in the Fleet instance. Use this when you want HPA to control replica counts for every managed application.
For ACK One GitOps, controlplane-kcm must be configured alongside kube-controller-manager in managedFieldsManagers.
apiVersion: v1
data:
...
resource.customizations.ignoreDifferences.all: |
managedFieldsManagers:
- kube-controller-manager
- controlplane-kcm
jsonPointers:
- /spec/replicas
kind: ConfigMap
metadata:
name: argocd-cm
namespace: argocd
What's next
-
To enable HPA for an application, see Implement Horizontal Pod Autoscaler (HPA).
-
For details on the scaling algorithms HPA uses, see Algorithm details.