1

I am following this article[1] to get a fixed IP address of my Cloud Run instance, but my project already uses cloud memorystore (Redis) which requires a VPC serveless connector that I already using.

This is my serveless connector for Redis

gcloud beta compute networks vpc-access connectors list --region us-central1
CONNECTOR_ID         REGION       NETWORK  IP_CIDR_RANGE  SUBNET  SUBNET_PROJECT  MACHINE_TYPE  MIN_INSTANCES  MAX_INSTANCES  STATE
serveless-connector  us-central1  default  10.8.0.0/28                            e2-micro      2              3              READY

And I deploy with the following command line

gcloud beta run deploy service --vpc-connector=serveless-connector...

But on the documents, it seems to be nescessary another VPC connector on Cloud Run, in order to get the outbound NAT.

Is there some way to get Redis with VPC connector AND a static IP address?

UPDATE

If I run

gcloud compute networks subnets create subnet \
--range=10.8.0.0/28 --network=default --region=us-central1 --project ${PROJECT_ID} 

I got the error:

 - Invalid IPCidrRange: 10.8.0.0/28 conflicts with existing subnetwork 'aet-uscentral1-serveless--connector-sbnt' in region 'us-central1'.

1 - https://cloud.google.com/run/docs/configuring/static-outbound-ip

Rodrigo
  • 135
  • 4
  • 45
  • 107
  • 1
    You can use the same connector, just follow the steps in the doc you share – Puteri Nov 01 '21 at 19:19
  • 1
    You need to configure the egress (set it to all) if you want an external static IP with Cloud Nat, but there is no problem: Private IP to reach Memory store and public IP to reach something else and use Cloud NAT to get a static IP – guillaume blaquiere Nov 01 '21 at 20:55
  • Please, see my updated question – Rodrigo Nov 01 '21 at 21:00
  • Yes, if you create 2 connectors with the same IP range, it's a problem!! Try to use `10.8.0.128/28` instead – guillaume blaquiere Nov 02 '21 at 10:23
  • 1
    I deleted the previous connector and created again using the tutorial and worked! Here my steps https://pastebin.com/raw/QAJ43cJS – Rodrigo Nov 02 '21 at 11:05

1 Answers1

1

Posting the correct solution as community wiki. I deleted the previous connector and created again using the tutorial and worked! Here my steps.

```shell
gcloud compute networks subnets create subnet \
  --range=10.8.0.0/28 \
  --network=default \
  --region=us-central1 \
  --project=${PROJECT_ID} 
```

```shell
gcloud compute networks vpc-access connectors create vpc-access-connector \
  --region=us-central1 \
  --subnet-project=${PROJECT_ID} \
  --subnet=subnet \
  --project=${PROJECT_ID}
```

```shell
gcloud compute routers create router \
  --network=default \
  --region=us-central1 \
  --project=${PROJECT_ID}
```

```shell
gcloud compute addresses create ipddr0 --region=us-central1 --project=${PROJECT_ID}
```

```shell
gcloud compute routers nats create nat \
  --router=router \
  --region=us-central1 \
  --nat-custom-subnet-ip-ranges=subnet \
  --nat-external-ip-pool=ipddr0 \
  --project=${PROJECT_ID}
```
Vicente Ayala
  • 191
  • 10