A Kubernetes Service can have a targetPort and port in the service definition:
kind: Servi
It helps me to think of things from the perspective of the service.
nodePort: The port on the node where external traffic will come in onport: The port of this servicetargetPort The target port on the pod(s) to forward traffic toTraffic comes in on nodePort, forwards to port on the service which then routes to targetPort on the pod(s).
It's worth emphasizing more that nodePort is for external traffic. Other pods in the cluster that may need to access the service will just use port, not nodePort as it's internal only access to the service.
Also worth noting that if targetPort is not set, it will default to the same value as port. E.g. 80:80 for service port 80 targeting container port 80.