AWS Load Balancer Controller无法在EKS Fargate上启动求助
问题分析与解决方案
错误原因拆解
- 第一个调度失败错误:集群所有节点都是Fargate节点,默认调度器未配置容忍Fargate节点的
eks.amazonaws.com/compute-type: fargate污点,导致Pod无法调度。 - 第二个Fargate配置错误:Fargate调度器要求Pod必须携带与Fargate Profile匹配的标签
eks.amazonaws.com/fargate-profile,当前Deployment的Pod模板缺少该标签,而CoreDNS能正常运行是因为其Pod标签已匹配Fargate Profile的选择规则。
具体解决步骤
1. 确认Fargate Profile配置
先查看你的Fargate Profile的选择器规则,确认它包含kube-system命名空间,以及对应的标签匹配规则:
aws eks describe-fargate-profile --cluster-name dsa-ph-dev-cluster --fargate-profile-name <你的Fargate Profile名称>
记录输出中selectors字段里的标签(例如eks.amazonaws.com/fargate-profile: my-fargate-profile)。
2. 修改Deployment配置
更新aws-load-balancer-controller的Deployment,添加匹配Fargate Profile的标签,并移除不必要的手动调度器指定:
apiVersion: apps/v1 kind: Deployment metadata: # 原元数据部分保持不变 spec: # 原spec其他部分保持不变 template: metadata: annotations: kubectl.kubernetes.io/restartedAt: "2023-07-13T14:38:36+02:00" prometheus.io/port: "8080" prometheus.io/scrape: "true" labels: app.kubernetes.io/instance: aws-load-balancer-controller app.kubernetes.io/name: aws-load-balancer-controller # 添加Fargate Profile匹配标签,替换为你的Profile名称 eks.amazonaws.com/fargate-profile: <你的Fargate Profile名称> spec: # 移除手动指定的fargate-scheduler,Fargate会自动处理调度 # schedulerName: fargate-scheduler # 可选:注释或删除Pod反亲和性配置(Fargate节点hostname为临时值,该配置可能干扰调度) # affinity: # podAntiAffinity: # preferredDuringSchedulingIgnoredDuringExecution: # - podAffinityTerm: # labelSelector: # matchExpressions: # - key: app.kubernetes.io/name # operator: In # values: # - aws-load-balancer-controller # topologyKey: kubernetes.io/hostname # weight: 100 # 其余spec内容保持不变
3. 应用配置并验证
应用修改后的Deployment:
kubectl apply -f <修改后的Deployment文件路径> -n kube-system
查看Pod调度状态:
kubectl get pods -n kube-system -l app.kubernetes.io/name=aws-load-balancer-controller
内容的提问来源于stack exchange,提问作者heartsaver
相关产品推荐
相关产品推荐

