<p>I have 10 replicas running same Java application.
I would like to skip sending a request to the replica which is running full garbage collection cycle/stop the world cycle(using jvm tool interface)  .</p>

<p>ex: 5 application are running full GC cycle , 
5 have completed the GC cycle.
Hence i would like to route the traffic to the pods which have completed the GC cycle .</p>

<p>pseduo code:
1) Load balancer recieves incoming REST request for the backend service.
2) Determine the replica's which is not in full GC cycle.
3) Use round robin to route the request to 1 of the replica's found from step 2.</p>

<p>Can someone help me if we can do this in kubernetes.</p>

kcp
<p>I have a concept for you but you need to add some part to you program. Take a look for <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#define-readiness-probes" rel="nofollow noreferrer"><code>readinessProbe</code></a>.</p>

<p><code>readinessProbe</code>: Indicates whether the Container is ready to service requests. If the readiness probe fails, the endpoints controller removes the Pod’s IP address from the endpoints of all Services that match the Pod. The default state of readiness before the initial delay is <code>Failure</code>. If a Container does not provide a readiness probe, the default state is <code>Success</code>.</p>

<p>This is the example of config, you can use TCP socket as well</p>

<pre><code>readinessProbe:
  httpGet:
    path: /healthz
    port: 8181
  initialDelaySeconds: 5
  periodSeconds: 5
</code></pre>

<p>When GC starts, you stop responding by path <code>/healthz</code> and kubelet marks the pod as unhealthy and wait until it becomes healthy again, in your case it will be when GC is finished.</p>
