Score:0

How could I make Cloud Run communicate with a kubernetes cluster?

us flag

I deployed an image on Cloud Run where I need to make http calls to a service that is inside a Kubernetes cluster.

This service can be only accessed from a private network.

I read on that article that I need to connect the cloud run instance to my private VPC, then I need to create a load balancer that will be mapped to one of my k8s service. That will get me a external ip that will not change and I could use in Cloud Run.

Did I understand it right ?

Then, how could I assign a hostname to that external ip ? I would need to update the dns that cloud run uses I guess ?

jabbson avatar
sb flag
Sounds about right. Likely, no need for the ip to be external. And yes, to use the name you obviously would need to update the DNS mapping. Have you tried it, did you come across any issues?
Veera Nagireddy avatar
nl flag
Duplicate of [Stackoverflow Question](https://stackoverflow.com/questions/74235644)
Score:0
cl flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.