I have an image which will run my training job. The training data is in a Cloud SQL database. When I run the cloud_sql_proxy on my local machine, the container can connect just fine.
❯ 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
I'm using mysql
just to test the connection, the actual training command is elsewhere in the container. When I try this via the AI Platform, I can't connect.
❯ 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'
It seems like the host isn't accessible from wherever the job gets run. How can I grant AI platform access to Cloud Sql?
I have considered including the cloud sql proxy in the training container, and then injecting service account credentials as user args, but since they're both in the same project I was hoping that there would be no need for this step. Are these hopes misplaced?