我有一张可以运行我的培训工作的图像。训练数据位于 Cloud SQL 数据库中。当我在本地机器上运行 cloud_sql_proxy 时,容器可以正常连接。
❯ docker run --rm us.gcr.io/myproject/trainer:latest mysql -uroot -h"'172.17.0.2'" -e"'show databases;'"
Running: `mysql -uroot -h'172.17.0.2' -e'show databases;'`
Database
information_schema
mytrainingdatagoeshere
mysql
performance_schema
我mysql
只是用来测试连接,实际的训练命令在容器的其他地方。当我通过 AI Platform 尝试此操作时,我无法连接。
❯ gcloud ai-platform jobs submit training firsttry3 \
--region us-west2 \
--master-image-uri us.gcr.io/myproject/trainer:latest \
-- \
mysql -uroot -h"'34.94.1.2'" -e"'show tables;'"
Job [firsttry3] submitted successfully.
Your job is still active. You may view the status of your job with the command
$ gcloud ai-platform jobs describe firsttry3
or continue streaming the logs with the command
$ gcloud ai-platform jobs stream-logs firsttry3
jobId: firsttry3
state: QUEUED
❯ gcloud ai-platform jobs stream-logs firsttry3
INFO 2019-12-16 22:58:23 -0700 service Validating job requirements...
INFO 2019-12-16 22:58:23 -0700 service Job creation request has been successfully validated.
INFO 2019-12-16 22:58:23 -0700 service Job firsttry3 is queued.
INFO 2019-12-16 22:58:24 -0700 service Waiting for job to be provisioned.
INFO 2019-12-16 22:58:26 -0700 service Waiting for training program to start.
ERROR 2019-12-16 22:59:32 -0700 master-replica-0 Entered Slicetool Container
ERROR 2019-12-16 22:59:32 -0700 master-replica-0 Running: `mysql -uroot -h'34.94.1.2' -e'show tables;'`
ERROR 2019-12-16 23:01:44 -0700 master-replica-0 ERROR 2003 (HY000): Can't connect to MySQL server on '34.94.1.2'
似乎无法从作业运行的任何地方访问主机。 如何授予 AI 平台对 Cloud Sql 的访问权限?
我已经考虑在训练容器中包含云 sql 代理,然后将服务帐户凭据作为用户 args 注入,但由于它们都在同一个项目中,我希望不需要这一步。这些希望是不是落空了?