Rails5、Google容器引擎和Google云SQL

Rails 5, Google Container Engine and Google Cloud SQL

我正在尝试将部署在 Google 容器引擎中的 Rails 应用程序连接到 Google 云 SQL 中托管的数据库。

我正在关注 this documentation。根据它,我的 pods 有两个容器:spike 和 cloudsql-proxy。

在这个页面中,我们可以看到下面一行:

Provide 127.0.0.1:3306 as the host address your application uses to access the database.

在这个过程的最后,我得到了这个:

Return 共 kubectl logs [pod_name] cloudsql-proxy

2017/05/03 09:50:43 Listening on 127.0.0.1:3306 for [instance_connection_name]
2017/05/03 09:50:43 Ready for new connections

并在 kubectl exec -it [pod_name] -- /bin/bash、return 中 cat log/production.log

ActionView::Template::Error (Unknown MySQL server host '127.0.0.1:3306' (25))

是不是很好玩?

我在 中找到了灵感。

结果是 database.yml,而不是

production:
 host: 127.0.0.1:3306

应该是

production:
 host: 127.0.0.1