Skip to content

HPA Configuration in values.yaml Misleads Target Utilization vs. Average Value Setting #199

@vchendrix

Description

@vchendrix

Description

The Horizontal Pod Autoscaler (HPA) configuration in the values.yaml file implies that the target utilization is being configured. However, the current implementation sets the average value instead. This discrepancy can lead to confusion and unexpected behavior during autoscaling.

Affected Code:

The relevant section of the hpa.yaml template can be found here.

{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
{{- if or (.Capabilities.APIVersions.Has "autoscaling/v2") (.Capabilities.APIVersions.Has "autoscaling/v2beta2") }}
target:
type: AverageValue
averageValue: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- else }}
targetAverageValue: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{- if or (.Capabilities.APIVersions.Has "autoscaling/v2") (.Capabilities.APIVersions.Has "autoscaling/v2beta2") }}
target:
type: AverageValue
averageValue: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- else }}
targetAverageValue: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}


Steps to Reproduce

  1. Configure HPA in values.yaml with a value implying target utilization.
  2. Deploy the Helm chart.
  3. Observe that the HPA uses the average value instead of the target utilization.

Expected Behavior

The configuration should prioritize the use of target utilization, as it is more commonly used and aligns with typical HPA configurations. Alternatively, the configuration could allow users to choose between setting target utilization or average value explicitly.


Suggested Improvements

  1. Modify Default Behavior:

    • Update the hpa.yaml template to use target utilization by default, as it is generally preferred for most use cases.
  2. Add Configurability:

    • Introduce a configuration option in values.yaml that allows users to specify whether they want to set target utilization or average value.

    Example:

    hpa:
      targetType: utilization  # Options: utilization, averageValue
      targetValue: 70
    • Adjust the hpa.yaml template to dynamically render the configuration based on the chosen targetType.
  3. Improve Documentation:

    • Clearly document the difference between target utilization and average value in the values.yaml file and other relevant documentation.
    • Provide examples to guide users in configuring the HPA according to their needs.

Additional Context

This issue may cause confusion and unexpected scaling behavior if users are unaware of the difference between target utilization and average value. Updating the default behavior to prioritize target utilization or adding configurability will make the chart more user-friendly and flexible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions