Cloud Run simplifies and automates deployments to Kubernetes. When you use Cloud Run, you don't need a configuration file. You simply choose a cluster for your application. With Cloud Run, you can use a cluster managed by Google, or you can use your own Kubernetes cluster.
To use Cloud Run, your application needs to be deployed using a Docker image and it must be stateless.
Open the Cloud Shell code editor and expand the training-data-analyst/courses/design-process/deploying-apps-to-gcp folder in the navigation pane on the left. Then, click main.py to open it.
In the main() function, change the title to Hello Cloud Run as shown below:
Save your change.
To use Cloud Run, you need to build a Docker image. In Cloud Shell, enter the following commands to use Cloud Build to create the image and store it in Container Registry:
cd ~/gcp-course/training-data-analyst/courses/design-process/deploying-apps-to-gcp
gcloud builds submit --tag gcr.io/$DEVSHELL_PROJECT_ID/cloud-run-image:v0.1 .
When the build completes, in the Navigation menu (Navigation menu icon), click Cloud Run.
Click Create service. This enables the Cloud Run API.
Click the Select link in the Container image URL text box. In the resulting dialog, expand cloud-run-image and select the image listed. Then click Select.
In Service name, type hello-cloud-run.
In Autoscaling set the Maximum number of instances to 6. Leave the rest as defaults.
For Authentication, select Allow unauthenticated invocations.
In Container, Variables & Secrets, Connections, Security for Container, select default in the Execution environment section.
Finally, click Create.
It shouldn't take long for the service to deploy. When a green check appears, click on the URL that is automatically generated for the application. It should return Hello Cloud Run.
0 Comments