Practice Exams:

Google Associate Cloud Engineer – Google Cloud Run

  1. Step 01 – Getting Started with Google Cloud Run

Welcome back. In the previous sections, we talked about Kubernetes. When we talked about Kubernetes, we needed to create a cluster. How about an easier way of deploying containerized applications? That’s the idea behind Cloud run. Cloud Run is container to production in seconds. So you have a container to deploy. You can go to production in seconds. Now, before I do anything, what we’ll do is we’ll start with a demo for Cloud Run. So let’s go over to our browser. I would continue using my first project, and over here I would type in Cloud Run. So this is where Cloud run is. I can go in there. When we used Kubernetes, we needed to create a cluster and then deploy our microservices. However, when we use Cloud Run, I can just say create service.

And this would also enable the cloud run API. So it’s enabling the cloud run API. Right now, I’d give the service a name. My first Cloud Run service. The Cloud Run API is now enabled. That’s awesome. You can pick a region where you want to run Cloud Run on. I’ll use the first one which is recommended. It does not really matter. The first thing you can see is you need to choose whether you’d want to go for Cloud Run or Cloud Run for Anthos. I don’t want to worry about clusters and anything. So I’ll use the fully managed cloud run version and I’ll say next. And as you can see in here, the first thing I would need to do is to select the services first revision. And I would need to pick up a container image from the Google Container Registry.

Instead of actually trying to build a container image, what we’ll use is an image which is provided by Google Cloud. So if you click select, you can see that there are a few demo containers which are available. So I’ll go to the demo containers and pick up the hello one and say select. Any container image which is deployed to Google Container Registry can be deployed in here. For now, we are using a sample image which is provided by Google Cloud. I’ll go ahead and say Next. And over here you can configure how this service is triggered. What we want is we want to elaborate ingress from everywhere. If you want, you can actually allow internal traffic from cloud load balancing. Or you can say, I only want internal traffic from within the network.

I would choose Allow all traffic. I don’t really want to worry about authentication. So let’s say Allow unauthenticated invocations. And I would go ahead and say Create. You can see that once you have a container with very, very minimum configuration, you’d be able to easily deploy your service using Cloud Run. So the idea behind Cloud Run, as it says in here, is container to production in seconds. That’s cloud run. So this is built on top of an open standard which is called Knative. This is a fully managed serverless platform for containerized applications. Zero infrastructure management. You can see that we did not create a cluster at all. We directly created, we directly deployed the container. This is again paper for use your pay for used CPU, memory requests and networking.

It provides you with a fully integrated end to end developer experience. There are no limitations in languages, binaries and dependencies. Because we are using containers, it is easily portable. Because you are running containers. You can deploy containers in Cloud Run or Kubernetes. You can even deploy containers in App engine as well. So it’s very portable. And you can also deploy containers in other cloud environments as well. And Cloud Run integrates very well with cloud code. It’s an editor cloud build. It’s a CI CD tool. Cloud monitoring and cloud logging. While I was talking about Cloud Run, I saw that the service is deployed and ready. The interesting thing for you to remember is the terminology. So we created a service and inside a service we can have multiple revisions.

So we are looking at the first revision of this specific service. You can see the URL of it. In here you can click this URL and you can see that application is running in Cloud Run. You can see a few more details about the application. So it gives me the revision details, the service details, where it is running, and the project details as well. Let’s close this and go back to Cloud Run. Over here you can see that you can get metrics around this service. So if you give a little while, you’d see that metrics would be populated with request count, request latencies and a lot of other metrics. You can look at the revisions for your service. In here we just have one revision. If you release multiple versions of it, then you’ll have multiple revisions.

In here you can look at the logs for the service in logs, this is coming from Cloud Logging. So you can look at the logs for that specific service. And you can go to triggers. This is where we can configure the ingress and the authentication. You can go to Details as well and look at the details of the Cloud Run service. It shows the region, the URL and what was the last revision deployed. You can also use YAML configuration to deploy the service to Cloud Run. Just like Kubernetes supports YML configuration, cloud Run also supports a YAML configuration. You can go here, edit it and deploy it. We can also edit the service. So you can either edit or deploy a new revision by going in here. So let’s go and see what we can do in here. So you can go in here and if you want a new container image, you can change that.

Or you can even configure if you want more memory, you can configure how much memory you’d want, how much CPU you want, and you can configure the request timeout up to a max of 3600 seconds. And you can configure maximum number of requests to be handled per container. And you can also configure auto scaling in here. So you can say I would want maximum of, let’s say, only 50 instances or 20 instances. And if you are actually changing the image, you can also control the traffic split. So if I actually uncheck this box, and let’s say I deploy the same version again, this would create a new version. And because I uncheck the box, you can see that the traffic of it is 0%. Let’s say this was using a different container image, then I can also manage the traffic.

So I can go to manage traffic. And I can say, this much traffic should go to the first revision. This much traffic should go to the second revision. Now I’ll go back to the service details, and what I would do is I would delete this service. I don’t really want to leave it in here, so I’ll go ahead and say delete the service. Until now, we were looking at Cloud run. Cloud Run is basically a way you can actually move from container to production in seconds. In addition to cloud run, there is something called Anthos. The fundamental behind Anthos is to be able to run Kubernetes clusters anywhere. So you’d want to be able to run Kubernetes clusters in your data centers in a single cloud, let’s say in AWS, Azure or Google Cloud, or a combination of clouds.

So in your Kubernetes clusters, a few nodes might be in each of the cloud environments. So multi cloud and on premise. Some of the nodes might even be on premise. So using a combination of these to run Kubernetes clusters is the thing that Anthos provides you with. And Cloud Run for Anthos enables you to deploy your workloads to Anthos clusters which are running on premises or Google Cloud. So the important take aways from this step is if you have a container and you don’t want to worry about managing the servers at all. Cloud run if you want to be able to run kuber netes clusters anywhere cloud multi cloud or on premise anthos if you want to be able to deploy to anthos, you can use cloud run for anthos to deploy to anthos clusters. I’m sure you’re having a wonderful time, and I’ll see you.

  1. Step 02 – Gcloud and Google Cloud Run

Welcome back. In this quick step, let’s look at Cloud Run. From the command line, you should be able to easily guess the commands to deploy to Cloud Run deploying a new container. It’s g Cloud Run so G Cloud app was app engine gcloud compute was compute engine gcloud container was kubernetes g Cloud Run is Cloud Run so G Cloud Run deploy. You give service a name and you’d specify an image. You can also specify revision suffix. So over here we are saying this is V One. The first deployment would create a service and the first revision of the service. Next deployments for the same service would create new revisions for that service.

Listing available revisions should be very easy. So Gcloud Run Revisions List this is very, very similar to app engine versions. Gcloud app versions list. Here it is. Gcloud Run Revisions List adjusting traffic assignments also should be very, very easy. You can see that the command looks very, very similar. Gcloud Run services Update Traffic my service two revisions and you are setting v Two is equal to ten and V One is equal to 90. In this quick step, we looked at how you can use Cloud Run from the command line. I’m sure you’re having an exciting time, and I’ll see you in the next step.