Saif Ali Khan
Saif Ali Khan

Reputation: 566

How to deploy Google Cloud Run with static ip address that is already reserved?

I have a project that is successfully deployed on Google Cloud Run with continuous deployment from GitHub. The application is working fine, my problem is that when each time I update the application, Google cloud assigns the application a new IP address. I want a static IP address each time I update the website on Github and it is redeployed...

I am new to Google cloud. I have checked Google docs and tried to fix it according to docs. I have created a VPC Connector. I have also redeployed a new Revision with VPC Connector but not sure how it works...

Thank you...

Upvotes: 1

Views: 905

Answers (1)

siamsot
siamsot

Reputation: 1575

You have to configure the VPC egress to send all the traffic through a VPC network that has a Cloud NAT gateway configured with a static IP address.

You have to create a Cloud Router

gcloud compute routers create ROUTER_NAME \
--network=NETWORK_NAME \
--region=REGION

and then reserve the static IP:

gcloud compute addresses create ORIGIN_IP_NAME --region=REGION

Then you create the NAT Gateway:

gcloud compute routers nats create NAT_NAME \
--router=ROUTER_NAME \
--region=REGION \
--nat-all-subnet-ip-ranges \
--nat-external-ip-pool=ORIGIN_IP_NAME

And finally you deploy your Cloud Run service with the command:

gcloud beta run deploy SERVICE_NAME \
--image=IMAGE_URL \
--vpc-connector=CONNECTOR_NAME \
--vpc-egress=all

Please note that this is still in Beta

Detailed instructions can be found here

Upvotes: 2

Related Questions