0

I'm trying to deploy this ingress service on AWS EKS. it works locally, but not when deployed to EKS.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: 'true'
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: a16a5f3b82c3b4cf0a27a801c8b43788-1a53212dd4e2fc34.elb.ca-central-1.amazonaws.com
      http:
        paths:
          - path: /?(.*)
            pathType: Prefix
            backend:
              service:
                name: store-cluster-ip-service
                port:
                  number: 80
          - path: /api/?(.*)
            pathType: Prefix
            backend:
              service:
                name: products-api-cluster-ip-service
                port:
                  number: 5002

I'm getting the following errors.

Warning: annotation "kubernetes.io/ingress.class" is deprecated, please use 'spec.ingressClassName' instead
Warning: path /?(.*) cannot be used with pathType Prefix
Warning: path /api/?(.*) cannot be used with pathType Prefix
Error from server (BadRequest): error when creating "ingress-service.yaml": admission webhook "validate.nginx.ingress.kubernetes.io" denied the request: ingress contains invalid paths: path /?(.*) cannot be used with pathType Prefix
path /api/?(.*) cannot be used with pathType Prefix

I'm following an outdated course on udemy so the first warning i'm aware i have to change to using an ingress class, but why are the second two errors happening? Are they related to the first issue (ingress Class)?

1 Answer 1

0

I believe you are encountering the Nginx Ingress Controller's "strict-validate-path-type" check, which is enabled by default. When this option is enabled, there is strict validation of Exact and Prefix types, only allowing:

alphanumeric characters and "-", "_" and additional "/".

I would try changing the type to ImplementationSpecific.

The other option would be to update the Nginx Ingress Controller ConfigMap to set strict-validate-path-type: "false". Make sure to restart the controller pod(s) after this change.

Also, the regex syntax may have changed since the Udemy example was created, here is the latest docs on regex in path matching.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.