There are three kinds of ports widely used in kubernetes resource management, for example:
port
is the port exposed within the cluster. so other nodes/pods from same cluster can access it through service:port
targetPort
is the port exposed from within the pod.
nodePort
is the port exposed to outside world. so on public network, it could be accessed as public-ip:nodePort
kind: Service
apiVersion: v1
metadata:
labels:
app: nginx
name: nginx
spec:
ports:
- port: 443
targetPort: 443
- nodePort: 31234
selector:
app: nginx