I have created a service(backend) in openshift 3 and I have spun up 3 pods. So there are three pods backend-1-abc, backend-1-xyz and backend-1-efg. Also I have added router for this https://backend.abc.com.
Each pod has an inbuilt cache, which reads the data from DB and stores it into its internal cache. Also there is an endpoint "/refresh". The cache in the pods gets refreshed only when we hit the endpoint "/refresh" explicitly.
But my problem is whenever I hit "https://backend.abc.com/refresh", due to Kubernetes loadbalance, only one pod's /refresh endpoint will be called and it's cache gets refreshed. but the other two pod's cache remains unchanged.
Kindly let me know, is there any way to refresh the cache of all the pods simultaneously.
I think you can try to access to Service
directly, because Service
processes requests based on round-robin
algorithms.
e.g.>
# oc get svc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
backend 172.30.6.68 <none> 8080/TCP 1m
--- Repeat the curl cmd 3times, if you have 3 pods.
# curl http://172.30.6.68:8080/refresh
# curl http://172.30.6.68:8080/refresh
# curl http://172.30.6.68:8080/refresh
-- I updated based on Graham's solutions.
If you ensure to refresh cache, you can request to all pods.
oc get endpoints <Your backend service name> -o yaml | grep ip
can list your all pod IPs.