how to enable-cors in GKE with ingress

后端 未结 2 1113
时光说笑
时光说笑 2021-01-07 06:35

I\'m trying to enable cors with ingress without success using the following annotation:

 kubernetes.io/ingress.class: \"nginx\"
nginx.ingress.kubernetes.io         


        
相关标签:
2条回答
  • 2021-01-07 07:16

    The correct annotation is ingress.kubernetes.io/enable-cors: "true"

    0 讨论(0)
  • 2021-01-07 07:30

    This is a supplement to the approved answer for people using Kubernetes on GCP.

    If people having an existing ingress running with class gce, they need to switch over to nginx first.

    Then you should follow the installation steps at NGINX Ingress Controller - Installation Guide.

    But please note, if you are using Kubernetes 1.8+, you have RBAC enabled by default. This might give you an error while running the first RBAC installation line. The error is like: "Error from server (Forbidden): error when creating "STDIN": clusterroles.rbac.authorization.k8s.io "nginx-ingress-clusterrole" is forbidden: attempt to grant extra privileges".

    While having this configuration step failed, the nginx ingress controller won't run, it will crash over and over again complaining about RBAC.

    When I did a search on the net myself, I found a post related to this error and it helped me to get a running nginx ingress controller.

    Please read the post by user dafstone at March 5 2018.

    It adds your GCP account as a cluster admin which allows you to install the required RBAC rules as explained in the installation guide at first.

    Good luck!

    0 讨论(0)
提交回复
热议问题