Courseiva
Services and Networking →mediumMultiple Choice

CKAD Services and Networking Practice Question

An Ingress resource has the following spec:

spec: rules: - host: example.com http: paths: - path: /api pathType: Prefix backend: service: name: api-service port: number: 80

What will the Ingress controller do for a request to http://example.com/api/v1/users?

⚠ Common exam trap

It's easy for candidates to confuse `pathType: Prefix` with `pathType: Exact` and incorrectly think the path must match exactly, leading them to choose the 404 error option.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Route the request to api-service on port 80.

The Ingress rule uses `pathType: Prefix` and a path of `/api`, which matches any request whose URL path begins with `/api`. The request to `http://example.com/api/v1/users` starts with `/api`, so the Ingress controller routes it to `api-service` on port 80. This is the standard behavior defined by the Kubernetes Ingress specification for prefix-based path matching.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    Route the request to api-service on port 80.

    Why this is correct

    The Ingress rule defines a host and a path with pathType Prefix. Because the incoming request's path starts with that prefix, the rule's match condition is satisfied. The controller then performs the routing action specified in the rule, forwarding the request to the backend service api-service on port 80. Since the rule matches, no other default or error handling is applied.

  • ✗

    Route the request to the default backend.

    Why it's wrong here

    The default backend exists only to handle requests that do not match any rule in the Ingress spec. In this case, the request path does match the specified prefix rule, so that rule is considered a hit and the default backend is bypassed. Routing to the default backend would only be correct if no rule matched, which is not the situation here. Therefore, choosing the default backend would violate the precedence semantics of Ingress rule matching.

  • ✗

    Return a 502 Bad Gateway error.

    Why it's wrong here

    A 502 Bad Gateway response is an HTTP error generated by the ingress controller when it cannot obtain a valid upstream response, typically because the backend service or its pods are unavailable or unhealthy. The Ingress spec does not indicate any such outage or error condition; the rule simply points to a service and port that are presumed to exist. Since the rule matches and the controller routes the request normally, a 502 would only occur if an infrastructure failure happened separately — it is not an intended consequence of this rule.

  • ✗

    Return 404 Not Found because the path does not match exactly.

    Why it's wrong here

    The pathType in this rule is Prefix, not Exact, so the controller uses prefix matching on the URL path rather than requiring an exact string equality. An Exact pathType would demand that the request path be identical to the configured path, and any difference would result in no match. Because the configured path is a prefix and the request begins with it, the match succeeds; returning 404 for not matching exactly misinterprets the pathType semantics.

About these practice questions

One of 826 original CKAD practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This CKAD practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKAD exam.