How to change php values in wordpress running on kubeapps kubernetes

1/19/2020

I've spent a good amount of time to figure out how to increase php configuration values for Wordpress in a Kubernetes environment so I thought somebody else might be interested.

My setup is as follows:

  • Azure AKS (any other Kubernetes cluster would be much the same)
  • Kubeapps by Bitnami for managing helm charts (https://kubeapps.com/)

Problem

For some Wordpress plugins I need to increase the values for post_max_size, max_execution_time, upload_max_filesize and max_input_time.

-- J J
.htaccess
kubernetes
php
wordpress

1 Answer

1/19/2020

Solution

The only proper way to change the php values I found is by using a custom HTAccess file. To achieve that you first of all need to create a configMap. This configMap is separated from the Wordpress app and can be used for multiple instances of Wordpress running on your Kubernetes cluster. The following is an example of a working configMap. You should take care of the namespace you choose. kubeapps is the default namespace, if you have chosen a different one you should apply the same for your configMap otherwise the configMap might not be found.

apiVersion: v1
kind: ConfigMap
metadata:
  name: prod-wordpress-cm
  namespace: kubeapps
data:
  wordpress-htaccess.conf: |
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value max_execution_time 180
    php_value max_input_time 180

When you successfully applied the configMap to your cluster by running kubectl apply -f prod-wordpress-cm.yaml you can reference it in the Kubeapps helm chart values.yaml which holds your instance specific configuration (for details see: https://hub.kubeapps.com/charts/bitnami/wordpress and https://github.com/bitnami/bitnami-docker-wordpress). Ensure that you enter the same configMap name you have chosen above.

## Set Apache allowOverride to None
## ref: https://github.com/bitnami/bitnami-docker-wordpress#environment-variables
##
allowOverrideNone: true

# ConfigMap with custom wordpress-htaccess.conf file (requires allowOverrideNone to true)
customHTAccessCM: prod-wordpress-cm

And you are done. Hope that helps saving some time for others.

-- J J
Source: StackOverflow