Connect from Kubernetes
This guide shows you how to connect to a MongoDB cluster from your managed Kubernetes cluster.
Prerequisites
Before connecting to a MongoDB cluster from your managed Kubernetes, make sure you have:
A data center with id
xyz-my-datacenter
.A private LAN with id
3
.A MongoDB cluster connected to LAN 3, with the connection string
mongodb+srv://m-xyz-example.mongodb.de-txl.ionos.com
.A Kubernetes cluster with id
xyz-my-k8s-cluster
.ionosctl
set up with your IONOS credentials.
Note: In this guide, we use DHCP to assign IP addresses to node pools. Therefore, it is important that the database is in the same subnet that is used by the DHCP server.
1.To enable connectivity, connect the node pools to the private LAN with the MongoDB cluster.
2. Wait for the node pool to become available. To test the connectivity you can create a pod that contains the MongoDB tool mongosh
. If you have multiple node pools, make sure to schedule the pod on one of the node of the node pools that are attached to the private LAN.
3. Create the pod by using the following command:
4. Attach the pod to the cluster by using the following command:
Result: You see the database is accepting connections.
If you see connection issues, make sure that the node is properly connected to the LAN. To debug the node, use a debugging container.
Last updated