I want to load-balance 2 stateful applications running on 2 pods. This application cannot have 2 replicas as it is stateful.
I tried giving the same service names to both the pods but it looks like Kubernetes get confused and nothing is served.
I am using on-premies Kubernetes cluster with metallb as a load-balancer.
Currently, these pods are exposed over public IP with service TYPE as a load-balancer and added A record to both the pods. But it cannot do a health check with DNS.
I only think of having Nginx pod and do mod-proxy to it. Is there any better solution other than this?
The selector on a service can be anything, and can match pods from multiple statefulsets (or deployments). So make a label on your pods and use that in the selector of a new service to target both.