Next.js Discord

Discord Forum

502s when serving project build with `standalone` through Nginx Ingress on K8S

Answered
Gazami crab posted this in #help-forum
Open in Discord
Avatar
Gazami crabOP
I have built an application, which is served locally without issue through next start. However, when I build my application, in standalone mode, and try to deploy it in a local K8S cluster, building an image as per the docs (https://nextjs.org/docs/pages/building-your-application/deploying#docker-image). Once I try to serve it through a basic service, and an Nginx Ingress Controller I get hit with 502s on seemingly random requests (happens on roughly 1/8 requests).

I have set Nginx's nginx.ingress.kubernetes.io/proxy-buffer-size to 256kb (also 1Mb later on), and proxy_buffers to 8 256kb afterwards to try and fix the issue. None of these seem to have any effect.

Since this happens to "random" requests getting JS files, enabling caching on the browser "solves" it by caching the bundle files. Nginx logs don't show any errors, and the pods themselves never went down, nor has CPU usage/memory usage spiked in peculiar manners.

Is this a known issue, or are there quirks to K8S deployments behind reverse proxies that I need to watch out for?
Answered by Gazami crab
It was caused by duplicate selector labels in the deployments
View full answer

1 Reply

Avatar
Gazami crabOP
It was caused by duplicate selector labels in the deployments
Answer