简体   繁体   English

从GCE VM应用程序连接到Cloud SQL专用IP

[英]Connecting to Cloud SQL private IP from GCE VM application

I am checking Cloud SQL Private IP connections from different types of clients. 我正在检查来自不同类型客户端的Cloud SQL专用IP连接。 I could successfully make a connection from an application hosted in a GKE cluster which was created as a VPC-native cluster as described here . 我可以顺利地从在描述这是一个VPC-本地集群创造了GKE集群托管的应用程序的连接在这里 Having already done this, I was expecting it would be easier to connect to the Private IP from the same application (which is a simple Spring Boot application) hosted in a GCE VM. 完成此操作后,我期望从GCE VM中托管的同一应用程序(这是一个简单的Spring Boot应用程序)连接到私有IP会更容易。 Contrary to my expectations this does not appear to be so. 与我的期望相反,事实并非如此。 It is the same Spring Boot application that I am trying to run inside a VM. 这是我尝试在VM内运行的同一Spring Boot应用程序。 But it does not seem to be able to connect to the database. 但是它似乎无法连接到数据库。 I was expecting some connection error but nothing shows up - no exception thrown. 我期待一些连接错误,但是什么都没有出现-没有抛出异常。 What is strange is I am able connect to the Cloud SQL Private IP via mysql command line from the same VM but not from within the Spring Boot application. 奇怪的是我能够通过mysql命令行从同一VM连接到Cloud SQL Private IP,但不能从Spring Boot应用程序内部连接到Cloud SQL Private IP。 Anyone out there who faced this before? 有人以前遇到过这个吗?

Issue was not related Cloud SQL Private IP. 问题与Cloud SQL专用IP不相关。 As mentioned in my earlier comment, I was passing active profile info via Kubernetes pod configuration. 如我先前的评论中所述,我正在通过Kubernetes pod配置传递活动的配置文件信息。 So the Dockerfile did not have this info. 因此,Dockerfile没有此信息。 To fix the issue, I had to pass active profile info when the program was initialized outside Kubernetes. 为了解决这个问题,当程序在Kubernetes外部初始化时,我必须传递活动的配置文件信息。 This has a lot of helpful answers how to do this. 如何执行此操作有很多有用的答案。 If the program is being started via a docker run command the active profile info can be passed as a command line argument. 如果通过docker run命令启动程序,则可以将活动配置文件信息作为命令行参数传递。 See here for a useful reference. 请参阅此处以获取有用的参考。

So to summarize, Cloud SQL Private IP works fine from a CE VM. 综上所述,Cloud SQL Private IP可从CE VM正常运行。 No special configuration required at GCE VM end to get this working. 在GCE VM端不需要特殊配置即可使此工作正常进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过GCE或GKE使用私有IP连接到Cloud SQL - Connecting to Cloud SQL with Private IP from GCE or GKE 从具有私有和公共 IP 的虚拟机连接到私有 IP 上的 Google Cloud SQL 实例失败 - Connecting to Google Cloud SQL instance on private IP from a VM with both private and public IPs fails 使用外部 IP 连接到在 Cloud GCE VM 上运行的 Docker 容器中的 HTTPS 服务器 - Connecting to HTTPS server in Docker container running on Cloud GCE VM with external IP 在 perl 中从 GCE 远程连接到 Google Cloud SQL 时出错 - Errors connecting remotely to Google cloud SQL from GCE in perl GCE SQL代理连接到错误的SQL IP - GCE SQL proxy connecting to wrong sql ip GCP Cloud Functions 使用私有 IP 连接到云 sql - GCP Cloud Functions connecting to cloud sql with private IP 使用 Knex.js 连接到 GCE VM 上的 Cloud SQL PostgreSQL 实例时出错 - Error while connecting to Cloud SQL PostgreSQL instance on GCE VM with Knex.js 使用公共和私有 IP 从 VM 连接到 Cloud SQL 实例 - 如何确保为连接选择正确的网络接口? - Connecting to a Cloud SQL instance from VM with public and private IPs - how to ensure the right network interface is chosen for the connection? Cloud Sql Proxy 私有IP 外部应用 - Cloud Sql Proxy Private IP External application GCP 使用 VM 通过 Cloud SQL Auth Proxy Private IP 连接到 Cloud SQL - GCP using VM to connect to Cloud SQL via Cloud SQL Auth Proxy Private IP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM