Search code examples
amazon-web-serviceskubernetesamazon-elb

Kubernetes - Ingress Path regex - contains a character that is not valid


I'm getting the following error when using regex. I want to filter based on the query string to send the traffic to a different port.

controller.go:217] kubebuilder/controller "msg"="Reconciler error" "error"="failed to reconcile listeners due to failed to reconcile rules due to failed creating rule 1 on arn:aws:elasticloadbalancing:ap-south-1:1234:listener/app/51233e9-testwebdev-test-1eb8/1234 due to ValidationError: Condition value '/(action=.*\u0026uid.*test=[0-9]+)|test|status\u0026uid)' contains a character that is not valid\n\tstatus code: 400, request id: 664231b0-7c95-4ee6-a14b-fb83e9d7590a"  "controller"="alb-ingress-controller" "request"={"Namespace":"test-web-dev","Name":"test-ingress-dev"

The path has regex as shown below

  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    nginx.ingress.kubernetes.io/use-regex: "true"
    ....

  paths:
    - path: "/.*(action=.*&uid.*test=[0-9]+)|(test|status&uid)"
      backend:
        serviceName: httpd
        servicePort: 1234
    - path: /
      backend:
        serviceName: httpd
        servicePort: 443

Solution

  • As I see your manifests, your Ingress is configured as AWS ALB instead of NGINX due to kubernetes.io/ingress.class: alb. So you should configure AWS path condition compliance, refer Path Conditions for more details. AFAIK, AWS ALB regex is supported partially, not full regex.

    A path pattern is case-sensitive, can be up to 128 characters in length, and can contain any of the following characters.
    
    1. A–Z, a–z, 0–9
    
    2. _ - . $ / ~ " ' @ : +
    
    3. & (using &)
    
    4. * (matches 0 or more characters)
    
    5. ? (matches exactly 1 character)