Hi Team,
We are trying percona operator for MongoDB with exposeType : LoadBalancer in our development servers using AWS EKS
We have below queries reg the loadbalencers :
- LB name
mongo1-cdbr1-0 LoadBalancer 10.100.80.36 a7c9d1c2f2df14ab3959e7f87dc48f3b-755583469.us-east-2.elb.amazonaws.com 27017:32365/TCP 38m
mongo1-cdbr1-1 LoadBalancer 10.100.115.217 a8b8a778816b841f990c8f21a63cefa4-705224816.us-east-2.elb.amazonaws.com 27017:32238/TCP 38m
mongo1-cdbr1-2 LoadBalancer 10.100.56.73 ae1bd4452e7464f989e9ddc304870a97-1759599640.us-east-2.elb.amazonaws.com 27017:31734/TCP 37m
We can see LB names are created with random names → a7c9d1c2f2df14ab3959e7f87dc48f3b-755583469 / a8b8a778816b841f990c8f21a63cefa4-705224816 / ae1bd4452e7464f989e9ddc304870a97-1759599640
Is there any way to setup custom names like “mongo1-cdbr-lb” for the load balencers for exposing outside the cluster ?
Please suggest to configure custom names for the load balencers .
- Single ALB instead of multiple loadbalencers tagged to services
Is there any way to configure single load balencer(which servers as dns-srv name) for all the services which are tagged to pods of replicaset.
Eg : mongo1-cdbr-lb (single ALB) which should route the traffic to all the services for replicaset using mongodb+srv from outside the cluster .
Regards,
Adithya
1 Like
Hello @Adithya .
Is there any way to setup custom names like “mongo1-cdbr-lb” for the load balencers for exposing outside the cluster ?
We rely on regular Kubernetes primitives - so we just create a service object of a specific type. I’m not aware of being able to specify the LB name through k8s right now.
- Single ALB instead of multiple loadbalencers tagged to services
Single ALB will not solve the problem. Behind this ALB there should be multiple SVR records pointing to different servers, otherwise it does not make much sense.
In general our recommendation is to enable sharding and expose mongos nodes through a single load balancer. You will have one sharded mongoDB cluster with single entry-point.
1 Like
@Sergey_Pronin Thanks for the reply.
Can we know how to setup single load balancer for replicaset/sharded cluster ? Can you provide some sample yaml file
If we add exposeType: LoadBalancer it’s creating multiple load balancers in AWS as mentioned above.
Regards,
Adithya
1 Like
Hey @Adithya ,
as I mentioned it can be done through enabling sharding.
In a nutshell the key options would look like this:
spec.replsets.[].explose.enabled: false
spec.sharding.enabled: true
spec.sharding.mongos.expose.exposeType: LoadBalancer
This will enable sharding and expose mongos pods through a single load balancer (and as a result the whole MongoDB cluster).
Hope this helps.
2 Likes
Thanks @Sergey_Pronin for the all the details. Appreciate quick response.
So for Replicaset config with cr.yaml with k8s operator we will not be able to setup single LB.
Single load balancer setup works for sharded cluster.
mgdb-mongos LoadBalancer 10.100.137.171 a638c75f9e74d4054840a40023c1c539-863770566.us-east-2.elb.amazonaws.com 27017:32493/TCP 7m29s
From AWS EC2 console : we can see random DNS name is used for CLB. Is there any way to setup DNS Name from the cr.yaml while creating LB from EKS .
Name → a638c75f9e74d4054840a40023c1c539
DNS name → a638c75f9e74d4054840a40023c1c539-863770566.us-east-2.elb.amazonaws.com (A Record)
Regards,
Adithya
1 Like
For the name, please see this: Annotations - AWS Load Balancer Controller
Looks like AWS load balancer controller supports that through the annotation service.beta.kubernetes.io/aws-load-balancer-name
So just add under spec.sharding.mongos.expose.serviceAnnotations
smth like service.beta.kubernetes.io/aws-load-balancer-name: my-lb-name
1 Like
@Sergey_Pronin
Tried the option like below but no luck. still LB name is random.
expose:
exposeType: LoadBalancer
serviceAnnotations:
service.beta.kubernetes.io/aws-load-balancer-name: awslb
&
expose:
exposeType: LoadBalancer
serviceAnnotations:
service.beta.kubernetes.io/load-balancer-name: awslb
For sharded cluster:
service/mgdb-mongos LoadBalancer 10.100.17.221 a726464f38ba044e0ab8ce1bdf7011e4-1633854664.us-east-2.elb.amazonaws.com 27017:31050/TCP 11m
Replicaset:
service/mongo-cdbrs-0 LoadBalancer 10.100.2.27 aec6d9995a39744dcb408481b9dd0005-2042329951.us-east-2.elb.amazonaws.com 27017:30790/TCP 11m
service/mongo-cdbrs-1 LoadBalancer 10.100.54.208 a4127e81a13bc40f0a5a1015a0910921-316818886.us-east-2.elb.amazonaws.com 27017:30516/TCP 11m
service/mongo-cdbrs-2 LoadBalancer 10.100.248.122 aa1f0620357d34ae8b34e6d1be1c6b6c-1226402236.us-east-2.elb.amazonaws.com 27017:32593/TCP 10m
~Adithya
1 Like
@Sergey_Pronin
Can this feature of having single LB (with custom name) for both replicaset and sharded cluster be included in future versions of percona operator ?
Regards,.
Adithya
1 Like
If we talk about one load balancer + multiple replica set nodes - the load balancer must be aware where Primary is and handle the failover.
Or if we talk about SRV records - load balancer does not help as well, as these SRV records would be pointing to internal IP-addresses in k8s networking.
How do you see it working?
1 Like