As per Nginx docs, you can set client_max_body_size in 3 sections:
Do set this value, you must change it in nginx ingress controller pod, exactly in /etc/nginx/nginx.conf.
Below example:
$ kubectl exec -ti <ingres-controller-pod> /bin/bash
$ kubectl exec -ti nginx-ingress-controller-6b85b64f49-rwxlf /bin/bash
Edit nginx.conf file.
$ vi /etc/nginx/nginx.conf
In my example hostname from ingress is my.pod.svc.
Now you need to find proper server part of file. You can search it, as it will be commented like below.
## start server <your host name from ingress>
Like below:
## start server my.pod.svc
server {
server_name my.pod.svc ;
...
Now you must find proper location. In this example case it will be /pod.
location ~* "^/pod" {
set $namespace "default";
Here you must specify this value.
As default it is 2M. During change, don't forget about ;.
There is similar thread on Stackoverflow. In that thread you can also find link with another example here.
After this change you will need to reload nginx.
EDIT:
Another option (which was used by OP in this situation) is to use annotation.
client_body_max_size
nginx.ingress.kubernetes.io/proxy-body-size: 8m
This way it would apply whole cluster.
another annotation that can be use is configuration_snippet annotation. For this example, set size only to /upload-path, it would looks like:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-snippet
annotations:
nginx.ingress.kubernetes.io/configuration-snippet: |
location /upload-path {
client_max_body_size 8M;
}