How to run mongo on specific port in k8s 3 node replica set?


How to run mongo on specific port in k8s 3 node replica set?

Steps to Reproduce:

I deployed 3 node replica set using cr.yaml and as expected it deployed 3 node replica set with default port 27017. I want to run mongo on custom port. How can I make it happen? What changes I need to do in cr.yaml for this?


I am using operator 1.15


[If applicable, include any relevant log files or error messages]

Expected Result:

[What the user expected to see or happen before the issue occurred]

Actual Result:

[What actually happened when the user encountered the issue]

Additional Information:

[Include any additional information that could be helpful to diagnose the issue, such as browser or device information]

1 Like

Hello @Bhanu ,

right now it is not possible with Operator directly. If you expose a replica set through the expose section with ClusterIP or LoadBalancer - it will use 27017.
If you use NodePort - it will randomly pick a port.

There are other ways:

  1. Some custom service mesh (like istio) or TCP ingress. There you can set it up and have it exposed through another port.
  2. Manually create services of your choice on top of the ones that Operator provisions.

We might think how it can be done through the Operator. What is your use case here? Why 27017 does not work for you?

1 Like

Hi Sergey,

We would like to avoid default port for security reasons. I am exposing cluster with LoadBalancer.

We are using TCP ingress. Can you provide me a sample of transportservice yaml file to custom port 30000 from default 27107?

Thank you