为什么在针对EKS托管服务的ALB端点上出现502错误

时间:2019-11-26 12:20:30

标签: kubernetes kubernetes-ingress eks aws-alb

我正在EKS中构建一个服务,该服务具有两个部署,两个服务(NodePort)和一个入口。

  • 我正在使用aws-alb-ingress-controller。
  • 当我运行kubectl port-forward POD 8080:80时,它确实向我显示了我正在工作的豆荚。
  • 当我用alb查看生成的端点时,出现502错误。
  • 当我查看目标组的已注册目标时,看到消息,运行状况检查失败,并显示以下代码:[502]

这是我完整的字母。

---
#Example game deployment and service
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: "example-game"
  namespace: "example-app"
spec:
  replicas: 5
  template:
    metadata:
      labels:
        app: "example-game"
    spec:
      containers:
      - image: alexwhen/docker-2048
        imagePullPolicy: Always
        name: "example-game"
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: "service-example-game"
  namespace: "example-app"
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: NodePort
  selector:
    app: "example-app"


#Example nginxdemo Deployment and Service
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: "example-nginxdemo"
  namespace: "example-app"
spec:
  replicas: 5
  template:
    metadata:
      labels:
        app: "example-nginxdemo"
    spec:
      containers:
      - image: nginxdemos/hello
        imagePullPolicy: Always
        name: "example-nginxdemo"
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: "service-example-nginxdemo"
  namespace: "example-app"
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: NodePort
  selector:
    app: "example-app"
---

#Shared ALB ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: "example-ingress"
  namespace: "example-app"
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/healthcheck-protocol: HTTP
    Alb.ingress.kubernetes.io/healthcheck-port: traffic-port
    alb.ingress.kubernetes.io/healthcheck-path: /

#   alb.ingress.kubernetes.io/scheme: internal
#   alb.ingress.kubernetes.io/load-balancer-attributes: routing.http2.enabled=true

  labels:
    app: example-app
spec:
  rules:
    - http:
        paths:
          - path: /game/*
            backend:
              serviceName: "service-example-game"
              servicePort: 80
          - path: /nginxdemo/*
            backend:
              serviceName: "service-example-nginxdemo"
              servicePort: 80

1 个答案:

答案 0 :(得分:0)

我不知道为什么,但是事实证明赋予入口的标签必须唯一。

当我将标签从“ example-app”更改为“ example-app-ingress”时,它开始工作。