Search code examples
google-cloud-platformgoogle-kubernetes-enginegoogle-cloud-run

Can GCP's Cloud Run be used for non-HTTP services?


I'm new to GCP and trying to make heads and tails of it. So far, I've experienced with GKE and Cloud Run.

In GKE, I can create a Workload (deployment) for a service of any kind under any port I like and allocate resources to it. Then I can create a load balancer and open the ports from the pods to the Internet. The load balancer has an IP that I can use to access the underlying pods.

On the other hand, when I create a Could Run service, I'll give it a docker image and a port and once the service is up and running, it exposes an HTTPS URL! The port that I specify in Cloud Run is the docker's internal port and if I want to access the URL, I have to do that through port 80.

Does this mean that Cloud Run is designed only for HTTP services under port 80? Or maybe I'm missing something?


Solution

  • Technically "no", Cloud Run cannot be used for non-HTTP services. See Cloud Run's container runtime contract.

    But also "sort of":

    1. The URL of a Cloud Run service can be kept "private" (and they are by default), this means that nobody but some specific identities are allowed to invoked the Cloud Run service. See this page to learn more)
    2. The container must listen for requests on a certain port, and it does not have CPU outside of request processing. However, it is very easy to wrap your binary into a lightweight HTTP server. See for example the Shell sample that Uses a very small Go HTTP sevrer to invoke an arbitrary shell script.