Answered by @Gari Singh, post this answer to help other communities to serverfault
Assuming you are using Cloud Run and GKE, you'd need to take the following steps:
Create a Serverless VPC connector to connect Cloud Run to the VPC where your GKE cluster is deployed:
gcloud services enable vpcaccess.googleapis.com
gcloud compute networks vpc-access connectors create $CONNECTOR_NAME \
--network $VPC_NETWORK \
--region $REGION \
--range $IP_RANGE
Reserve a static internal IP address:
gcloud compute addresses create $ADDRESS_NAME \
--region $REGION --subnet $SUBNETWORK
Create a LoadBalancer for your GKE service and assign the static IP:
gcloud compute addresses describe $ADDRESS_NAME --region $REGION
The above command will show you the static IP you created
Create a load balancer service:
apiVersion: v1
kind: Service
metadata:
name: helloweb
annotations:
networking.gke.io/load-balancer-type: "Internal"
labels:
app: hello
spec:
selector:
app: hello
tier: web
ports:
- port: 80
targetPort: 8080
type: LoadBalancer
loadBalancerIP: "YOUR.IP.ADDRESS.HERE"
You can use the IP address directly from Cloud Run, but you could also create a DNS name using Cloud DNS as well.