Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker for Mac(Edge) - Kubernetes - LoadBalancer

It is so cool that we have a LoadBalancer in Docker for Mac.

I have a question regarding ports created:

apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    run: nginx
spec:
  ports:
    port: 9999
    targetPort: 80
  selector:
    run: nginx
  type: LoadBalancer

This gives me(kubectl get service):

nginx        LoadBalancer   10.96.128.253   localhost     9999:32455/TCP   2s

What is 32455?

Thanks

like image 630
Chris G. Avatar asked Feb 23 '26 18:02

Chris G.


1 Answers

32455 is your nodePort. Kubernetes automatically assigns a unique nodePort for any service that is accessible outside of a cluster (including services of type LoadBalancer. You can specify these yourself as well in the same config, as long as you .

With regards to Docker for Mac specifically, Kubernetes is creating a service which is listening on localhost:9999. This is an "egress" that kubernetes is creating since you don't actually have a load balancer, it's essentially simulating one. Beyond the "load balancer/egress", it still behaves just like it would in production - that is Kubernes assigns a nodePort for the service. You curl localhost:32455, you will likely get the same response as if you had curl localhost:9999.

like image 187
nelsonenzo Avatar answered Feb 27 '26 02:02

nelsonenzo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!