适用于Mac(Edge)的Docker-Kubernetes-LoadBalancer [英] Docker for Mac(Edge) - Kubernetes - LoadBalancer

查看:99
本文介绍了适用于Mac(Edge)的Docker-Kubernetes-LoadBalancer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

太酷了,我们在Mac的Docker中有了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

这给了我(kubectl获得服务):

This gives me(kubectl get service):

nginx        LoadBalancer   10.96.128.253   localhost     9999:32455/TCP   2s

什么是32455?

谢谢

推荐答案

32455是您的nodePort. Kubernetes会自动为群集外部可访问的任何服务(包括LoadBalancer类型的服务)分配一个唯一的nodePort.您可以在相同的配置中自行指定这些端口,只要您自己即可.

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 .

对于Mac专用的Docker,Kubernetes正在创建一个正在localhost:9999上侦听的服务.这是kubernetes正在创建的出口",因为您实际上没有负载均衡器,它实际上是在模拟一个负载均衡器.除了负载均衡器/出口"之外,它的行为仍与生产环境中的行为相同-也就是说Kubernes为服务分配了一个nodePort.您curl localhost:32455,可能会得到与curl localhost:9999相同的响应.

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.

这篇关于适用于Mac(Edge)的Docker-Kubernetes-LoadBalancer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆