没有标签选择器的Kubernetes负载均衡器 [英] Kubernetes Load balancer without Label Selector
问题描述
尝试使用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:
- 一个具有
Nginx-Ingress-Controller
pod作为后端的Load Balancer Service
. - 您的
Load balancer Service
将具有一个外部IP,将所有群集流量都指向该IP. - 可根据需要路由所有群集流量的入口规则.
- A
Load Balancer Service
withNginx-Ingress-Controller
pod as backend. - Your
Load balancer Service
would have an External IP, point all your cluster traffic to that IP. - 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屋!