Home > Software engineering >  Kubernetes nginx ingress controller cannot upload size more than 1mb
Kubernetes nginx ingress controller cannot upload size more than 1mb

Time:06-08

I am fairly new to GCP and I have a rest URI to upload large files.
I have a ngress-nginx-controller service and want to change it to upload files larger than 1mb and set a limit.

apiVersion: v1
kind: Service
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"ingress-nginx","app.kubernetes.io/version":"0.35.0","helm.sh/chart":"ingress-nginx-2.13.0"},"name":"ingress-nginx-controller","namespace":"ingress-nginx"},"spec":{"externalTrafficPolicy":"Local","ports":[{"name":"http","port":80,"protocol":"TCP","targetPort":"http"},{"name":"https","port":443,"protocol":"TCP","targetPort":"https"}],"selector":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/name":"ingress-nginx"},"type":"LoadBalancer"}}
  creationTimestamp: "2020-09-21T18:37:27Z"
  finalizers:
  - service.kubernetes.io/load-balancer-cleanup
  labels:
    app.kubernetes.io/component: controller
    app.kubernetes.io/instance: ingress-nginx
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/version: 0.35.0
    helm.sh/chart: ingress-nginx-2.13.0
  name: ingress-nginx-controller
  namespace: ingress-nginx

This is the error it throws :

<html>
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx/1.19.2</center>
</body>
</html>

CodePudding user response:

If you need to increase the body size of files you upload via the ingress controller, you need to add an annotation to your ingress resource:

nginx.ingress.kubernetes.io/proxy-body-size: 8m

Documentation available here: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#custom-max-body-size

  • Related