Google Professional Cloud Network Engineer Question 413
Select 2Google Cloud PlatformYou are setting up a Google Cloud HTTPS Load Balancer for your application. The application has two services: 'service-a' for API requests and 'service-b' for static assets. You need to configure the URL map such that:
- All requests to '/api/*' are routed to 'service-a'
- All requests to '/static/*' are routed to 'service-b'
- Any other requests are sent to a default backend service
What is the correct way to configure URL map rules for this setup?
- A
Create a path matcher with a rule for '/api/' routing to 'service-a', another rule for '/static/' routing to 'service-b', and set a default backend service.
- B
Create a path matcher with only a rule for '/api/*' routing to 'service-a' and set 'service-b' as the default backend service.
- C
Create a path matcher with a rule for '/static/' routing to 'service-b', another rule for '/api/' routing to 'service-a', and set a default backend service.
- D
Create two separate path matchers: one for '/api/' routing to 'service-a' and another for '/static/' routing to 'service-b', each with its own default backend service.
- E
Use a single path matcher with a rule for '/api/' routing to 'service-a', another rule for '/static/' routing to 'service-b', and set a wildcard route ('/*') as the default backend service.
Show answer and explanation
Correct answers: A, C
Explanation
To configure a URL map for a Google Cloud HTTPS Load Balancer, you must define path matchers with rules that direct traffic to appropriate backend services based on URL patterns. A single path matcher can include multiple rules for specific paths (e.g., '/api/' to 'service-a' and '/static/' to 'service-b') and must specify a default backend service for any traffic that does not match the defined rules. Options 1 and 3 correctly implement this configuration, while the other options either violate URL map restrictions or incorrectly assign services.
- A. Correct.
This is a correct configuration. A single path matcher can have multiple path rules for specific patterns (e.g., '/api/' and '/static/') and a default backend service for fallback traffic.
- B. Incorrect.
This is incorrect because it does not include a rule for '/static/*', and 'service-b' is improperly assigned as the default backend service. This would result in static asset requests being routed incorrectly.
- C. Correct.
This is a correct configuration. The order of the rules does not matter as long as all required rules and a default backend service are defined within the same path matcher.
- D. Incorrect.
This is incorrect. A single URL map can only have one path matcher, so creating two separate path matchers is not allowed.
- E. Incorrect.
This is incorrect because although the rule for '/api/' and '/static/' is correct, a wildcard route ('/*') is redundant when a default backend service is already specified.