Sunday, June 21, 2020

[google-cloud-sql-discuss] Google Cloud Compute Instance doesn't work as expected with startup script

I've created an Google Cloud Compute Engine Instance Template where I specify a docker container image to be used (hosted privately on Google Container Registry).
For my app I need to have Google Cloud Sql Proxy running, so I followed these steps and added a startup script on my Compute Engine Instance Template like this:

    #! /bin/bash
    wget https
://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O /var/lib/google/cloud_sql_proxy
    chmod
777 /var/lib/google/cloud_sql_proxy
    sudo
/var/lib/google/cloud_sql_proxy -instances={instance name} &

The issue I have is that when I create an Compute Engine VM Instance based on this template
   
gcloud compute instances create {instance name} --source-instance-template {template name}

The instance is created and starts and I can see that cloud_sql_proxy script is running, BUT the docker image is not pulled neither does the container starts...

I've tried to create an Compute Engine VM Instance without specifying the startup script and it works correctly, the docker image is pulled and the container starts running.
And with the Compute Instance running, I've connect via ssh and start the cloud_sql_proxy script manually and everything works (the apps connects successfully to the SQL instance on Google Cloud SQL).
But I want to have this automated...

What am I missing? Has anybody had this issue?

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/43784a2a-2d3d-43b0-bd22-d971f6340e47o%40googlegroups.com.

No comments:

Post a Comment