grafana / helm-charts

Apache License 2.0
1.66k stars 2.28k forks source link

enforce_domain breaks quay.io/kiwigrid/k8s-sidecar reloading #3330

Open brianbraunstein opened 1 month ago

brianbraunstein commented 1 month ago

Problem

Turning on enforce_domain https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#enforce_domain forces a redirect even of the localhost API calls done by the sidecars quay.io/kiwigrid/k8s-sidecar . It looks like when quay.io/kiwigrid/k8s-sidecar gets the redirect, it switches from POST to GET, at which point the request fails. Setting reloadURL manually is a workaround.

Suggestion

When setting enforce_domain, then default reloadURL to use root_url https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#root_url instead of localhost. Which will involve some tweaking here: https://github.com/grafana/helm-charts/blob/79ab1d5f0cda7088a21a7643b91ee1136faf6901/charts/grafana/templates/_pod.tpl#L386-L387

Alternatives

I also filed https://github.com/grafana/grafana/issues/93773 to try to make enforce_domain NOT redirect localhost (or have an additional option to do this) which would avoid the need to fix this.

Fixing quay.io/kiwigrid/k8s-sidecar to handle redirects is another option.

brianbraunstein commented 1 month ago

I looked into fixing quay.io/kiwigrid/k8s-sidecar but actually I think it's fine. The problem is the grafana server is returning a 301 when it should return a 308. I update the grafana issue https://github.com/grafana/grafana/issues/93773 with more details about this. That means there are 2 alternatives, both described in https://github.com/grafana/grafana/issues/93773