CKA Services and Networking Practice Question
Which of the following is a correct Ingress resource snippet that routes traffic to service 'web-svc' on port 80 for the host 'example.com'?
⚠ Common exam trap
Candidates often confuse the deprecated `extensions/v1beta1` API syntax (using `serviceName` and `servicePort`) with the current `networking.k8s.io/v1` API syntax (using `service.name` and `port.number`), leading them to select option C.
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
✓
spec: rules: - host: example.com http: paths: - path: / pathType: Prefix backend: service: name: web-svc port: number: 80
It follows the exact structure required by the Kubernetes Ingress v1 API (networking.k8s.io/v1). It specifies the host `example.com`, defines an HTTP rule with a path of `/` and `pathType: Prefix`, and correctly references the backend service `web-svc` on port 80 using the `service.name` and `port.number` fields. This configuration ensures that traffic for `example.com` is routed to the target service.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
spec: rules: - host: example.com http: paths: - path: / pathType: Prefix backend: service: name: web-svc port: number: 80
Why this is correct
This snippet correctly adheres to the networking.k8s.io/v1 Ingress API specification. It properly defines a routing rule under spec.rules with a designated host, an http routing block, and a path list containing the required path, pathType (set to Prefix), and a nested backend.service configuration specifying both name and port.number.
- ✗
spec: rules: - http: paths: - backend: service: name: web-svc port: number: 80
Why it's wrong here
This snippet is invalid under the networking.k8s.io/v1 schema because it omits the mandatory path and pathType fields within the paths list. While omitting the host field is technically allowed to match all incoming traffic, failing to declare a pathType (such as Prefix or Exact) violates the OpenAPI validation schema for modern Ingress resources.
- ✗
spec: rules: - host: example.com http: paths: - backend: serviceName: web-svc servicePort: 80
Why it's wrong here
This configuration incorrectly uses the legacy serviceName and servicePort fields, which were deprecated and subsequently removed in the stable networking.k8s.io/v1 Ingress API. Modern Kubernetes clusters require the nested service.name and service.port.number (or service.port.name) structure under the backend block, alongside explicit path and pathType declarations.
- ✗
spec: rules: - host: example.com backend: serviceName: web-svc servicePort: 80
Why it's wrong here
This snippet contains a structural syntax error by attempting to define a backend directly under a rule host without an intervening http block. In Kubernetes Ingress resources, backends must either be defined globally as a spec.defaultBackend or nested within the http.paths array of a specific routing rule.
Go deeper
Related to this question
Learn chapter
Installing Kubernetes with kubeadm
Key term
Network Policies
A Kubernetes resource that controls how pods communicate with each other and with other network endpoints, acting as a firewall for pod-to-pod traffic.
Key term
Ingress Resources
Ingress Resources are Kubernetes API objects that manage external access to services inside a cluster, typically HTTP and HTTPS traffic, by defining rules for routing requests based on hostnames and paths.
About these practice questions
One of 726 original CKA 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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CKA 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 CKA exam.