Google Professional Cloud DevOps Engineer Question 25
Select 2Google Cloud PlatformYour team is implementing a continuous integration (CI) pipeline using Cloud Build for a multi-service application hosted in Google Cloud. The application consists of a backend API and a frontend web application that are stored in separate Git repositories. Each service has its own Dockerfile for containerization. The team wants to ensure that changes to either repository trigger a build for the relevant service and deploy the updated container to a Google Kubernetes Engine (GKE) cluster. How should you configure the Cloud Build setup to achieve this?
- A
Create separate Cloud Build triggers for each Git repository, configured to trigger on changes to their respective branches.
- B
Use a single Cloud Build trigger that monitors both Git repositories and runs a shared build configuration file for both services.
- C
Define separate
cloudbuild.yamlfiles in each repository to handle the build and deployment process for their respective services. - D
Configure Cloud Build to use Pub/Sub to listen to repository changes and dynamically determine which service to build.
- E
Use Google Cloud Deploy instead of Cloud Build to manage the continuous integration process for both services.
Show answer and explanation
Correct answers: A, C
Explanation
To implement a CI pipeline for a multi-service application using Cloud Build, it is best practice to create independent build triggers for each service’s repository. Each repository should also maintain its own cloudbuild.yaml file to define service-specific build and deployment steps. This approach ensures that changes to one service do not unnecessarily trigger builds for the other, making the pipeline efficient and maintainable.
- A. Correct.
Correct: Creating separate Cloud Build triggers for each repository ensures that changes in each service’s codebase independently trigger builds for only the relevant service.
- B. Incorrect.
Incorrect: Using a single Cloud Build trigger for both repositories is not recommended because it cannot easily differentiate which service needs to be built and deployed when a change occurs.
- C. Correct.
Correct: Defining separate
cloudbuild.yamlfiles in each repository allows for service-specific build and deployment steps, making the pipeline modular and maintainable. - D. Incorrect.
Incorrect: While Pub/Sub can be used to trigger builds in some scenarios, it is unnecessary and overly complex for this use case, as Cloud Build triggers natively support Git repository changes.
- E. Incorrect.
Incorrect: Google Cloud Deploy is a separate tool designed primarily for continuous delivery (CD), not continuous integration (CI). Cloud Build is the appropriate choice for CI in this scenario.