Google Cloud Professional Cloud Developer — Question 228
You are working on a new application that is deployed on Cloud Run and uses Cloud Functions. Each time new features are added, new Cloud Functions and Cloud Run services are deployed. You use ENV variables to keep track of the services and enable interservice communication, but the maintenance of the ENV variables has become difficult. You want to implement dynamic discovery in a scalable way. What should you do?
Answer options
- A. Configure your microservices to use the Cloud Run Admin and Cloud Functions APIs to query for deployed Cloud Run services and Cloud Functions in the Google Cloud project.
- B. Create a Service Directory namespace. Use API calls to register the services during deployment, and query during runtime.
- C. Rename the Cloud Functions and Cloud Run services endpoint is using a well-documented naming convention.
- D. Deploy Hashicorp Consul on a single Compute Engine instance. Register the services with Consul during deployment, and query during runtime.
Correct answer: B
Explanation
The correct answer is B because using a Service Directory allows for dynamic service registration and discovery, making it easier to manage services without hardcoding ENV variables. Option A is incorrect as querying APIs does not provide a systematic registration process. Option C does not address the need for dynamic discovery, and option D introduces unnecessary complexity by deploying Consul on Compute Engine instead of leveraging Google Cloud's managed services.