I am trying to enable CORS on ingress in kubernetes running traefik. So that in the response header I could add CORS origin to be allowed to every host for now. How can I do that? Below is the k8 ingress.yml file.
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: test-ingress
namespace: test
labels:
app: test-cors-app
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: company.host
http:
paths:
- path: /
backend:
serviceName: test-service
servicePort: 80
UPDATE I have traefik 1.7
You can use this annotation in your ingress :
traefik.ingress.kubernetes.io/custom-response-headers
oringress.kubernetes.io/custom-response-headers
both will work with traefik.Modify your ingress.yml file as :
**Modify annotation attributes accrodingly. It works for traefik lower versions as well. see here