Theres a NodeJS application deployed on GKE
MongoDB Atlas Peering Connection is successful with GCP VPC Peering Connection
However, NodeJS Application is throwing error with connection with MongoDB
What can I do to test connection from GKE Cluster to MongoDB?
The easiest way would be to deploy your nodeJS application and look at the application logs. If for some reason that's not working you could launch a mongo CLI pod, start a shell session and try to initiate the connection that way.
You mentioned the nodeJS application is throwing an error. You might want to copy paste that error here so people on StackOverflow can be of more help. It's important that you provide as much context as possible in your question.
Related
We have an airflow task that adds data to the mongodb server.
We can connect to the mongodb server only behind IP Access or VPC Peering.
We are having issues with VPC Peering, so we thought we can just enable direct IP access between the airflow workers and the mongodb server
Has anyone done that?
If not, do you have another suggestion?
I have deployed via terraform a setup with lambdas, mongodb cluster, aws vpc and a privatelink endpoint and my connection string isn't working. i am getting a timeout error from mongo.
My connection string is:
"mongodb+srv://:#XXXXXXXXXXXX-pl-0.XXXXX.mongodb.net/?retryWrites=true&w=majority"
I was wondering if it could be to do with security, maybe the ports i'm allowing are wrong, can someone advise what they should be?
Any ideas on why this isn't the connecting?
I have a project into PAYARA server full with JDBC Connectiones. The project works fine over VMs (actually GCP).
But I need migrate to GKE. I have a payara server full running on GCP POD but i don't know make a JDBC Connection to CLoudSQL.
Please helpme.
Take a look at the Cloud SQL connector for Java.
You might also be interested in the Cloud SQL Auth proxy, which is covered in the "Connecting from Google Kubernetes Engine".
I've set up the peering connection between MongoDB Atlas and Googles "default" VPC and the connection is labeled as "active" on both ends.
The ip range of the vpc is whitelisted in MongoDB Atlas.
But my node hosted in google-app-engine still gets timed out when accessing the MongoDB.
I use the connection url of mongodb atlas for peered connection in the form of (notice the "-pri"):
mongodb+srv://<username>:<password>#<my-cluster>-pri.rthhs.mongodb.net/<dbname>?retryWrites=true&w=majority
Which part am i missing to establich the connection? Do i need a google vpc connector?
Thanks for any help!
First of all, make sure you are running M10-Cluster or above!!! VPC-peering is not available for M0/M2/M5...
And YES you do need that connector! All "Serverless"-Services from Gcloud (like GAE in standard environment) need it.
create a connector in the same region as your GAE-App following these instructions. You can find the current region of your GAE-App with gcloud app describe
your app.yaml has to point to that connector like this
app.yaml
runtime: nodejs10
vpc_access_connector:
name: projects/GCLOUD_PROJECT_ID/locations/REGION_WHERE_GAE_RUNS/connectors/NAME_YOU_ENTERED_IN_STEP_1
Go to your Atlas project, navigate to Network Access and whitelist the IP-range you set for the connector in Step 1
You may also need to whitelist the IP-range from Step 1 for the VPC-Network. You can do that in GCP by navigating to VPC-Network -> Firewall
If you have questions about how to setup the VPC-Peering between Atlas and Gcloud try this tutorial. They do it for Kubernetes-Engine (no connector needed). But adding my steps from above will hopefully do the trick.
Try Cannot connect to Mongo Atlas using VPC peering from GCP cluster and MongoDB and Google Cloud Functions VPC Peering?.
First step I suggest identifying whether you have physical connectivity (and so need to fix ip whitelist) or don't have connectivity (and need to fix peering configuration).
I want to connect flask pod with mongodb in Kubernetes. Have deployed both but no clue how to connect them and do CRUD on it. Any example helps.
Maybe you could approach this in steps. For example, you could start with running a demo flask app in kubernetes like https://github.com/honestbee/flask_app_k8s Then you could look at adding in the database. First you could do this locally like in How can I use MongoDB with Flask? Then to make it work in kubernetes I'd suggest installing the mongodb helm chart (using its instructions at https://github.com/helm/charts/tree/master/stable/mongodb) and then doing kubectl get service to find out what service name and port the deployed mongo is using. Then you can put that service name and port into your app's configuration and the connection should work as it would locally because of kubernetes dns-based discovery (which I see you also have a question about but you don't necessarily need to know all the theory to try it out).