首页 文章

kubernetes服务如何决定要路由到哪个后端pod

提问于
浏览
2

我有一个Kubernetes服务,通过这样做选择:

spec: 
  selector: 
    backend: nlp-server

如果有多个 Pods 与选择器匹配, ServiceService 路由请求?

我使用默认的 ClusterIP 设置 . 在docs中搜索"ClusterIP: Exposes the service on a cluster-internal IP. Choosing this value makes the service only reachable from within the cluster. This is the default ServiceType."

如果我希望服务路由到有意义的Pod(负载较小),
internal load-balancer我需要什么?

1 回答

  • 5

    简而言之,您不需要链接到的内部负载均衡器 . Service 资源确实是一个负载均衡器 . 根据proxy mode,它可能是循环或随机的 . 如果你使用默认的(基于iptables的代理),那么每次你点击服务的虚拟IP都会是random pod selected .

    注意:您可以使用内部负载均衡器类型,通常在 Cloud 环境such as GKE中,例如,当您需要的是集群内部连接时,可以降低成本,但是(据我所知)通常是L4负载 - balancer 器 .

相关问题