Kubernetes Ingress pathType
should be configurable without an additonal quarkus.kubernetes.ingress.rules
rule #43783
Description
Describe the bug
@Sgitario @geoand @iocanel as a continuation of #26747 and with the Kubernetes NGINX Ingress versions >= 1.8.0
warning networking.k8s.io.ingress Creation Warning -> 299 - path /something(/|$)(.*) cannot be used with pathType Prefix
when a rewrite is used, it is important that the pathType
of the default generated ingress is configurable.
# One of Prefix (default), Exact or ImplementationSpecific
quarkus.kubernetes.ports.http.path-type
https://github.com/kubernetes/ingress-nginx/releases/tag/controller-v1.8.0
https://kubernetes.github.io/ingress-nginx/faq/#validation-of-path
kubernetes/ingress-nginx#11819
https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#strict-validate-path-type
I know the following example rewrite does not make sense to you as one could use quarkus.http.root-path
, quarkus.http.non-application-root-path
, and quarkus.rest.path
, but I have a valid use case for a legacy application where I need this rewrite.
The warning will not appear by correctly setting the pathType
to ImplementationSpecific
using Kubernetes NGINX Ingress versions >= 1.8.0
.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /api/$2
name: my-api
namespace: my-namespace
spec:
ingressClassName: nginx
rules:
- host: app.example.com
http:
paths:
- backend:
service:
name: my-api
port:
number: 8080
path: /something(/|$)(.*)
pathType: ImplementationSpecific
tls:
- hosts:
- app.example.com
secretName: my-certificate
Expected behavior
The developer should be able to configure the default generated ingress pathType
using the new configuration property quarkus.kubernetes.ports.http.path-type
.
Actual behavior
Currently, it is not possible to configure the generated pathType
for the default generated ingress.
It is only possible using an additional rule where one would need to create a dummy path for the default generated ingress rule, and then we need to duplicate configuration option values.
quarkus.kubernetes.ingress.expose=true
# To change the Ingress host. By default, it's empty.
quarkus.kubernetes.ingress.host=prod.svc.url
# Kuberntes NGINX Ingress rewrite annotation
quarkus.kubernetes.ingress.annotations."nginx.ingress.kubernetes.io/rewrite-target"=/api/$2
# To change the Ingress path of the generated Ingress rule. By default, it's "/".
# We must use a dummy here so we don't duplicate the path in the additional rule
quarkus.kubernetes.ports.http.path=/_dummy
quarkus.kubernetes.ingress.rules.1.host=prod.svc.url
quarkus.kubernetes.ingress.rules.1.path=/something(/|$)(.*)
quarkus.kubernetes.ingress.rules.1.path-type=ImplementationSpecific
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
app.kubernetes.io/version: 2.12.9
app.quarkus.io/quarkus-version: 3.15.1
app.quarkus.io/build-timestamp: 2024-10-09 - 12:26:48 +0000
nginx.ingress.kubernetes.io/rewrite-target: /api/$2
labels:
app.kubernetes.io/name: my-api
app.kubernetes.io/version: 2.12.9
app.kubernetes.io/managed-by: quarkus
name: my-api
namespace: my-namespace
spec:
rules:
- host: app.example.com
http:
paths:
- backend:
service:
name: my-api
port:
name: http
path: /something(/|$)(.*)
pathType: ImplementationSpecific
- backend:
service:
name: my-api
port:
name: http
path: /_dummy
pathType: Prefix
tls:
- hosts:
- app.example.com
secretName: my-certificate
How to Reproduce?
No response
Output of uname -a
or ver
No response
Output of java -version
Java(TM) SE Runtime Environment Oracle GraalVM 21.0.4+8.1 (build 21.0.4+8-LTS-jvmci-23.1-b41)
Quarkus version or git rev
3.15.1
Build tool (ie. output of mvnw --version
or gradlew --version
)
8.10.2
Additional information
No response
Activity