Reputation: 16821
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?
Upvotes: 13
Views: 4683
Reputation: 4219
To keep this question relevant, I would like to add some updates since the accepted answer was posted. In the end of 2021 Google announced new CPU allocation controls. As mentioned on Use Cloud Run "always-on" CPU allocation for background work:
With this release, users can now alter this behavior so the CPU is always allocated and available even when there are no incoming requests (so long as the container instance is up). Setting the CPU to be always allocated can be useful for running background tasks and other asynchronous processing tasks.
Along with this, you also have the option to not allow public incoming traffic, if that's what you are interested in.
Upvotes: 1
Reputation: 7909
Technically "no", Cloud Run cannot be used for non-HTTP services. See Cloud Run's container runtime contract.
But also "sort of":
Upvotes: 11