<p>I am all new to Kubernetes. That said: I'm looking to add failover capabilities to an existing dockerized service which you'd probably consider as legacy service, in the sense that it requires an active/standby failover handling (full rationale will be rather long to describe, it has to do with spatial indexing and geo data processing where for a given scenario having multiple active instances will make things worse in regards to scalability and performance, e.g. sharding would get incredibly hard to handle).</p>
<p>My service is an HTTP REST service (in C++) and uses is a DB client to a distributed RQLite DB which stores all data managed by this service. I want to achieve the following:</p>
<ul>
<li>I want to have 3 RQLite services up and running continuously at all times, distributed to three nodes if possible (NB: RQLite itself uses RAFT with a default group of three).</li>
<li>I also want to have 2-3 services of my own app running all time, one of them must be the master all others must remain in standby.</li>
<li>Services must be able to know another (e.g. resolve IPs of RQLite instances)</li>
</ul>
<p>I could have missed it, but don't whether active/standby is actively supported by Kubernetes. I've found some dated answers like the one here (<a href="https://stackoverflow.com/questions/29226725/how-should-application-using-active-passive-redundant-model-be-containerized-usi">How should application using active/passive redundant model be containerized using kubernetes?</a>).</p>
<p>But before looking into many details which are all new to me, I'd like to get your rationale whether Kubernetes is actually the correct foundation for such kind of scenario (Nomad might be better for such &quot;legacy&quot; apps?)?</p>
<p>It would be great if you could provide a minimal example to demonstrate how Kubernetes can solve my failover wows.</p>

<p>Sure, regarding Kubernetes. You can also use Nomad, I don't think there is no right or wrong so it's mostly about opinion and what you would like to try.</p>
<p>I think if you just want to use a single <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Kubernetes Service</a>, you can just make use of <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">ReadinessProbes</a> in your replicas. You can use a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">Deployment</a> to manage your replicas. This is assuming your application has a leader election mechanism (like RAFT) that only has that 1 pod/instance receiving traffic at one time. The leader will always pass the readiness probe while the non-leader will fail the readiness probe. A Kubernetes service will not forward traffic to pods where their readiness probe is not passing.</p>
<p>Another option is to set up your own proxy like <a href="https://docs.nginx.com/nginx/admin-guide/load-balancer/http-health-check/#hc_passive" rel="nofollow noreferrer">nginx</a>/<a href="https://www.haproxy.com/blog/using-haproxy-as-an-api-gateway-part-3-health-checks/" rel="nofollow noreferrer">haproxy</a> in front of 2 or more services, that proxy will do the health checks and will forward only to the 'active' services.</p>
<p><a href="https://learn.hashicorp.com/nomad/load-balancing/fabio" rel="nofollow noreferrer">Similar options are available with Nomad</a>.</p>
