Andy Longwill:
Hi all, for a cluster with no external load balancer is NodePort
service and LoadBalancer
effectively the same thing (in terms of any linux networking changes made on the nodes)?
Example: I have two servers:
k get nodes -o wide # output trimmed for readability
NAME STATUS ROLES AGE VERSION INTERNAL-IP
k3s02 Ready <none> 147m v1.23.6+k3s1 172.31.20.163
k3s01 Ready control-plane,master 159m v1.23.6+k3s1 172.31.30.24
I create two services for the same deployment:
k expose deployment -n apps foo-service --port=8080 --target-port=80 --name=foo-service-nodeport --type=NodePort
service/foo-service-nodeport exposed
and
k expose deployment -n apps foo-service --port=8080 --target-port=80 --name=foo-service-lb --type=LoadBalancer
service/foo-service-lb exposed
Then I can access the service via:
k get svc -n apps
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
foo-service-nodeport NodePort 10.43.254.64 <none> 8080:31888/TCP 25m
foo-service-lb LoadBalancer 10.43.14.131 172.31.20.163,172.31.30.24 8080:30228/TCP 23m
Then I can access the NodePort service with:
curl -I 172.31.20.163:31888
HTTP/1.1 200 OK
curl -I localhost:31888
HTTP/1.1 200 OK
and the LoadBalancer service:
curl -I 172.31.20.163:30228
HTTP/1.1 200 OK
curl -I localhost:30228
HTTP/1.1 200 OK