In this article, we will go through the steps to create service in Google Cloud Run. Developers really like an environment where they want to focus more on application development and less on app infrastructure management. Cloud Run is one of the leading Google Cloud Technology which provides a platform to develop and deploy more and more scalable containerized applications on a fully Serverless environment. This provide an edge to efficiently deploy faster and robust applications. Hence we will see more about Cloud Run by creating an example service using below mentioned steps. More on Cloud Run Documentation.
Key Features of Cloud Run
- It is Serverless.
- It makes the code deployment faster.
- It abstracts all the infrastructure management so that one can focus only on building the applications.
- It supports code written in any of the programming languages including Java, Python, GO, Ruby, Node.js and many more.
- Cloud Run is built on open knative platform which makes the application portable.
How to Create Service in Google Cloud Run
Also Read: Deploy Serverless CI/CD Workflow in Google Cloud Using 8 Practical Steps
Step 1: Prerequisites
a) You should have a valid
Google Email ID and
b) Cloud Run API should be enabled.
c) You should have necessary permission to create service in
d) You should have access to a
Step 2: Go to Cloud Run
In the first step you need to open Cloud Run by either searching the service from Search Box or directly open by dragging the left section cursor on Google Dashboard Page all the way down to
Cloud Run. Once it is opened, you can Click on
Step 3: Provide Service Settings
In the Service settings, it will first ask the Service Name where we will give the name
test-service. Then we need to set the Deployment Platform. Here we will choose
Cloud Run(fully managed) option and use
Step 4: Configure the Service's First Revision
Next step is to choose the container image for the service deployment in Cloud Run. This can be done by clicking on
Select and then pointing to the docker image that needs to be used for service deployment. You can also choose another option of
Continuously deploy new revisions from a source repository to deploy the latest available version from Source Repository.
Container Registryfor this demo. If you have not already created an image then probably you should create one first. Another option available is to select the image from
Artifact Registryinstead of
Container Registry. You can use either option as per your convenience.
You can also check the advanced settings and select the configuration as per your requirement. By default container will listen all requests on
Port 8080. If you want you can change this port as well. Next you can set the Container command and arguments to provide the entry point. If you are going to use a Dockerfile then probably you can leave this field blank as entry point command will be given through the Dockerfile.
Next is to check the capacity and align the resources as per your requirement. Here we are going to use the default capacity as we are not going to perform any heavy load tasks.
Step 5: Configure how this Service is Triggered
Next step is to define how this service can be invoked. You can select any of the
Ingress option given below as per your use case. Here we are using the default settings i.e Allow all traffic. Then we have to select the authentication method. You can either select
allow unauthenticated invocations or
Require authentication. Usually in a restricted environment, Require authentication option is used to only allow the authorized users otherwise for a public API or website you need to use the Allow unauthenticated invocations.
Step 6: Create Service
Finally, Click on Create. If everything goes well then Service will be created in next 2-3 minutes and it will look like below. You can notice a URL is now generated after service creation. This URL will be further used to request web resources access.