What is the Docker image for the Cloud SQL proxy and why is it used?

10/14/2018

I'm following the tutorial on how to deploy a Django application to the Kubernetes Engine in the Google Cloud Platform and on step 9 it does this:

  1. Retrieve the public Docker image for the Cloud SQL proxy.

    docker pull b.gcr.io/cloudsql-docker/gce-proxy:1.05

What is this Cloud SQL proxy image? Am I understand it correctly that the application, the web workers, are deployed to images built on top of the Cloud SQL proxy image? Is this so that they can access the database?

Looking at the yaml file for the application, it looks like the image generated out of the Cloud SQL proxy will be running the application bu then there's another container that is just the cloudsql-docker image. Why is this second container needed?

-- pupeno
docker
google-cloud-platform
google-kubernetes-engine
kubernetes

2 Answers

6/17/2019

I just came through a similar situation. If you are running your app in a container on a Google cloud Instance and if you wanna connect to Google Cloud SQL, just use Cloud SQL Proxy docker. Link your app container with Cloud SQL Proxy docker Container. Plus keep the MySQL host name in app as SQL Proxy container name instead of localhost.

Its most useful when running managed instance groups with load balancer

Reference: https://forums.docker.com/t/app-container-cannot-access-mysql-container/6660

-- Blesson
Source: StackOverflow

10/14/2018

I'm sure some other people that actually understand Kubernetes, Docker and GCP will chip in with better answers, but I wanted to drop in what I've learned so far in case others arrived here with the same question.

What is this Cloud SQL proxy image?

That is a Docker image that runs the Cloud SQL proxy which is explained here: https://cloud.google.com/sql/docs/postgres/sql-proxy

I'm still not 100% sure why this SQL Proxy is used though.

Am I understand it correctly that the application, the web workers, are deployed to images built on top of the Cloud SQL proxy image?

That was wrong. This command:

docker build -t gcr.io/<your-project-id>/polls .

uses the Dockerfile from the git repo which states gcr.io/google_appengine/python as the base image for the app image.

-- pupeno
Source: StackOverflow