Open nlamirault opened 7 months ago
Hi @nlamirault,
Your setup looks alright to me at first glance, but I would suggest some additional troubleshooting steps to see what's going on. The No 'Access-Control-Allow-Origin' header is present
seems to hint that the ingress config is not materializing as expected. I would suggest to try the following:
Check that you don't have any other ingress set up for that host:
kubectl get ingresses -A -o wide | grep -ie agent-frontend-faro
Curl the faro endpoint from the same machine running the browser and see what headers are returned:
curl -v http://agent-frontend-faro.home.portefaix.xyz
curl -v -d '{}' http://agent-frontend-faro.home.portefaix.xyz
Check the logs for your ingress controller and verify that you can see the request you make with both curl and the browser is correctly received. nginx
also logs the service and endpoint backing the request, you can check it matches grafana-agent-grafana-agent-frontend-faro
.
In the Network tab of your browser's development tools, inspect the request Faro is doing. You won't be able to see the response (it is blocked by cors), but the request might be worth checking, in case it includes strange headers.
Right click that request, "Copy as curl", and try to issue it in the terminal. There you will be able to see the response with its headers.
If this does not lead you to the problem, feel free to paste the output of those commands here, and we'll do our best to help you diagnose the situation :)
Hi @roobre i migrate to Alloy. I've got 2 ingress:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/cors-allow-headers: DNT,X-CustomHeader,X-LANG,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Api-Key,X-Device-Id,Access-Control-Allow-Origin
nginx.ingress.kubernetes.io/cors-allow-methods: PUT, GET, POST, OPTIONS, DELETE
nginx.ingress.kubernetes.io/cors-allow-origin: '*'
nginx.ingress.kubernetes.io/enable-cors: "true"
labels:
app: alloy-frontend
app.kubernetes.io/instance: alloy
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: alloy-frontend
app.kubernetes.io/part-of: alloy
app.kubernetes.io/version: v1.1.0
argocd.argoproj.io/instance: alloy
helm.sh/chart: alloy-frontend-0.3.0
portefaix.xyz/version: v0.54.0
name: alloy-frontend-external
namespace: opentelemetry
spec:
ingressClassName: nginx
rules:
- host: alloy-frontend.home.portefaix.xyz
http:
paths:
- backend:
service:
name: alloy-alloy-frontend
port:
number: 12345
path: /
pathType: Prefix
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/cors-allow-methods: GET, PUT, POST, DELETE, PATCH,
OPTIONS
nginx.ingress.kubernetes.io/cors-allow-origin: '*'
nginx.ingress.kubernetes.io/cors-max-age: "1728000"
nginx.ingress.kubernetes.io/enable-cors: "true"
labels:
app: alloy-frontend
app.kubernetes.io/instance: alloy
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: alloy-frontend
app.kubernetes.io/part-of: alloy
app.kubernetes.io/version: v1.1.0
argocd.argoproj.io/instance: alloy
helm.sh/chart: alloy-frontend-0.3.0
portefaix.xyz/version: v0.54.0
name: alloy-frontend-faro-external
namespace: opentelemetry
spec:
ingressClassName: nginx
rules:
- host: alloy-frontend-faro.home.portefaix.xyz
http:
paths:
- backend:
service:
name: alloy-alloy-frontend
port:
number: 12347
path: /
pathType: Prefix
and I've got an error using curl:
$ curl -v -d '{}' http://alloy-frontend-faro.home.portefaix.xyz
* Host alloy-frontend-faro.home.portefaix.xyz:80 was resolved.
* IPv6: (none)
* IPv4: 100.126.241.86
* Trying 100.126.241.86:80...
* Connected to alloy-frontend-faro.home.portefaix.xyz (100.126.241.86) port 80
> POST / HTTP/1.1
> Host: alloy-frontend-faro.home.portefaix.xyz
> User-Agent: curl/8.6.0
> Accept: */*
> Content-Length: 2
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 405 Method Not Allowed
< Date: Fri, 21 Jun 2024 14:52:14 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 18
< Connection: keep-alive
< Allow: GET, OPTIONS
<
* Connection #0 to host alloy-frontend-faro.home.portefaix.xyz left intact
Method Not Allowed%
Hey,
To me something seems to be off with your ingress-nginx annotations, or config. The curl command you posted should have returned CORS headers, something like:
< access-control-allow-origin: *
< access-control-allow-methods: GET, PUT, POST, DELETE, PATCH, OPTIONS
< access-control-allow-headers: DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization
I'd suggest taking a look at the ingress-nginx manuals, logs, and/or generated config to try and figure out what's happening in there.
Hi, i would like to test Faro with Grafana Agent with this application. I use a K3s cluster with nginx-ingress-controller deployed, and a Grafana Agent with Faro configuration:
Ingress:
Pizza configuration:
Pizza application is deployed and works fine. But in the browser console, i've got these logs:
How can i fix that CORS error ? Thanks.