kubernetes-sigs / aws-load-balancer-controller

A Kubernetes controller for Elastic Load Balancers
https://kubernetes-sigs.github.io/aws-load-balancer-controller/
Apache License 2.0
3.93k stars 1.46k forks source link

paths not working #699

Closed Toolenaar closed 5 years ago

Toolenaar commented 5 years ago

Hi I have setup ingress-controller on AWS EKS, but I am having problems resolving paths other then the base /

In the example below / does work correctly however /api does not work.

I am using the same app in this example but I have tested it with other apps running in my cluster aswell, all which dont work on /somethinghere.

Any idea what might be going wrong ?

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: "webapp-alb-ingress"
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/subnets: subnet-01e193631sfedsf0a3,subnet-0b0064f88sdffd075,subnet-0252d90sdffdfb77e
    alb.ingress.kubernetes.io/tags: Environment=prod,Team=locali
    ingress.kubernetes.io/rewrite-target: /
  labels:
    app: webapp-service
spec:
  backend:
    serviceName: default-http-backend
    servicePort: 80
  rules:
  - http:
      paths: 
        - backend:
            serviceName: localiapi
            servicePort: 4040
          path: /api
        - backend:
            serviceName: localiapi
            servicePort: 4040
          path: /
nerdinand commented 5 years ago

I had the same problem, solution is to use path: /*. Because the rule for the ALB is referencing this value directly, e.g.:

screenshot 2018-10-29 at 14 26 31

So if the rule says "Path is /", then all your requests (other than for /) return a 404 (fallback rule).

Toolenaar commented 5 years ago

Thanks for the quick reply. Unfortunately this does not fix my case :(

When I look at the rules on the ALB they look like this:

screenshot 2018-10-29 at 15 15 25

Which seems correct to me. Both paths should direct to the same app. However when I go to /api, I get a 404 returned by the app (not the default-backend).

screenshot 2018-10-29 at 15 20 46

bigkraig commented 5 years ago

Does your service respond on /api? The ALB does not do URL rewrites and therefor the service needs to respond on the same paths being requested on the ALB.

Toolenaar commented 5 years ago

@bigkraig Aha! that makes sense... I did not take this into account. I am very new to Kubernetes, so thanks for pointing that out.

bigkraig commented 5 years ago

NP, definitely not what most people expect and it would be nice if we could provide a rewrite rule in the ALB. You may also want to change your rule to use /api* and ditch the /* rule.

omerfsen commented 5 years ago

I have the same issue. Simply put I have a site and i have created an ALB like:

apiVersion: extensions/v1beta1 kind: Ingress metadata: name: identity-manager namespace: default annotations: kubernetes.io/ingress.class: alb alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/tags: app=node,tier=backend alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:eu-central-1:7yyyyyy:certificate/xxxx alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}, {"HTTP": 8080}, {"HTTPS": 8443}]' alb.ingress.kubernetes.io/ip-address-type: ipv4 alb.ingress.kubernetes.io/backend-protocol: HTTP alb.ingress.kubernetes.io/subnets: subnet-0e0b2522292ac20f8,subnet-0957a17b6e8e63294,subnet-040d1fc58359f8151 alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}' spec: rules:

So with this

identity-manager.cloud.serra.pw/api/ works but anything underneath does not work so I need to edit

      - path: /api
        backend:
          serviceName: node
          servicePort: 80

to

      - path: /api/*
        backend:
          serviceName: node
          servicePort: 80

Then it works. Other Ingress simply works with /api only. So aws-alb-ingress-controller must match to this behaviour I think.

fejta-bot commented 5 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot commented 5 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

Erokos commented 5 years ago

Hi,

have the same problem, It would be nice if we had a rewrite target rule for the alb like it's possible with the nginx ingress controller.

BR

fejta-bot commented 5 years ago

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

k8s-ci-robot commented 5 years ago

@fejta-bot: Closing this issue.

In response to [this](https://github.com/kubernetes-sigs/aws-alb-ingress-controller/issues/699#issuecomment-511183369): >Rotten issues close after 30d of inactivity. >Reopen the issue with `/reopen`. >Mark the issue as fresh with `/remove-lifecycle rotten`. > >Send feedback to sig-testing, kubernetes/test-infra and/or [fejta](https://github.com/fejta). >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
k8s-ci-robot commented 4 years ago

@vjsairam: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to [this](https://github.com/kubernetes-sigs/aws-alb-ingress-controller/issues/699#issuecomment-678247527): >/reopen Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
bg-chun commented 3 years ago

it still happens....

petr4 commented 3 years ago

Hey! We need help with it as ingress api is changed to apiVersion: networking.k8s.io/v1, have to use http block

omerfsen commented 3 years ago

Aws works only with /* for subpaths

andradedpg commented 2 years ago

It still happens :( Anyone?

mortrick commented 1 year ago

Did someone find a way to transfer traffic to the root path of the service using the ingress version networking.k8s.io/v1 ?

chelto commented 1 year ago

I'm still getting issues with this. spent 3 days trying to get it to work.