1. Created Cloud SQL in Menu SQL

2. Created Service Account and for role make sure to select, Cloud SQL > Cloud SQL Client, Cloud SQL > Cloud SQL Editor, Cloud SQL > Cloud SQL Admin, upload .json file to instance ( we created instances in point 2 )
This file for credential connection cloud sql proxy between our instances and cloud sql.

3. Make sure when Created instance, Boot disk -> deletion rule -> Delete boot disk when instance is deleted is Uncheck.
install & configure all services we need such as, lib-apache2-mod-php, php-mysql, download file cloud sql proxy and create custom service for systemd for persistent connection between instance and cloud sql using cloud sql proxy

4. Created Instance Template from instances disk we had configure in Point 3.

5. Created Instance Group, choose Instance Template we created before, set up autoscaling, min and max instances, etc.

6. Configure Load Balancing, and created Backend, and choose Backend type Instances Group we had created before then created Frontend

7. Access IP from frontend Load Balancing we created before

Sources Code :

  • download cloud_sql_proxy and copy file under /usr/local/bin
sudo wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
  • make following folders, and upload .json file from service account under /var/local/cloud-sql-proxy
mkdir -p /var/run/cloud-sql-proxy

mkdir -p /var/local/cloud-sql-proxy
  • created file cloud-sql-proxy.service under /etc/systemd/system and copy below gist. after that start service, systemctl start cloud-sql-proxy

Description=Google Cloud Compute Engine SQL Proxy

ExecStart=/usr/local/bin/cloud_sql_proxy -dir=/var/run/cloud-sql-proxy -instances=ca-niko-test:us-central1:nds-csql=tcp:3306 -credential_file=/var/local/cloud-sql-proxy/ca-niko-test-612577e1f21a.json