Hey guys, I am trying to upload files larger than 200mb using a netcore app deployed to a kubernetes cluster with a load balancer. When I post to the endpoint the file I get an NGINX error 413 Request Entity Too Large - NGINX. This is weird for me because I didn’t install any nginx to proxy the requests through. I read that netcore apps use Kestrel as the server.
service.yaml
apiVersion: v1
kind: Service
metadata:
name: myapp-api-service
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "0"
spec:
type: LoadBalancer
selector:
app: myapp
microService: myapp-api
ports:
- protocol: TCP
port: 80
targetPort: myapp-api
deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-api
spec:
selector:
matchLabels:
app: myapp
microService: myapp-api
replicas: 1
template:
metadata:
labels:
app: myapp
microService: myapp-api
spec:
containers:
- name: myapp-api
image: harbor.test.ro/myapp/myapp-api:latest
imagePullPolicy: Always
ports:
- name: myapp-api
containerPort: 80
protocol: TCP
imagePullSecrets:
- name: regcred
Dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic AS build
WORKDIR /app
# # copy csproj and restore as distinct layers
COPY Myapp.API/Myapp.API/*.csproj ./Myapp.API/
# # COPY utils/*.csproj ./utils/
WORKDIR /app/Myapp.API/
RUN dotnet restore
WORKDIR /app/
COPY Myapp.API/. ./Myapp.API/
# COPY utils/. ./utils/
WORKDIR /app/Myapp.API
RUN dotnet publish -c Release -o out
# test application -- see: dotnet-docker-unit-testing.md
# FROM build AS testrunner
# WORKDIR /app/tests
# COPY tests/. .
# ENTRYPOINT ["dotnet", "test", "--logger:trx"]
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
WORKDIR /app
COPY --from=build /app/Myapp.API/out ./
ENTRYPOINT ["dotnet", "Myapp.API.dll"]
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
thanks @jkwiatkoski Adding nginx.ingress.kubernetes.io/proxy-body-size: xm can help to solve 413 issue.
I believe you want to use a service annotation like such: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#custom-max-body-size
Play around with the sizes a bit to find which ones work best for you.
Regards,
John Kwiatkoski Senior Developer Support Engineer - Kubernetes