Search code examples
kubernetesghost-blog

How to increase the maximum file size when using Ghost docker image and Kubernetes


I am hosting a Ghost blog using Kubernetes and the docker image ghost with version 3.16.1. While uploading a theme, I get a error message that the file size is to large.

The file you uploaded was larger than the maximum file size your server allows.

I have been remoting into the pod to see if I found any settings there that I could configure without see any. Can not see what configuration to add in the deployment file to increase the default.

I have a Ingress controller that is using Nginx and is specifying "nginx.org/client-max-body-size", but that did not help after I added that one.

Do anyone know how I can increase the maximum file size while using the Ghost docker image and nginx ingress controller? Below is part of the ingress conroller configuation file and the deployment file.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: beitostolenlive-no-ingress
  namespace: beitostolenlive-no
  annotations:
    kubernetes.io/ingress.class: "nginx"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    nginx.org/proxy-connect-timeout: "30s"
    nginx.org/proxy-read-timeout: "20s"
    nginx.org/client-max-body-size: "50m"

Here is the deployment configuration file.

apiVersion: apps/v1
kind: Deployment
metadata:
    name: beitostolenlive-no
    namespace: beitostolenlive-no
    labels:
        web: beitostolenlive-no
spec:
    replicas: 1
    strategy:
        type: Recreate
    selector:
        matchLabels:
            web: beitostolenlive-no
    template:
        metadata:
            labels:
                web: beitostolenlive-no
        spec:
            containers:
            - name: beitostolenlive-no
              image: ghost:3.16.1
              imagePullPolicy: Always
              ports:
                - containerPort: 2368
              env:
                - name: url
                  value: https://beitostolenlive.no
                - name: database__client
                  value: mysql
                - name: database__connection__host
                  value: ***
                - name: database__connection__user
                  value: ***
                - name: database__connection__password
                  value: ***
                - name: database__connection__database
                  value: ***
              volumeMounts:
              - mountPath: /var/lib/ghost/content
                name: content
            volumes:
            - name: content
              persistentVolumeClaim:
                claimName: beitostolenlive-no-content

Solution

  • Please add nginx.ingress.kubernetes.io/proxy-body-size annotation to your ingress configuration file.

    For NGINX, an such error will be returned to the client when the size in a request exceeds the maximum allowed size of the client request body. This size can be configured by the parameter client_max_body_size.

    To configure this setting globally for all Ingress rules, the proxy-body-size value may be set in the NGINX ConfigMap. To use custom values in an Ingress rule define annotation I have mentioned.

    Useful information: custom-max-body-size, 413-k8s-helm.