<p>I would like to understand the mapping between the service port and pod container port.</p>

<p>Do I need to define the container port as part of my pod and also as part of my service? Or it's ok just to expose it as part of the service?</p>

<p>containerPort as part of the pod definition is only informational purposes. Ultimately if you want to expose this as a service within the cluster or node then you have to create a service.</p>
<p>To answer your question, yes it is enough if you just expose it as part of the Kubernetes service. It is a good practice to mention as part of the pod definition so that if someone looks at the definition can understand the port where your container service is running.</p>
<p>This is very well explained <a href="https://medium.com/faun/should-i-configure-the-ports-in-kubernetes-deployment-c6b3817e495" rel="noreferrer">here</a></p>
<p>Official kubernetes reference <a href="https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#ports" rel="noreferrer">documentation</a></p>
