google-cloud-platformgoogle-cloud-sqlcloud-sql-proxy

Trying to find the `recommended dns` data for GCP Cloud SQL instance


I'm working through the documentation for connecting to a private Cloud SQL instance. I created the instance with a private IP (no public access), set up cloud sql proxy on my local, and am able to connect to the network successfully. However, I see in the docs that the console does not automatically add the required private dns records to go from the proxy to the db instance.

When I run this with my sql instance, I do not see the mentioned recommended dns record in the result like the documentation claims exists.

gcloud sql instances describe INSTANCE_NAME \
--project=PROJECT_ID

I do get all the other configuration data, but nothing that matches the suggested dns format: INSTANCE_UID.PROJECT_DNS_LABEL.REGION_NAME.sql.goog.

My instance is a second gen, so I don't know if that has something to do with it. I'd like to get this working via the console before I seek to automate it with Terraform, e.g. I plan on automating this later, but that is not my current goal.


Solution

  • I tried to reproduce the issue at my end. At first I also have created the instance from the console by selecting only private IP as network as shown below

    image

    I am also unable to see cloud DNS names. It seems like this is expected behavior when an instance is created from the console. As you can observe in the above screenshot,cloud SQL launches instances in PSA(Private Service Access) with Private IP as an option. However to have a cloud DNS name, Instance should be launched in PSC(Private Service Connect) mode and as per doc Create a Cloud SQL instance launching cloudSQL in PSC is not available via console.

    To cross verify this,I have launched the instance with --enable-private-service-connect option as stated in above doc, Then I am able to see DNS name with pattern INSTANCE\\\_UID.PROJECT\\\_DNS\\\_LABEL.REGION\\\_NAME.sql.goog. in both console and gcloud sql instances describe command output.

    This confirms to me that, To have a DNS name instance should be launched in PSC.

    Please go through DNS names and records and PSC blog to have a better understanding of DNS and Private Service Connect.