-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] cannot connect to replicaset mod mongodb outside k8s cluster #8373
Comments
In Kubeblocks 0.9.0, MongoDB support initialization with host networking, enabling access through the host IP outside of Kubernetes. Before using this feature, you should upgrade the MongoDB addon to version 0.9.1 and create a new cluster with the following commands: helm upgrade -i kb-addon-mongodb kubeblocks-addons/mongodb -n kb-system --version 0.9.1 helm install your-cluster-name kubeblocks-addons/mongodb-cluster --version 0.9.1 --set hostnetwork=enable |
Thank you for your reply, but it seems that the host network cannot meet my needs The main issue is that the host in the replicaset's conf is the headless domain of the service. the MongoDB driver will listens to the cluster topology and attempts to connect to these headless domains. I have attached the specific rs.conf() below. The initialization of the replica cluster and the member's joining and leaveing of cluster are managed by Lorry, seemingly only using headless domain names as hosts. This will result in the inability to connect to MongoDB outside the k8s cluster.
|
Yes, you're right. The MongoDB cluster topology is managed by Lorry, which supports headless services and host networking to configure the replicaset. However, it cannot recognize or use domains outside of Kubernetes. Is it possible to use the host network to initialize the MongoDB replicaset and use an external domain that points to the host IP? |
Thank you for your suggestion, I will try this solution.
I noticed that the hostnetwork only works when
What should I do next? Looking forward to your reply. By the way, I believe that using a host network can only meet the needs of testing and development, and there may be port conflicts or other risks in production practice. If there is another more graceful solution, it would be very helpful to me. |
I apologize for the issue and appreciate your response regarding the problem. The MongoDB addon was recently upgraded to a new API, and the host network is not functioning normally. We have fixed this in the new chart. Please upgrade using the same commands as before. The host ports are managed by KubeBlocks, which ensures that there are no conflicts with resources it controls. helm upgrade -i kb-addon-mongodb kubeblocks-addons/mongodb -n kb-system --version 0.9.1 helm install your-cluster-name kubeblocks-addons/mongodb-cluster --version 0.9.1 --set hostnetwork=enabled,mode=replicaset Another possible solution is to use the headless domain and configure IP mapping for this domain outside Kubernetes. This way, the domain name remains consistent inside and outside the cluster, though the IP addresses differ. (This might work, but i am not sure..) |
Describe the bug
when i try to connect to a deployed replicaset mode mongodb by golang mongo driver, the driver will monitor cluster topology and update topology to headless domain. But at outside of k8s cluster i can't resolve the headless domain, so it will occur error which "no such host".
I have expose the service by NodePort service, And if I directly connect a pod, it can work properly.
I noticed that Lorry uses the headless domain component Replicset topology. Is there any configuration to use custom external domains for component topology, or is there any other way for me to connect to MongoDB outside the k8s cluster?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
could connect mongodb outside k8s cluster.
Screenshots
Desktop (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: