Hi,
I've tried googling but I only find solutions to problems with private Cloud SQL instances. I'd be grateful for any help as I've been banging my head half of the day...
gcloud container clusters create my-cluster \
--disk-size=10GB \
--machine-type=e2-small \
--node-locations=us-central1-b,us-central1-c,us-central1-f \
--num-nodes=1 \
--preemptible \
--release-channel=regular \
--workload-pool=my-project.svc.id.goog \
--zone=us-central1-f \
--no-enable-master-authorized-networks \
--enable-ip-alias \
--enable-private-nodes \
--master-ipv4-cidr 172.16.0.32/28
And a Cloud SQL instance created with:
gcloud sql instances create my-db \
--database-version=POSTGRES_12 \
--region=us-central1 \
--storage-auto-increase \
--storage-size=10 \
--storage-type=SSD \
--tier=db-f1-micro
In my pod I have the following sidecar container:
- name: cloud-sql-proxy
image: gcr.io/cloudsql-docker/gce-proxy:1.20.2
command:
- "/cloud_sql_proxy"
- "-instances=my-project:us-central1:my-db=tcp:5432"
- "-term_timeout=20s"
securityContext:
runAsNonRoot: true
The pod uses a service account that has been created and configured with these commands:
Now when I try to connect to Postgres through cloud-sql-proxy in my app, the connection times out with the following error in cloud-sql-proxy's logs:
2021/03/19 21:51:29 couldn't connect to "my-project:us-central1:my-db": dial tcp MY_DB_PUBLIC_IP:3307: connect: connection timed out
Interestingly enough, I can run cloud-sql-proxy on my laptop to connect to the same instance without any problems. I checked my app's container in the pod and it has access to public Internet. What am I missing?
Thanks,
Juliusz