【问题标题】:How to increase the maximum file size when using Ghost docker image and Kubernetes使用 Ghost docker 镜像和 Kubernetes 时如何增加最大文件大小
【发布时间】:2020-08-09 17:42:44
【问题描述】:

我正在使用 Kubernetes 和版本 3.16.1 的 docker 镜像 ghost 托管 Ghost 博客。上传主题时,我收到一条错误消息,指出文件过大。

您上传的文件大于服务器允许的最大文件大小。

我一直在远程访问 pod,以查看是否在其中找到任何可以配置但看不到任何设置的设置。看不到部署文件中要添加什么配置来增加默认值。

我有一个使用 Nginx 并指定“nginx.org/client-max-body-size”的 Ingress 控制器,但在我添加该控制器后没有帮助。

有人知道在使用 Ghost docker 映像和 nginx 入口控制器时如何增加最大文件大小吗?下面是入口控制器配置文件和部署文件的一部分。

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"

这是部署配置文件。

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

【问题讨论】:

  • 你尝试添加 nginx.ingress.kubernetes.io/proxy-body-size 注解吗?
  • 所以我将它作为解决方案发布,您可以接受并让其他社区更容易看到?
  • 是的,如果您发布该解决方案,我会将其标记为已接受。 @MaggieO

标签: kubernetes ghost-blog


【解决方案1】:

请在您的入口配置文件中添加nginx.ingress.kubernetes.io/proxy-body-size 注解。

对于 NGINX,当请求中的大小超过客户端请求正文的最大允许大小时,将向客户端返回此类错误。这个大小可以通过参数client_max_body_size来配置。

要为所有 Ingress 规则全局配置此设置,可以在 NGINX ConfigMap 中设置 proxy-body-size 值。要在 Ingress 规则中使用自定义值,请定义我提到的注释。

有用信息:custom-max-body-size413-k8s-helm

【讨论】:

    猜你喜欢
    • 2023-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-09
    • 1970-01-01
    • 2015-07-17
    • 1970-01-01
    相关资源
    最近更新 更多