I'm deploying Traefik 3.2.0 using the v33.0.0 of the Helm chart, configured to use the Gateway API, and everything has been working fine. As I was adding services, I noticed that the "*" origin allowed by my backend service wasn't being passed through by Traefik, resulting in CORS errors. I believe this behavior is documented here. To resolve the issue, I tried adding a Middleware as follows:
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: cors-header
namespace: traefik
spec:
headers:
accessControlAllowHeaders:
- "*"
accessControlAllowOriginList:
- "*"
And tried to configure the Helm chart to use this Middleware (as described in the values.yaml comments) like this:
traefik:
providers:
kubernetesIngress:
enabled: false
kubernetesGateway:
enabled: true
gateway:
enabled: true
annotations:
cert-manager.io/issuer: selfsigned-issuer
listeners:
websecure-influxdb:
hostname: influxdb.bioapp.internal
port: 8443
protocol: HTTPS
namespacePolicy: All
certificateRefs:
- name: bioapp-influxdb-tls
websecure-emqx:
hostname: emqx.bioapp.internal
port: 8443
protocol: HTTPS
namespacePolicy: All
certificateRefs:
- name: bioapp-emqx-tls
... snip some more listeners ...
ports:
traefik:
expose:
default: true
websecure:
port: 8443
middlewares: [cors-header]
This results in the error message:
2024-11-07T16:54:55Z ERR error="middleware \"cors-header@kubernetesgateway\" does not exist" entryPointName=websecure routerName=httproute-bioapp-emqx-gw-traefik-traefik-gateway-ep-websecure-0-ead85cd493ac4eede6a6@kubernetesgateway
2024-11-07T16:54:55Z ERR error="middleware \"cors-header@kubernetesgateway\" does not exist" entryPointName=websecure routerName=httproute-bioapp-influxdb-gw-traefik-traefik-gateway-ep-websecure-0-f0249643959c474d9e49@kubernetesgateway
After carefully reading the docs, I have tried the following permutations when specifying the middleware in the Helm chart:
cors-header
cors-header@kubernetesgateway
cors-header@kubernetescrd
traefik-cors-header
traefik-cors-header@kubernetesgateway
traefik-cors-header@kubernetescrd
All of these result in corresponding error messages similar to ERR error="middleware \"<middleware-namespace>-<middleware-name>@<provider-name>\" does not exist"
. Can anyone help me figure out how to get past this, what am I doing wrong?