Error 404 aws-load-balancer-controller

Hello everyone, I don’t want to bother you but I have no choice, I’ve been trying to solve the problem for days and I can’t do it.

I installed the chart aws-load-balancer-controller but I can’t get my gunicorn application to work.
In the logs of the AWS ballast I see the following

2023-01-31T12:37:03.569275Z app/k8s-aaaaaaaa-a0e6e75bee/01091f9645ec60b0
10.54.171.250:49234 - -1 -1 -1 404 - 389 167 "POST http://test-app.aws.domain.com:80/booking-service/create-booking HTTP/1.1" "curl/7.77.0" - - - "Root=1-63d90b6f-439aff734f6630c042c5a69b" "-" "-" 0 2023-01-31T12:37:03.561000Z "fixed-response" "-" "-" "-" "-" "-" "-"

Here my config:

any sugestions?

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: default-http-backend
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internal
alb.ingress.kubernetes.io/target-type: instance
alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-east-1:xx:certificate/x-8420-4bda-aa37-x
alb.ingress.kubernetes.io/group.name: kiuapi-adapters
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]'
alb.ingress.kubernetes.io/load-balancer-attributes: access_logs.s3.enabled=true,access_logs.s3.bucket=x,access_logs.s3.prefix=x
spec:
tls:
- hosts:
- x-prod.aws.x.com
rules:
- host: x-prod.aws.x.com
http:
paths:
- path: /adapter-login
pathType: Prefix
backend:
service:
name: adapter-login
port:
number: 8004
- path: /adapter-sqlpooler
pathType: Prefix
backend:
service:
name: adapter-sqlpooler
port:
number: 8003
- path: /booking-service
pathType: Prefix
backend:
service:
name: booking-service
port:
number: 8005
- path: /issue-service
pathType: Prefix
backend:
service:
name: issue-service
port:
number: 8006
- path: /
pathType: Prefix
backend:
service:
name: adapter-rca
port:
number: 8001

---
apiVersion: v1
kind: Service
metadata:
name: adapter-login
namespace: kiuapi-adapters
labels:
app: adapter-login
annotations:
spec:
type: NodePort
selector:
app: adapter-login
ports:
- name: adapter-login
targetPort: 8004
port: 8004
protocol: TCP

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: adapter-login
  namespace: kiuapi-adapters
  labels:
    app: adapter-login
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: adapter-login
    spec:
      containers:
      - name: adapter-login
        image: xxxx.dkr.ecr.x-x-x.amazonaws.com/x:latest
        imagePullPolicy: Always
        envFrom:
        - configMapRef:
           name: env-adapter-login
        ports:
         - name: http
           containerPort: 8004
           protocol: TCP
  selector:
    matchLabels:
      app: adapter-login

Updated:

This is work fine:

this is not work

  • host: adapters-prod.aws.aaaaa.com
    http:
    paths:
    • path: /
      pathType: Prefix
      backend:
      service:
      name: adapter-login
      port:
      number: 8004
    • path: /adapter-sqlpooler
      pathType: Prefix
      backend:
      service:
      name: adapter-sqlpooler
      port:
      number: 8003
    • path: /issue-service
      pathType: Prefix
      backend:
      service:
      name: issue-service
      port:
      number: 8006
    • path: /booking-service
      pathType: Prefix
      backend:
      service:
      name: booking-service
      port:
      number: 8005

is a problem with Amazon balancer

I also came across this issue. I worked on it for more then 7 days.
All of the examples and documentation say this should work. There are many similar discussions of how people can’t get this to work. After much development and testing I came to the same conclusion.
Path based rules do not work with ingress rules and AWS ALB as written about. Host based ruling is the only way to make it work.
I wish AWS would change their documentation of fix the underlying problem.

I encountered a similar issue. It may seem counterintuitive, but the behavior you’re observing is actually correct. The challenge arises because the Ingress does not strip the path from your request.

Consider the following YAML configuration for your Ingress paths:

paths:
  - path: /your-custom-path
    pathType: Prefix
    backend:
      service:
        name: my-service
        port:
          number: 80

When you make a request to /your-custom-path via Ingress, the request is forwarded to your service, including the path. Consequently, your container receives a request like "GET /your-custom-path". If your container doesn’t recognize the /your-custom-path route, it will return a 404 error. To resolve this, you can configure /your-custom-path as the root of your application, which will enable the hosted path to function correctly.

Unfortunately, as of the date of this comment (2024-06-12), the AWS Ingress Controller lacks a rewrite-target feature akin to that of the Nginx Controller. If you switch to Nginx, you can utilize the nginx.ingress.kubernetes.io/rewrite-target: / annotation, which provides the capability to remove the path from the incoming request.

For more information on the rewrite-target feature in Nginx, refer to the official documentation: