Host-based routing directs incoming traffic to different services based on the hostname in the request URL. It helps serve multiple websites or apps from the same IP address.
Click to reveal answer
beginner
Which Kubernetes resource is commonly used to configure host-based routing?
The Ingress resource is used to define rules for host-based routing, specifying which hostnames map to which backend services.
Click to reveal answer
intermediate
How does host-based routing differ from path-based routing?
Host-based routing uses the hostname (like example.com) to route traffic, while path-based routing uses the URL path (like /app1 or /app2) to decide where to send traffic.
Click to reveal answer
beginner
What is a simple example of an Ingress rule for host-based routing?
An Ingress rule that sends traffic for host 'app.example.com' to service 'app-service' on port 80.
Click to reveal answer
beginner
Why is host-based routing useful in real life?
It lets you run multiple websites or apps on one server or IP address, saving resources and making management easier.
Click to reveal answer
Which Kubernetes resource is primarily used to implement host-based routing?
AService
BIngress
CPod
DConfigMap
✗ Incorrect
Ingress defines rules for routing external traffic based on hostnames or paths.
Host-based routing directs traffic based on which part of the request?
AURL path
BIP address
CHostname
DHTTP method
✗ Incorrect
Host-based routing uses the hostname in the URL to decide where to send traffic.
What happens if no host rule matches in an Ingress configuration?
AIngress controller crashes
BTraffic is dropped
CTraffic is routed randomly
DTraffic is routed to a default backend if configured
✗ Incorrect
Ingress can have a default backend to handle unmatched requests.
Which of these is NOT a benefit of host-based routing?
ARoute traffic by URL path
BSave IP addresses
CServe multiple apps on one IP
DSimplify DNS management
✗ Incorrect
Routing by URL path is path-based routing, not host-based.
In an Ingress rule, where do you specify the hostname for routing?
Aspec.rules.host
Bmetadata.name
Cspec.backend.serviceName
Dspec.tls.hosts
✗ Incorrect
The hostname is set under spec.rules.host in the Ingress YAML.
Explain how host-based routing works in Kubernetes and why it is useful.
Think about how websites use domain names to decide where to send visitors.
You got /4 concepts.
Describe the difference between host-based routing and path-based routing in Kubernetes Ingress.
Consider what part of the URL each routing method uses.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of host-based routing in Kubernetes Ingress?
easy
A. To encrypt all incoming traffic automatically.
B. To balance traffic evenly across all nodes in the cluster.
C. To monitor the health of backend services.
D. To send traffic to different services based on the website address (host).
Solution
Step 1: Understand host-based routing concept
Host-based routing directs requests to services depending on the host name in the URL.
Step 2: Compare options to the concept
Only To send traffic to different services based on the website address (host). matches this behavior; others describe different features.
Final Answer:
To send traffic to different services based on the website address (host). -> Option D
Quick Check:
Host-based routing = directing traffic by host [OK]
Hint: Host-based routing uses website address to choose service [OK]
Common Mistakes:
Confusing host-based routing with load balancing
Thinking it encrypts traffic automatically
Assuming it monitors service health
2. Which of the following is the correct way to specify host-based routing in a Kubernetes Ingress YAML?
A. The keys 'serviceName' and 'servicePort' are deprecated; use 'service.name' and 'service.port.number'.
B. The host field is missing under metadata.
C. The path should be '/' instead of '/shop'.
D. The Ingress resource must have a selector field.
Solution
Step 1: Check Ingress backend service syntax
Modern Kubernetes Ingress requires 'service.name' and 'service.port.number' keys, not 'serviceName' and 'servicePort'.
Step 2: Identify the error in YAML
The YAML uses deprecated keys causing routing failure.
Final Answer:
The keys 'serviceName' and 'servicePort' are deprecated; use 'service.name' and 'service.port.number'. -> Option A
Quick Check:
Use correct backend service keys = The keys 'serviceName' and 'servicePort' are deprecated; use 'service.name' and 'service.port.number'. [OK]
Hint: Use 'service.name' and 'service.port.number' in Ingress backend [OK]
Common Mistakes:
Using old 'serviceName' and 'servicePort' keys
Adding host under metadata instead of rules
Changing path unnecessarily
5. You want to run two websites, 'blog.example.com' and 'shop.example.com', on the same Kubernetes cluster using one Ingress. How should you configure the Ingress rules for host-based routing?
hard
A. Create one rule with host 'example.com' and use paths '/blog' and '/shop' to route to services.
B. Create separate Ingress resources for each host with identical paths.
C. Create two rules under spec.rules, each with a different host and paths pointing to their respective services.
D. Use a single rule with no host specified and rely on path prefixes only.
Solution
Step 1: Understand host-based routing for multiple hosts
To route traffic by host, define separate rules for each host under spec.rules.
Step 2: Compare options for best practice
Create two rules under spec.rules, each with a different host and paths pointing to their respective services. correctly uses two rules with different hosts and paths to route traffic properly.
Final Answer:
Create two rules under spec.rules, each with a different host and paths pointing to their respective services. -> Option C
Quick Check:
Multiple hosts need separate rules = Create two rules under spec.rules, each with a different host and paths pointing to their respective services. [OK]
Hint: Use separate rules for each host in one Ingress resource [OK]
Common Mistakes:
Using one host with path prefixes instead of separate hosts
Creating multiple Ingresses unnecessarily
Not specifying hosts and relying on paths only
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.