0
0
Kubernetesdevops~20 mins

Host-based routing in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Host-based Routing Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Host-based Routing in Kubernetes Ingress

What is the primary purpose of host-based routing in a Kubernetes Ingress resource?

ATo route traffic to different backend services based on the requested hostname
BTo route traffic based on the client IP address
CTo route traffic to services based on the container port number
DTo route traffic only to services running on the same node as the Ingress controller
Attempts:
2 left
💡 Hint

Think about how Ingress directs requests to different services depending on the URL host.

Configuration
intermediate
2:00remaining
Identify the Correct Host-based Routing Ingress YAML Snippet

Which Ingress YAML snippet correctly routes traffic to service-a when the host is app.example.com?

A
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: service-a
            port:
              number: 80
B
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  rules:
  - host: app.example.com
    http:
      paths:
      - path: /app
        pathType: Prefix
        backend:
          service:
            name: service-b
            port:
              number: 80
C
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  rules:
  - host: app.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: service-a
            port:
              number: 80
D
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  rules:
  - host: app.example.com
    http:
      paths:
      - path: /
        pathType: Exact
        backend:
          service:
            name: service-a
            port:
              number: 8080
Attempts:
2 left
💡 Hint

Check the host, path, and port values carefully.

💻 Command Output
advanced
1:30remaining
Output of kubectl get ingress with Multiple Hosts

Given an Ingress resource with two host rules: app1.example.com routing to service1 and app2.example.com routing to service2, what is the output of kubectl get ingress my-ingress?

Kubernetes
kubectl get ingress my-ingress
AError from server (NotFound): ingresses.networking.k8s.io "my-ingress" not found
B
NAME         CLASS    HOSTS                       ADDRESS        PORTS   AGE
my-ingress   <none>   app1.example.com              192.168.1.10   80      10m
C
NAME         CLASS    HOSTS                       ADDRESS        PORTS   AGE
my-ingress   <none>   app2.example.com              192.168.1.10   80      10m
D
NAME         CLASS    HOSTS                       ADDRESS        PORTS   AGE
my-ingress   <none>   app1.example.com,app2.example.com   192.168.1.10   80      10m
Attempts:
2 left
💡 Hint

Remember that multiple hosts appear comma-separated in the HOSTS column.

Troubleshoot
advanced
2:00remaining
Troubleshooting Host-based Routing Failure

You have an Ingress configured with host app.example.com routing to service-a. Requests to app.example.com return 404 errors. Which is the most likely cause?

AThe service <code>service-a</code> is exposing the wrong port number
BThe Ingress controller is not running or not configured properly
CThe DNS for <code>app.example.com</code> is not pointing to the Ingress controller's IP
DThe pod labels do not match the service selector
Attempts:
2 left
💡 Hint

Consider what happens if the Ingress controller is missing or misconfigured.

🔀 Workflow
expert
2:30remaining
Correct Order to Deploy Host-based Routing Ingress

Arrange the steps in the correct order to deploy host-based routing using Kubernetes Ingress.

A1,2,3,4
B3,2,1,4
C1,3,2,4
D2,1,3,4
Attempts:
2 left
💡 Hint

Think about what must exist before the Ingress can route traffic.