Hello,
I am following https://docs.konghq.com/hub/kong-inc/cors/ to setup cors plugin for a route.
First I have KongPlugin created:
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: cors
namespace: kong
config:
origins:
- http://*.mydomain.com
plugin: cors
Then I have the plugin added to the Ingress:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: data-service
namespace: common
annotations:
kubernetes.io/ingress.class: kong
konghq.com/strip-path: "true"
konghq.com/plugins: cors
spec:
rules:
- http:
paths:
- path: /v1/api-data-service
backend:
serviceName: data-service
servicePort: 80
However, when I call the API I don’t see anything like access-control-allow-origin
in the response header:
Can someone please help?
BTW - some inspection I did:
$ curl -s localhost:8001/plugins | json
{
"next": null,
"data": []
}
$ curl -s localhost:8001/routes/3e805d97-8d99-54af-b2be-793305c4525d | json
{
"id": "3e805d97-8d99-54af-b2be-793305c4525d",
"tags": null,
"paths": [
"/v1/api-data-service"
],
"destinations": null,
"headers": null,
"protocols": [
"http",
"https"
],
"created_at": 1607652789,
"methods": null,
"snis": null,
"service": {
"id": "6918b268-4fb1-5562-b4a0-d16012fb829d"
},
"name": "common.data-service.00",
"updated_at": 1607652789,
"hosts": null,
"preserve_host": true,
"regex_priority": 0,
"strip_path": true,
"sources": null,
"response_buffering": true,
"https_redirect_status_code": 426,
"path_handling": "v0",
"request_buffering": true
}
$ kubectl describe kongplugins.configuration.konghq.com cors
Name: cors
Namespace: kong
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"configuration.konghq.com/v1","config":{"origins":["http://*.mydomain.com"]},"kind":"KongPlugin","metadata":{"annotations"...
API Version: configuration.konghq.com/v1
Config:
Origins:
http://*.mydomain.com
Kind: KongPlugin
Metadata:
Creation Timestamp: 2020-12-11T02:00:53Z
Generation: 5
Managed Fields:
API Version: configuration.konghq.com/v1
Fields Type: FieldsV1
fieldsV1:
f:config:
.:
f:origins:
f:metadata:
f:annotations:
.:
f:kubectl.kubernetes.io/last-applied-configuration:
f:plugin:
Manager: kubectl
Operation: Update
Time: 2020-12-11T02:20:01Z
Resource Version: 26537774
Self Link: /apis/configuration.konghq.com/v1/namespaces/kong/kongplugins/cors
UID: 0a3cd227-3bdf-48bd-bfc5-0d84749ffa2d
Plugin: cors
Events: <none>
$ kubectl describe ingress --namespace common data-service
Name: data-service
Namespace: common
Address: a097f4e169e6f4cec841753752f24d69-1322353396.ap-southeast-1.elb.amazonaws.com
Default backend: default-http-backend:80 (<none>)
Rules:
Host Path Backends
---- ---- --------
*
/v1/api-data-service data-service:80 (10.2.0.109:9000)
Annotations:
konghq.com/strip-path: true
kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{"konghq.com/plugins":"cors","konghq.com/strip-path":"true","kubernetes.io/ingress.class":"kong"},"name":"data-service","namespace":"common"},"spec":{"rules":[{"http":{"paths":[{"backend":{"serviceName":"data-service","servicePort":80},"path":"/v1/api-data-service"}]}}]}}
kubernetes.io/ingress.class: kong
konghq.com/plugins: cors
Events: <none>