Cloud Run
In my Hands on Knative series (part 1, part 2, part 3), I showed how to use Knative Serving, Eventing and Build on any Kubernetes cluster anywhere. This is great for portability but with that portability comes the overhead of creating and managing a Kubernetes cluster. Not to mention the complexity of Istio which is a dependency of Knative.
Google Kubernetes Engine (GKE) helps with managing the Kubernetes cluster a little but you still need to worry about all the bells and whistles of a Kubernetes cluster. Wouldn’t it be great to have the Knative Serving experience without having to worry about the underlying infrastructure? Well, you can with Cloud Run!
Cloud Run is a managed serverless platform of Google Cloud that enables you to run stateless containers invocable via HTTP requests. Cloud Run is built from Knative. This means that you can take the container of your Knative service and deploy to fully managed Cloud Run, or in your GKE cluster with Cloud Run on GKE. You get the same experience and features of Knative Serving such as autoscaling, versioning, etc.
In Hello World Serving example of my Knative Tutorial, we built a service that simply replied back with “Hello C# Sample v1”. It was a very simple service in the end but we had to do a lot pre-work before we could deploy the service, namely:
- Create a GKE cluster.
- Install Istio on the GKE cluster.
- Install Knative components (Serving, Eventing, Build) on the GKE cluster.
- Build and push a container image to DockerHub
- Create a Knative service yaml file for the service.
- Configure a domain for the Knative service
- Finally, deploy the Knative service
A lot of steps for a simple service! In Cloud Run, things are much more simple. The main advantage of Cloud Run is that it’s fully managed, so no infrastructure or Kubernetes to worry about. It also comes with a simple and intuitive command-line and user interface to quickly deploy and manage your serverless containers.
What does it take to deploy the same Hello World Serving example of my Knative Tutorial to Cloud Run? It’s literally 2 gcloud commands.
First, build and push the same container images to Google Container Registry (GCR):
gcloud builds submit --tag gcr.io/cloudrun-atamel/helloworld-csharp:v1
Second, deploy to Cloud Run:
gcloud beta run deploy --image gcr.io/cloudrun-atamel/helloworld-csharp:v1
That’s it! If you want to see the details, you can check out Deploy to Cloud Run part of my Knative Tutorial.