Google Kubernetes Engine (GKE) vs. Cloud Run
What is Google Kubernetes Engine (GKE)?
Kubernetes (K8s) is an extremely popular, open source, container orchestration platform. GKE is a managed offering for running Kubernetes clusters in GCP. GKE handles a lot of the heavy lifting, fully managing the K8s cluster lifecycle and getting you from zero to deploying a Helm chart in ~5–10 minutes.
What is GCP Cloud Run?
Cloud Run is a serverless managed offering for running containerized API-style services. If you have a containerized API, Cloud Run can host the service and provide full scale-to-zero elasticity. More recently, Cloud Run Jobs were announced, which run containerized work loads which have a definitive start and finish (e.g. process data and drop results in GCS, etc.).
Do we have a clear use case for Kubernetes (K8s) beyond what Cloud Run offers?
If you are looking to run a containerized API or a Job/Task, then Cloud Run is likely the best option due to lower knowledge pre-requisities and native integration with other GCP services.
- From a Total Cost of Ownership (TCO) perspective, it is far more simple to deploy a new service. The learning curve that is necessary with K8s does not exist — Cloud Run is nearly as straightforward as telling the service to start hosting a particular containerized application.
- Cloud Run enables auto-scaling down to zero, unlike a GKE cluster.
- Configuring features like ingress for a public-facing API is much easier in Cloud Run than Kubernetes. With Cloud Run, one needs only to set up a domain mapping to the desired service instance. With K8s, clsuter Ingress, static IPs, and domain certificates need to be separately configured to achieve the same effect.
- Connection to a Cloud SQL database is more simple in Cloud Run as well, with only four additional lines of Terraform needed vs. a less direct process with GKE.
- Logs presented in Cloud Run and Cloud Run Jobs are trivial to find, whereas with GKE getting to the right set of logs for your application requires more knowledge of how K8s operates (Should we look for logs at the workload level, the service level, the deployment level, the application level, or the container level in GKE?).
Of course, Kubernetes did not get so popular on accident, so when would something like GKE have an advantage?
When should we consider GKE/Kubernetes over Cloud Run?
- Orchestrating containers that are not API services or longer running Jobs. This scenario is simple and perhaps most obvious; GKE can handle other scenarios that Cloud Run cannot, such as hosting a Postgresql database (whether this example is actually preferable to a managed offering like Cloud SQL is another question entirely).
- Hybrid or multi-cloud portability is critical. Cloud Run is a service unique to GCP. A K8s-based orchestration approach enables more flexibility should your organization want to move to another cloud provider or to an on-premise hosting.
- We have a K8s expert who can take advantage of the lower-level configurability that Terraform offers. Your organization may have the capacity and desire to control your container orchestration at a lower-level than the abstraction that Cloud Run provides. GKE let’s you operate at that lower level.
If looking to host a containerized API service or execute a longer-running containerized Job, Cloud Run and Cloud Run Jobs make it about as simple as can be, while exceeding the scalability that GKE can offer — in particular automatically scaling to 0. For these use cases, it is easy to see the advantage of Cloud Run in terms of a lower Total Cost of Ownership and learning curve.
There are scenarios, however, where an organization’s needs and capabilities will push them towards orchestration via GKE and K8s, which we also discussed. Unless these constraints are present within your organization, however, Cloud Run is likely the way to go.
dragondrop.cloud’s mission is to automate developer best practices while working with Infrastructure as Code. Our flagship OSS product, cloud-concierge, allows developers to codify their cloud, detect drift, estimate cloud costs and security risks, and more — while delivering the results via a Pull Request. For enterprises running cloud-concierge at scale, we provide a management platform. To learn more, schedule a demo or get started today!
Learn More About GCP
When it comes to running containerized, long-duration workloads in the cloud, AWS Fargate Tasks and GCP Cloud Run Jobs are two options worth considering. AWS Fargate Tasks have been around for quite some time in cloud years (since 2018 ), while GCP Cloud Run Jobs were...
How can long running Cloud Run Jobs be dynamically trigged via an API endpoint?
Securely accessing Google Cloud SQL instances while minimizing system complexity and cost.