Skip to content

Metrics API scaler with aggregateFromKubeServiceEndpoints spuriously probes all pods in namespace #7641

Description

@proudier

Report

After configuring a Metrics API scaler with aggregateFromKubeServiceEndpoints: true and the URL of a headless service, pods unrelated to the service started to receive requests from the scaler.

It manifested as 404 errors in the logs of the unrelated pods, with the source IP being that of the KEDA operator pod. Only pods in the same namespace as the service are affected (ie. not cluster wide).

Expected Behavior

KEDA should only query pods (endpoints) belonging to the service specified in the url metadata field.

Actual Behavior

All pods from the namespace are receiving requests from the KEDA operator.

Steps to Reproduce the Problem

  1. Deploy two headless services (A and B) in the same namespace and each with ready pods
  2. Create a ScaledObject with type: metrics-api, aggregateFromKubeServiceEndpoints: "true", targeting services A
  3. Observe logs of the service B and see requests from KEDA Operator targeting the URL configured in the ScaledObject

Logs from KEDA operator

n/a

KEDA Version

2.19.0

Kubernetes Version

1.34

Platform

Google Cloud

Scaler Details

Metrics API

Would you be open to contributing a fix?

Yes

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingscalerscaler-metrics-apiAll issues related to our Metrics API scaler

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Ready To Ship

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions