<p>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?</p>

<p>You need to request this info from the Kubernetes API Server. You can do it with Java with <a href="https://github.com/kubernetes-client/java" rel="nofollow noreferrer">kubernetes-client/java</a>. See <a href="https://github.com/kubernetes-client/java/blob/master/examples/src/main/java/io/kubernetes/client/examples/InClusterClientExample.java" rel="nofollow noreferrer">InClusterClientExample</a></p>

<p>You are interested in the pods in <em>Ready</em> state matching a specific <code>label</code> that is representing (matching) your "application".</p>

<p>If you are only interesting in the <strong>number</strong> of <em>Ready</em> pods for a specific application, you can also request the <code>Deployment</code> directly instead of pods be a label.</p>
