7

I'm trying to deploy a gcp postgres instance using private IP's into the same network, default as a kubernetes cluster with IPAliasing enabled.

There are a handful of other k8s clusters deployed to the default network as well.

When I try to create a new Postgres instance using that network I get the following error:

Failed to create subnetwork. Couldn't find free blocks in allocated IP ranges. Please allocate new ranges for this service provider.

I've tried to allocate more IP addresses in the VPC network details page, under the "Private service connection" tab, but I'm unsure how to make use of this new IP range, without disrupting connections to existing services using an already created ip range.

Kit
  • 20,354
  • 4
  • 60
  • 103
Nick
  • 151
  • 1
  • 4

3 Answers3

7

So it turns out the solution was to go into "VPC Networking" then click on the "default" network. From here click on the link that says "Private service connection".

Here I clicked on the Allocate IP Range button and allocated a new /24 range.

After you create this new range you need to click on the submenu item called "Private connections to services".

then click on the connection name. In my case it was cloudsql-postgres-googleapis-com and then assign the new allocation.

the problem wasn't quite as hard as I initially thought. But more comes down to UI fail on Google's part. It's clear that that there can be multiple allocations assigned. And my fear of replacing an allocation and bringing down another service kept me from trying to click on the new allocation.

After you update this private connection you should be able to create new GCP Postgres instances using private IP's.

Nick
  • 151
  • 1
  • 4
1

For me, the allocation was not mapped properly. Google docs have improved now. You can refer to this 1 and make sure private service access has been configured properly.

avinava basu
  • 119
  • 4
1

So I was able to fix this issue by first allocating an IP CIDR range for my SQL instance. This could be done by going to VPC networks and then allocate a IP range for the private CIDR range using to Allocated IP ranges for service option.

Once this is done we will need to add this CIDR Range in Private Connection to Service. If there is an existing connection then you will need to use the below command to force and add this CIDR range to the private connection:

gcloud beta services vpc-peerings update --network=<vpc-name> --ranges=<allocated-CIDR-range> --project=<project-id>--force

Once I ran this command I was able to create an SQL Postgres instance with Private IP.