---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-with-cors
  namespace: default
  annotations:
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
    nginx.ingress.kubernetes.io/cors-expose-headers: "X-Forwarded-For, X-Forwarded-Host"
    nginx.ingress.kubernetes.io/cors-allow-headers: "X-Foo"
    nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, OPTIONS"
    nginx.ingress.kubernetes.io/cors-allow-origin: "*"
    nginx.ingress.kubernetes.io/cors-max-age: "42"

spec:
  ingressClassName: nginx
  rules:
    - host: cors.localhost
      http:
        paths:
          - path: /
            pathType: Exact
            backend:
              service:
                name: whoami
                port:
                  number: 80
