Home > Net >  How do I get the status.podIP within the container program in GCP Cloud Run?
How do I get the status.podIP within the container program in GCP Cloud Run?

Time:02-11

I am trying to run a container image in GCP Cloud run.

Tech Stack: .NET 6, C#, Orleans.NET, ASP.NET

My code requires the podIP to work properly.

This programs works properly in a regular Kubernetes cluster, because I am able to set an environment variable with the assigned podIP with the following configuration in the "env" section of the deployment.yaml file:

  - name: POD_IP
    valueFrom:
      fieldRef:
        fieldPath: status.podIP

When I try to provide the same in Cloud Run yaml, I get: GCP Cloud Run - YAML Edit

When I tried digging into the documentation of k8s.io.api.core.v1,

GCP Cloud Run - Documentation

This is saying that "Not supported by Cloud Run".

Is there any way to set podIP in the environment variable of GCP - Cloud Run?

CodePudding user response:

Cloud Run is a serverless product. As serverless product, you don't manage the servers and the network. Therefore, asking for the podIP make no sense and has no value (at least, it will be a private IP in the Google Cloud serverless network).

So, the answer is "NO, you can't get the podIP".

But why do you need it? You can set a dummy value and see what happens we your container. Or to update your code to make optional that value.

  • Related