How to redirect the request to a different node when there is an unexpected exception and one of the pods gets restarted We are deploying the application in a Kubernetes cluster and when we face an unexpected error and the pod gets restarted or goes down we are getting a 502 Gateway error even though there is another pod that should start accepting the requests without getting the 502 gateway error.
We are making sure that the application is cluster enabled and the request is redirected to the another pod automatically when we stop/kill the pod gracefully but doesnot happen on a exception.
You should configure a Readiness Probe in the Deployment for your app. When using a Readiness Probe, no traffic will be sent to instances that are not prepared to receive traffic.