Skip to content

LoadBalancer versus NodePort service types

In Kubernetes services, the LoadBalancer and NodePort types represent two different methods for exposing applications externally.^[400-devops-06-kubernetes-k8s-learning-06ingress-readme.md]

NodePort

A NodePort service exposes the application on a specific port on every Node in the cluster.^[400-devops-06-kubernetes-k8s-learning-06ingress-readme.md] For example, a service configured as NodePort might map internal service port 8000 to port 30486 on the node, as seen in example configurations like service-nodeport.^[400-devops-06-kubernetes-k8s-learning-06ingress-readme.md]

LoadBalancer

A LoadBalancer service builds on top of the NodePort concept by additionally provisioning an external load balancer (typically provided by the cloud infrastructure).^[400-devops-06-kubernetes-k8s-learning-06ingress-readme.md] This type automatically maps an external IP or FQDN to the service, abstracting away the individual Node IPs.^[400-devops-06-kubernetes-k8s-learning-06ingress-readme.md]

Key differences and limitations

The primary distinction lies in the infrastructure support. LoadBalancer is supported on "real" cloud clusters that can automatically provision external load balancers; in such environments, the EXTERNAL-IP field will be populated automatically.^[400-devops-06-kubernetes-k8s-learning-06ingress-readme.md]

However, if a Kubernetes cluster does not support this capability (common in local or bare-metal setups), the LoadBalancer type will result in an EXTERNAL-IP status of <pending>.^[400-devops-06-kubernetes-k8s-learning-06ingress-readme.md] In these scenarios, the service effectively falls back to functioning like a NodePort, exposing ports on the nodes (e.g., 80:32411/TCP) without a dedicated external IP.^[400-devops-06-kubernetes-k8s-learning-06ingress-readme.md]

Sources

^[400-devops-06-kubernetes-k8s-learning-06ingress-readme.md]