NodePort vs ClusterIP
JS
R
JavaScriptDifference between NodePort and ClusterIP SVC networking modes is that: NodePort maps an external NodeIP Address and a Port; ClusterIP only maps an internal IP Address and a Port
1A ClusterIP exposes the following:
2
3spec.clusterIp:spec.ports[*].port
4You can only access this service while inside the cluster. It is accessible from its spec.clusterIp port. If a spec.ports[*].targetPort is set it will route from the port to the targetPort. The CLUSTER-IP you get when calling kubectl get services is the IP assigned to this service within the cluster internally.
5
6A NodePort exposes the following:
7
8<NodeIP>:spec.ports[*].nodePort
9spec.clusterIp:spec.ports[*].port
10If you access this service on a nodePort from the node's external IP, it will route the request to spec.clusterIp:spec.ports[*].port, which will in turn route it to your spec.ports[*].targetPort, if set. This service can also be accessed in the same way as ClusterIP.
11
12Your NodeIPs are the external IP addresses of the nodes. You cannot access your service from spec.clusterIp:spec.ports[*].nodePort.
13
14A LoadBalancer exposes the following:
15
16spec.loadBalancerIp:spec.ports[*].port
17<NodeIP>:spec.ports[*].nodePort
18spec.clusterIp:spec.ports[*].port
19You can access this service from your load balancer's IP address, which routes your request to a nodePort, which in turn routes the request to the clusterIP port. You can access this service as you would a NodePort or a ClusterIP service as well.Created on 12/31/2021