1

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

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

这是我完整的 yaml。

---
#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
4

1 回答 1

1

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

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

于 2020-02-18T11:26:14.457 回答