AWS 网络负载均衡器和 AWS Fargate 的 TCP 流量
AWS Network Load Balancer and TCP traffic with AWS Fargate
我想从我的 Fargate 集群向端口 80 上的 public 互联网公开一个仅限 tcp 的服务。为此,我想使用 AWS 网络负载均衡器
这是我服务的配置:
apiVersion: v1
kind: Service
metadata:
name: myapp
labels:
app: myapp
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "30"
spec:
type: LoadBalancer
selector:
app: myapp
ports:
- protocol: TCP
port: 80
targetPort: 80
通过 CLUSTER-IP 使用集群内部的服务是可行的。当我使用 kubectl 应用我的配置时,会发生以下情况:
- 服务是在K8s中创建的
- NLB 在 AWS 中创建
- NLB 获得状态 'active'
- NLB 的 VPC 和其他值看起来正确
- 目标组在 AWS 中创建
- 注册了 0 个目标
- 我无法注册目标,因为组需要实例,而我没有
- EXTERNAL_IP 是
- 不会自动创建监听器
然后我为端口 80 和 TCP 创建一个侦听器。等待一段时间后,EXTERNAL_IP 被分配给 AWS 中的服务。
我的问题:它不起作用。使用来自 NLB 的 DNS 名称和端口 80 无法使用该服务。
in-tree Kubernetes Service
LoadBalancer for AWS,不能用于 AWS Fargate。
You can use NLB instance targets with pods deployed to nodes, but not to Fargate.
但您现在可以在 Service
LoadBalancer 上安装 AWS Load Balancer Controller 并使用 IP 模式,这也适用于 AWS Fargate。
kind: Service
apiVersion: v1
metadata:
name: nlb-ip-svc
annotations:
# route traffic directly to pod IPs
service.beta.kubernetes.io/aws-load-balancer-type: "nlb-ip"
见Introducing AWS Load Balancer Controller and EKS Network Load Balancer - IP Targets
我想从我的 Fargate 集群向端口 80 上的 public 互联网公开一个仅限 tcp 的服务。为此,我想使用 AWS 网络负载均衡器
这是我服务的配置:
apiVersion: v1
kind: Service
metadata:
name: myapp
labels:
app: myapp
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "30"
spec:
type: LoadBalancer
selector:
app: myapp
ports:
- protocol: TCP
port: 80
targetPort: 80
通过 CLUSTER-IP 使用集群内部的服务是可行的。当我使用 kubectl 应用我的配置时,会发生以下情况:
- 服务是在K8s中创建的
- NLB 在 AWS 中创建
- NLB 获得状态 'active'
- NLB 的 VPC 和其他值看起来正确
- 目标组在 AWS 中创建
- 注册了 0 个目标
- 我无法注册目标,因为组需要实例,而我没有
- EXTERNAL_IP 是
- 不会自动创建监听器
然后我为端口 80 和 TCP 创建一个侦听器。等待一段时间后,EXTERNAL_IP 被分配给 AWS 中的服务。
我的问题:它不起作用。使用来自 NLB 的 DNS 名称和端口 80 无法使用该服务。
in-tree Kubernetes Service
LoadBalancer for AWS,不能用于 AWS Fargate。
You can use NLB instance targets with pods deployed to nodes, but not to Fargate.
但您现在可以在 Service
LoadBalancer 上安装 AWS Load Balancer Controller 并使用 IP 模式,这也适用于 AWS Fargate。
kind: Service
apiVersion: v1
metadata:
name: nlb-ip-svc
annotations:
# route traffic directly to pod IPs
service.beta.kubernetes.io/aws-load-balancer-type: "nlb-ip"
见Introducing AWS Load Balancer Controller and EKS Network Load Balancer - IP Targets