EKS:找不到任何合适的子网来创建 ELB

iam*_*man 11 amazon-web-services kubernetes aws-load-balancer amazon-eks

我正在尝试使用loadBalancer类型服务向外界公开服务。

为此,我遵循了这个文档

https://aws.amazon.com/premiumsupport/knowledge-center/eks-kubernetes-services-cluster/

我的loadbalancer.yaml看起来像这样

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  type: LoadBalancer
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
Run Code Online (Sandbox Code Playgroud)

但是负载平衡器没有按预期创建我收到以下错误

Warning  SyncLoadBalancerFailed  8s (x3 over 23s)  service-controller  Error syncing load balancer: failed to ensure load balancer: could not find any suitable subnets for creating the ELB
Run Code Online (Sandbox Code Playgroud)

似乎是因为子网标签中的一些问题需要解决,但我的子网中有所需的标签

kubernetes.io/cluster/<cluster-name>. owned  
kubernetes.io/role/elb   1
Run Code Online (Sandbox Code Playgroud)

但是,我仍然收到错误 could not find any suitable subnets for creating the ELB

ted*_*ivm 13

默认情况下,AWS EKS 仅将负载均衡器附加到公共子网。为了在私有子网中启动它,您不仅需要标记您的子网(看起来就像您所做的那样),还需要注释您的负载均衡器 -

service.beta.kubernetes.io/aws-load-balancer-internal:“真”

您可以在此处找到更多信息。


fro*_*tin 7

对于可能提出这个问题的人来说,我也遇到过同样的错误,但问题非常简单。

带有kubernetes.io/cluster/<cluster-name>键的标签的集群名称错误,因为部署它的自动化是错误的。