Skip to content

Duplicate Scraping Issue with EndpointSlice Role Using ipFamilyPolicy=PreferDualStack #17193

Description

@winhvu

What did you do?

I’m testing Prometheus service discovery on a dual-stack Kubernetes cluster where the service has ipFamilyPolicy set to PreferDualStack. When using the deprecated endpoints scraping role, Prometheus discovers targets only with the IPv4 address.

However, when switching to the endpointslice scraping role with the same relabeling rules, Prometheus discovers targets with both IPv4 and IPv6 addresses for the same service.

What did you expect to see?

No duplicate scraping with endpointslice scraping role.

What did you see instead? Under which circumstances?

The endpointslice scraping role has duplicated scraping:

up{instance="ipv4:9089", job="endpointslice-role", namespace="test-ns", pod_name="testapp-5f58b46757-nq7hx", service_name="testapp-prefer-dualstack"} 1
up{instance="ipv6:9089", job="endpointslice-role", namespace="test-ns", pod_name="testapp-5f58b46757-nq7hx", service_name="testapp-prefer-dualstack"} 1

Which does not see from endpoints scraping role:

up{instance="ipv4:9089", job="endpoints-role", namespace="test-ns", pod_name="testapp-5f58b46757-nq7hx", service_name="testapp-prefer-dualstack"} 1

I’ve noticed that when the metric port is not declared (the port number 9089) in the Service manifest where the Prometheus annotations are placed, this duplication of scraping (both IPv4 and IPv6 targets) from the endpointslice role does not occur.

System information

Linux 6.4.0-150600.23.42-default x86_64

Prometheus version

prometheus, version 3.5.0
  go version:       go1.24.6
  platform:         linux/amd64
  tags:             netgo,builtinassets

Prometheus configuration file

Alertmanager version


Alertmanager configuration file

Logs


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions