0

I want to deploy my application (stateful) in kubernetes as 3 replicas just for high availability. Therefore only one instance of my application should get all the request. Other replicas are just for HA (in case master is down).

I know things like Redis or MySQL can be deployed but they themselves provide the master-slave architecture. https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/

How can this be achieved in kubernetes for any other simple application?

Rahul
  • 326
  • 2
  • 10
  • your application has logic of state management, replication if required and failover? – Harsh Manvar Jan 21 '22 at 09:19
  • Unable to understand your point. – Rahul Jan 21 '22 at 11:42
  • when you say satefulset with master and slave your application it self manages leader election and all ? master-slave replica is fine what is actual scenario, is it some type of DB that you are trying to deploy, is it some type of application have of state in memory or volume? – Harsh Manvar Jan 21 '22 at 11:45
  • Yes Statefuleset with master and slave means it does management of leader election by itslef. Regarding 2nd question yes, it is some kind of sate in memory. – Rahul Jan 22 '22 at 10:27

1 Answers1

0

You need to put the failover logic somewhere. Either on the server-side or client-side. Either client can talk to instance 1 by default and if it is not up, then failover to instance 2 and so on. Or you can have an agent/proxy on the server-side which does this routing for you. In this case, the proxy has the logic of checking if instance 1 is up or down, etc.

Usually, for stateful applications, failover is not just as simple as connecting to the other instance when the primary is down. It might involve reconciling the state, making sure the other replica has an up-to-date state or has a quorum, etc depending on the application. So there is no "one size fits all" type solution for all stateful applications. You need to build and chose the model appropriate for your application.

Muhammad Mohsin Khan
  • 1,444
  • 7
  • 16
  • 23
Shashank V
  • 10,007
  • 2
  • 25
  • 41