Connecting to cloud sql from a google container engine instance docker image running craft cms

7/7/2016

I am trying to externalise the database from a craft cms docker image running in a google container engine instance and connect it to a gcloud sql second generation instance running in the same project.

I've set the cloud sql permission to enabled in the cluster permissions section of the console and I've tried various authorisation settings in the access control settings of the database instance. I can only connect from the gcloud shell.

It seems I need a unix socket connection and I should be authorised to connect but when I deploy and run I see the dreaded CrashLoopBackOff error. I've tried the socket connection instance with and without the region, ip of the sql instance, with and without a password and authorising the 0.0.0.0/0 network... I can connect via the gcloud shell however. This is the connection of db.php in the craft/config folder

    'unixSocket' => '/cloudsql/website-1351:asia-east-1:pzr-craft-database',
    'user' => 'root',
    'password' => 'xxxxxxxx',
    'database' => 'craft',
    'tablePrefix' => 'craft',

Any idea how this can be achieved?

-- martin
gcloud
google-cloud-sql
google-container-registry
google-kubernetes-engine
php

1 Answer

7/7/2016

You need https://github.com/GoogleCloudPlatform/cloudsql-proxy to connect from GKE to Google Cloud SQL

-- Eric Tune
Source: StackOverflow