Kubernetes Deep Dive Room

Sign Up Free or Log In to participate!

when to use node ip or cluster IP.

You can use either the clusterIP:8080 or nodeIp:30001 (or whatever you’ve configured) – my assumption is when you want to hit the service and have the traffic routed automatically by the service, you use the former, and if you use the latter, its because you want to hit a specific node. Can you give an example of each?

1 Answers

Great question. I think the reason you use cluster IP is because that IP address is virtual, but then you can fix the port number, say 8080, or 80, or 443, so protocols like http or https work without specifying a port or having to change the port because, unless you specify it, the Node Port is assigned by Kubernetes. If you specify the Node Port (which must be in the range 30000-32767), then yes, a cluster IP:8080 and nodeIP:30001 is pretty much the same, but if you don’t specify the node port in your manifest, a port number from the range is selected for you but you don’t care what the node port is since you will use the clusterIP:8080.

Kris Budde

One important thing is missing here. The clusterIP is just kubernetes internal which means other pods can access the service internally with well known port. If you use node port, the port is exposed on each node. So you can access the service from outside kubernetes on each node with assigned port.

Sign In
Welcome Back!

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

Get Started
Who’s going to be learning?