I am trying to expose a stateful mongo replica set running on my cluster for outside access.
I have three replicas and I have created a LoadBalancer service for each replica with the same LoadBalancerIP while incrementing the port sequentially from 10255 to 10257.
apiVersion: v1
kind: Service
metadata:
name: mongo-service-0
namespace: datastore
labels:
app: mongodb-replicaset
spec:
loadBalancerIP: staticip
type: LoadBalancer
externalTrafficPolicy: Local
selector:
statefulset.kubernetes.io/pod-name: mongo-mongodb-replicaset-0
ports:
- protocol: TCP
port: 10255
targetPort: 27017
The issue is that only one service mongo-service-0 is deployed successfully with static IP, the other timeout after a while.
What I am trying to figure out is if I can use a single static IP address as LoadBalancerIP across multiple services with different ports.