kuberneteskubernetes-ingressamazon-eksaws-alb

Why am I getting 502 errors on my ALB end points, targeted at EKS hosted services


I am building a service in EKS that has two deployments, two services (NodePort) , and a single ingress.

Here is my complete 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

Solution

  • I don't know why but it turns out that the label given to to ingress has to be unique.

    When I changed the label from 'example-app' to 'example-app-ingress' it just started working.