Certified Kubernetes Application Developer (CKAD) Practice Test

Disable ads (and more) with a membership for a one time $2.99 payment

Enhance your skills for the CKAD exam. Study with curated quizzes and detailed explanations. Prepare effectively for your success!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


When defining services, what does the `targetPort` refer to?

  1. The port on the service itself

  2. The port to which traffic is routed on the pod

  3. The port exposed to external traffic

  4. A default port that pod listens to

The correct answer is: The port to which traffic is routed on the pod

The `targetPort` is a crucial parameter when defining services in Kubernetes, as it specifies the port on the pod that the service should forward traffic to. When a service receives a request, it needs to know how to direct that request to the appropriate endpoint, which in this case, is the pod. The `targetPort` essentially maps what port the incoming traffic on the service's `port` should be directed to when it reaches the pod. For example, if a service is configured to listen on port 8080 and the `targetPort` is set to 3000, any traffic coming to the service on port 8080 will be forwarded to port 3000 on the selected pods. This allows for flexibility, as the port the service listens on does not need to match the port the pod is using. Understanding this distinction is vital for effective service exposure and communication within a Kubernetes cluster. This capability enables developers and operators to seamlessly manage underlying changes in pod configurations without impacting the service's external accessibility.