-4

I deployed this Wordpress kubernetes container: https://console.cloud.google.com/marketplace/details/google/wordpress?project

But I have a problem with upload the theme in Wordpress. The uploaded file exceeds the upload_max_filesize directive in php.ini.

I can't find the file: php.ini. in the pods of kubernetes.

I tried to use plugin for edit php.ini in Wordpress https://wordpress.org/plugins/php-settings/ but it's no write the file.

Could someone help me with a step-by-step guide to modify the container's yaml or other solution?

4

3 回答 3

4

正如这里所建议的,推荐的方法是挂载一个 php config ini 文件。最方便的公开方式是使用 Kubernetes ConfigMaps。请创建一个新的配置映射:

apiVersion: v1
kind: ConfigMap
metadata:
  name: wp-php-config
  namespace: default
data:
  uploads.ini: |-
    file_uploads = On
    upload_max_filesize = 256M
    post_max_size = 256M
    memory_limit = 64M
    max_execution_time = 600

然后通过将以下配置添加到您的 pod 中,将 configMap 公开为您的 pod 中的卷spec.template.spec.containers

... (wordpress container specs)
  volumeMounts:
    - mountPath: /usr/local/etc/php/conf.d/uploads.ini
      name: php-config
      subPath: uploads.ini

(...)

volumes:
  - configMap:
      defaultMode: 420
      name: wp-php-config
    name: php-config

您可能还需要调整入口最大上传限制。假设您使用的是 nginx 入口,请用注释装饰它:

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

如果要将更改应用于全局入口,请搜索入口 configMap 并在此处添加设置。

于 2019-08-07T12:20:54.967 回答
0

这是我为解决问题所做的:

  1. 我将这些行添加到我的 Dockerfile

    上传文件

    RUN touch /usr/local/etc/php/conf.d/uploads.ini \ && echo "file_uploads = On \n\ max_execution_time = 600 \n\ upload_max_filesize = 200M \n\ post_max_size = 200M" >> /usr/local /etc/php/conf.d/uploads.ini

  2. 在 nginx-ingress dependencies.yml 中,我在 configmap 中添加了这些“数据”参数并且它起作用了。

    种类:ConfigMap apiVersion:v1 元数据:名称:nginx-configuration 命名空间:ingress-nginx 标签:app.kubernetes.io/name:ingress-nginx app.kubernetes.io/part-of:ingress-nginx 数据:proxy-body-尺寸:“200m” 客户端最大身体尺寸:“200m”

  3. 之后,*kubectl apply -f ingress/dependencies.yml*我能够上传超过 2mb 的数据。

试试这个,看看它是否适合你

于 2020-04-19T09:33:25.090 回答
0

您可以执行“kubectl get pods”来列出 pod,然后使用“kubectl exec -it [POD_NAME] -- /bin/bash”进入 shell。然后,您可以按照此链接中提到的方法更改值。

另一种选择是使用类似于此链接的自定义配置创建一个ConfigMap ,以增加上传文件的大小。

然后,您需要转到 GKE 工作负载,在“StatefulSet”类型的“wordpress-1-wordpress”工作负载中,您需要修改 YAML 文件,您可以在其中将ConfigMap 数据添加到 Volume中。

另一个解决方法是,您可以重建您在 docker 文件中使用的映像。

于 2019-01-08T19:19:49.357 回答