Venkat
Venkat

Reputation: 11

Is there a way to get number of active Kubernetes Pods in Java

We are building a rate limiter and calculate config values based on number of pods available at that moment. Is there any way to get the number of pods that are active in any instance from a java application? Also, is it possible to get the number of tasks in the case of AWS Fargate from a Java application?

Upvotes: 1

Views: 1217

Answers (1)

Jonas
Jonas

Reputation: 128867

You need to request this info from the Kubernetes API Server. You can do it with Java with kubernetes-client/java. See InClusterClientExample

You are interested in the pods in Ready state matching a specific label that is representing (matching) your "application".

If you are only interesting in the number of Ready pods for a specific application, you can also request the Deployment directly instead of pods be a label.

Upvotes: 2

Related Questions