没有标签选择器的Kubernetes负载均衡器 [英] Kubernetes Load balancer without Label Selector

查看:132
本文介绍了没有标签选择器的Kubernetes负载均衡器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用Kubernetes创建Laod Balancer资源(用于EKS集群).它通常可以与标签选择器"一起使用,但是我们希望每个集群只有一个LB,然后让入口直接服务. 这是我目前拥有的:

Trying to create a Laod Balancer resource with Kubernetes (for an EKS cluster). It works normally with the Label Selector, but we want to only have one LB per cluster, then let ingress direct services. Here is what I currently have :

kind: Service
apiVersion: v1
metadata:
  namespace: default
  name: name
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
spec:
  ports:
  - port: 80
  type: LoadBalancer

这将创建一个LB并为其提供内部DNS,但是实例永远不会变得健康(尽管它们是健康的).

This creates a LB and gives it an internal DNS, but instances never get healthy (although they are).

任何建议

推荐答案

每个

Per discussion in another question you posted. I think what you want is to achieve One Load Balancer Per Cluster, referring to this: Save on your AWS bill with Kubernetes Ingress.

要实现此目的,您需要创建:

To achieve this, you would need to create:

  1. 一个具有Nginx-Ingress-Controller pod作为后端的Load Balancer Service.
  2. 您的Load balancer Service将具有一个外部IP,将所有群集流量都指向该IP.
  3. 可根据需要路由所有群集流量的入口规则.
  1. A Load Balancer Service with Nginx-Ingress-Controller pod as backend.
  2. Your Load balancer Service would have an External IP, point all your cluster traffic to that IP.
  3. Ingress rules that route all cluster traffic as you wish.

因此,您的流量将通过以下管道:

So your traffic would go through the following pipeline:

所有流量-> AWS LoadBalancer-> Node1:xxxx-> Nginx入口控制器服务-> Nginx入口控制器Pod->您的Service1(基于您的入口规则)-> 您的豆荚

all traffic -> AWS LoadBalancer -> Node1:xxxx -> Nginx-Ingress-Controller Service -> Nginx-Ingress-Controller Pod -> Your Service1 (based on your ingress rules) -> Your Pod

以下是如何启动Nginx-Ingress-Controller的示例:

Here is an example how to bring up a Nginx-Ingress-Controller: https://hackernoon.com/setting-up-nginx-ingress-on-kubernetes-2b733d8d2f45

这篇关于没有标签选择器的Kubernetes负载均衡器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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