Docker for Mac(Edge) - Kubernetes - LoadBalancer

我是研究僧i 提交于 2019-12-11 12:11:03

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/49480737/docker-for-macedge-kubernetes-loadbalancer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!