How to redirect user requests to another deployment in Kubernetes?

10/29/2020

I have the following scenario,

I have two deployments on Kubernetes, my first deployment needs to be shut down due to some issue and user requests need to route to the second deployment and then the first deployment will shut down, once the second is up and running.

How would I route user requests from the first to the second? I know that there are readiness and liveness check but how would I specifically specify in the script to send the requests to the second deployment.

Based on my limited knowledge I believe there might be some other ways to re-route the traffic from the first deployment to second deployment. Also, my user request is a continuous video image being sent from the user to the Kubernetes system.

Thanks, help is highly appreciated.

-- abaair davis
deployment
kubernetes
kubernetes-deployment
kubernetes-pod
readinessprobe

1 Answer

10/29/2020

With a "second deployment", I assume that you mean a new version of your app, in Kubernetes this would be a change of the Deployment resource to use a different image:.

In Kubernetes, you usually have a few instances ("replicas") of your app running. And when a Deployment is updated to contain a new version (e.g. a new image), then Kubernetes automatically does a Rolling Update. This means that it will create new instances from the new image - one by one - and at the same time terminate instances from the old version of the app. This means that you, during a short period of time will have both versions of the app running at the same time. User requests will be routed to any running instance. This can be changed to use a different Deployment Strategy, e.g. "replace" or you can create a more advanced setup.

my user request is a continuous video image being sent from the user to the Kubernetes system

Requests to apps running on Kubernetes should be designed in an idempotent way - such that the client can retry the request if the connection is interrupted.

-- Jonas
Source: StackOverflow