Kubernetes NodePort vs LoadBalancer vs Ingress Intro
NodePort vs LoadBalancer vs Ingress
ClusterIP
A ClusterIP service is the default Kubernetes service. It gives you a service inside your cluster that other apps inside your cluster can access. There is no external access.
1 | apiVersion: v1 |

NodePort
NodePort, opens a specific port on all the Nodes, and any traffic that is sent to this port is forwarded to the service.
1 | apiVersion: v1 |

1 | 1. You can only have one service per port |
LoadBalancer
A LoadBalancer service is the standard way to expose a service to the interne.

1 | Traffic on the port you specify will be forwarded to the service. There is no filtering, no routing, etc. This means you can send almost any kind of traffic to it. like HTTP, TCP, UDP, Websockets, gRPC, or whatever. |
Ingress - L7 HTTP Load Balancer
Ingress is not a type of service, Instead, it sits in front of multiple services and act as a “smart router” or entrypoint into your cluster.
1 | apiVersion: extensions/v1beta1 |
1 | Ingress is the most useful if you want to expose multiple services under the same IP address, and these servcies all use same L7 protocol |
Cheat Sheet
| NodePort | LoadBalancer | Ingress | |
|---|---|---|---|
| Supported by core Kubernetes | Yes | Yes | Yes |
| Works on every platform Kubernetes will deploy | Yes | Only supports a few public clouds. MetalLB project allows use on-premises. | Yes |
| Direct access to service | Yes | Yes | No |
| Proxies each service through third party(NGINX, HAProxy) | No | No | Yes |
| Multiple ports per service | No | Yes | Yes |
| Multiple services per IP | Yes | No | Yes |
| Allows use of standard service ports (80,443,etc) | No | Yes | Yes |
| Have to track individual node IPs | Yes | No | Yes, When using NodePort; No, when using LoadBalancer |