java icon indicating copy to clipboard operation
java copied to clipboard

Further filter Pod Metrics using labels

Open at88mph opened this issue 7 months ago • 0 comments
trafficstars

Describe the bug For efficiency, it would be very beneficial to enable the labelSelector when querying the Metrics for Pods.

Client Version e.g. 24.0.0-SNAPSHOT

Kubernetes Version e.g. 1.27.10

Java Version e.g. Java 11

To Reproduce Calling this:

final ApiClient client = Config.fromCluster();
final PodMetricsList = new Metrics(client).getPodMetrics("namespace");

Which could potentially query hundreds of Pods that are out of context, could be adapted to either use the ListOption directly, or, in my case, just the labelSelector:

final String labelSelector = "foo=bar, xyz!=abc"
final ApiClient client = Config.fromCluster();
final PodMetricsList = new Metrics(client).getPodMetrics("namespace", labelSelector);

Expected behavior Reduce the items() in the PodMetricsList to just those that match the Namespace and Label Selector.

KubeConfig Not applicable

Server (please complete the following information):

  • OS: Debian Linux 12
  • Environment: Docker
  • Cloud: Self-hosted OpenStack

Additional context

at88mph avatar Apr 03 '25 17:04 at88mph