Certified Kubernetes Application Developer (CKAD) Practice Test

Question: 1 / 400

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

The port on the service itself

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.

Get further explanation with Examzify DeepDiveBeta

The port exposed to external traffic

A default port that pod listens to

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy