Kubernetes Deep Dive Room

Sign Up Free or Log In to participate!

Is it a typo or I’m missing something?

When I look at the screen at 7:30 at this lesson (demo, chapter 4) it shows that pods are listening on 8080 port and service is listening on 30001 port, while I think it’s opposite

It was showed that with curl – you were able to connect to particular pod to port 30001 and to service to port 8080

Same at 5:24 on the same video…

Unless I’m missing something, but video suggests (also some previous lessons suggests it also where config is described for a service) that port section of yaml for service is a port that pods are listening on, and nodePort is a port where service is listening on, and again I think it’s opposite.

Am I right or wrong?

1 Answers

Hi Mariusz.

I’ve had a quick look, and I think you might have hit on something where I can be a bit more clear. So I’ve made a note to add some clarification to the video/demo.

Here’s how it currently stands with some clarifications…

At 5:24 we show that port 30001 is the NodePort value. This is in the YAML file at .spec.ports.nodePort and is the port that the Service can be reached on via every node in the cluster.

At the same point (5:24-ish) we explain that the .spec.ports.port=8080 is the port to forward on to on the back-end. What I’ve not made clear enough is that the port to use on the back-end is actually .spec.ports.targetPort, but if we don’t specify a value for that, then it defaults to whatever is in .spec.ports.port. I’ve put this on my list of clarifications to make.

But let me add some quick clarification here using a YAML snippet:

kind: Service
  - port: 8888 << Front-end port for the Service (ClusterIP). Basically the port the Service listens on within the cluster.
    targetPort: 8080 << Back-end port to send traffic to Pods on. Defaults to `.spec.ports.port` if not present
    nodePort: 30001 << Cluster-wide port that you can hit on any cluster node and reach the Service

Hope that helps. I’ll update the videos some time this week as soon as I get a chance to record.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?