Skip to content

Use Conditional replicas Field in Deployment When HPA Enabled #7560

@juhosyrjanen

Description

@juhosyrjanen

Description:

Hi there, and thank you for the great project!
I’d like to suggest a small improvement to the Helm chart. I’m also happy to implement the change if the maintainers think it’s worthwhile.

There is a minor issue with how the Helm chart currently handles the interaction between the HorizontalPodAutoscaler (HPA) and the replicas field for the envoy-gateway Deployment. This issue especially affects users deploying Envoy Gateway with GitOps tools such as ArgoCD.

The Problem

By default in the values file, the envoy-gateway Deployment sets:

spec:
  replicas: 1

When an HPA is enabled with values like:

hpa:
  enabled: true
  minReplicas: 2
  maxReplicas: 5

  metrics:
    - type: Resource
      resource:
        name: memory
        target:
          type: Utilization
          averageUtilization: 75 # scale when memory usage > 75%

  behavior:
    scaleUp:
      stabilizationWindowSeconds: 0
      policies:
        - type: Percent
          value: 100
          periodSeconds: 60
    scaleDown:
      stabilizationWindowSeconds: 300
      policies:
        - type: Percent
          value: 50
          periodSeconds: 60

the HPA will try to increase the number of replicas (e.g., from 1 to 2) and will continue adjusting the count as needed. This creates configuration drift between the Deployment and Git, causing GitOps controllers such as ArgoCD to repeatedly report the Deployment as OutOfSync, which triggers unnecessary reconcile loops.

Ref picture :)

Image

Proposed Solution

If HPA is enabled, the Deployment should omit spec.replicas entirely.
This allows HPA to fully manage the replica count while keeping GitOps tools in sync.

A minimal change to the chart resolves the issue:

spec:
{{- if not .Values.hpa.enabled }} # Add this condition
  replicas: {{ .Values.deployment.replicas }}
{{- end }} # Close condition

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions