How to securely connect to Cloud SQL from Cloud Run?

爷,独闯天下 提交于 2019-11-27 18:06:21

问题


How do I connect to the database on Cloud SQL without having to add my credentials file inside the container?


回答1:


UPDATE: to connect to Cloud SQL from Cloud Run see the official documentation


Cloud SQL is now supported by the fully managed version of Cloud Run (Cloud Run on GKE users were already able to use Cloud SQL using a private IP)

The feature is currently in alpha, so you need to use gcloud alpha (it will be in gcloud beta within 10 days):

To get started:

  • if you do not have one already, create a Cloud SQL instance.
  • make sure that the Cloud SQL admin API
  • deploy a new revision of your Cloud Run service with gcloud alpha and the following flag: $ gcloud alpha run services update --add-cloudsql-instances [INSTANCE_CONNECTION_NAME] Where is INSTANCE_CONNECTION_NAME is of the type project:region:instancename.

When yo do this, Cloud Run will activate and configure the Cloud SQL proxy for you. You should then connect to it via the /cloudsql/[INSTANCE_CONNECTION_NAME] Unix socket.



来源:https://stackoverflow.com/questions/55693241/how-to-securely-connect-to-cloud-sql-from-cloud-run

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!