How would you configure an Ingress resource to route requests to frontend-service at path / and backend-service at path /api on host app.example.com?
hard📝 Workflow Q8 of 15
Kubernetes - Ingress
How would you configure an Ingress resource to route requests to frontend-service at path / and backend-service at path /api on host app.example.com?
ADefine two paths under one rule with host <code>app.example.com</code>, mapping <code>/</code> to <code>frontend-service</code> and <code>/api</code> to <code>backend-service</code>.
BCreate two separate Ingress resources each with host <code>app.example.com</code>, one for <code>/</code> path and one for <code>/api</code> path.
CUse a single path <code>/</code> routing to both services simultaneously.
DSet host to <code>app.example.com</code> and define backend services without specifying paths.
Step-by-Step Solution
Solution:
Step 1: Understand Ingress rules
Ingress rules allow multiple paths under one host to route to different services.
Step 2: Analyze options
Define two paths under one rule with host app.example.com, mapping / to frontend-service and /api to backend-service. correctly defines multiple paths under one host. Create two separate Ingress resources each with host app.example.com, one for / path and one for /api path. is valid but less efficient and can cause conflicts. Use a single path / routing to both services simultaneously. is invalid as one path cannot route to multiple services. Set host to app.example.com and define backend services without specifying paths. lacks path definitions.
Final Answer:
Option A -> Option A
Quick Check:
Multiple paths under one host route to different services [OK]
Quick Trick:Use multiple paths under one host for different services [OK]
Common Mistakes:
Defining multiple Ingresses for same host causing conflicts
Routing multiple services on same path
Omitting path definitions in rules
Master "Ingress" in Kubernetes
9 interactive learning modes - each teaches the same concept differently