Google Professional Cloud Developer Question 340
Single answerGoogle Cloud PlatformYou are tasked with deploying a Node.js application to Google Cloud. The application source code is stored in a GitHub repository, and you want to deploy it directly to Cloud Run without manually building a container image. Which approach should you use to achieve this?
- A
Use the gcloud CLI with the 'gcloud run deploy' command and specify the GitHub repository URL.
- B
Use Cloud Build to create and push a container image to Container Registry, then deploy it to Cloud Run.
- C
Configure a Cloud Build trigger to automatically build and deploy the application to Cloud Run whenever new code is pushed to the main branch.
- D
Deploy the application using the Cloud Run console by linking the GitHub repository and selecting the source code deployment option.
Show answer and explanation
Correct answer: D
Explanation
To deploy a Node.js application directly from source code to Cloud Run, you can use the Cloud Run console's built-in integration with GitHub. By linking the repository, Cloud Run handles the process of building the container image and deploying it, simplifying the workflow and eliminating the need for manual container management.
- A. Incorrect.
This option is incorrect because the 'gcloud run deploy' command does not support directly specifying a GitHub repository URL. You would need to provide a container image or use a Cloud Build integration.
- B. Incorrect.
This option is technically valid but involves additional manual steps. You would need to manually configure Cloud Build, build the container image, push it to Container Registry, and then deploy it to Cloud Run. This does not meet the requirement of deploying directly from source code.
- C. Incorrect.
This option is incorrect because while Cloud Build triggers can automate builds, it still requires additional configuration. The question specifies deploying directly to Cloud Run without manually setting up builds.
- D. Correct.
This is the correct option because the Cloud Run console supports deploying applications directly from source code by linking to a GitHub repository. It abstracts away the need to manually build and push container images, meeting the requirements of the scenario.