bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
9.03k stars 9.22k forks source link

Unable to add extra WordPress config in wp-config.php file #16084

Closed ayush-sachdev closed 1 year ago

ayush-sachdev commented 1 year ago

Name and Version

bitnami/wordpress:latest

What architecture are you using?

amd64

What steps will reproduce the bug?

Set up Kubernetes pods using bitnami/wordpress:latest docker image and add WORDPRESS_EXTRA_WP_CONFIG_CONTENT in the deployment manifest file.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: wordpress
spec:
  replicas: 1
  selector:
    matchLabels:
      app: wordpress
  template:
    metadata:
      labels:
        app: wordpress
    spec:
      securityContext:
        fsGroup: 1001
      containers:
        - name: wordpress
          image: bitnami/wordpress:latest
          securityContext:
            runAsUser: 1001
            allowPrivilegeEscalation: false
          ports:
          - containerPort: 8080
            name: wordpress
          env:
            - name: WORDPRESS_EXTRA_WP_CONFIG_CONTENT
              value: "define( 'WP_AUTO_UPDATE_CORE', false ); \
                      define( 'WP_CACHE', true); \
                      define( 'WPCACHEHOME', '/bitnami/wordpress/wp-content/plugins/wp-super-cache/'); \ "
            - name: WORDPRESS_DATABASE_HOST
              value: <DB Host>
            - name: WORDPRESS_DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: wp-db-secrets
                  key: MYSQL_ROOT_PASSWORD
            - name: WORDPRESS_DATABASE_USER
              value: <DB User>
            - name: WORDPRESS_DATABASE_NAME
              value: <DB Name>
          resources:
            requests:
              memory: "500Mi"
              cpu: "200m"
            limits:
              memory: "500Mi"
              cpu: "200m"
          volumeMounts:
            - name: wordpress-pvc
              mountPath: "/bitnami/wordpress"
      volumes:
        - name: wordpress-pvc
          persistentVolumeClaim:
            claimName: wordpress-pvc-claim

Are you using any custom parameters or values?

I am adding Extra config environment in deployment manifest file.

env:
            - name: WORDPRESS_EXTRA_WP_CONFIG_CONTENT
              value: "define( 'WP_AUTO_UPDATE_CORE', false ); \
                      define( 'WP_CACHE', true); \
                      define( 'WPCACHEHOME', '/bitnami/wordpress/wp-content/plugins/wp-super-cache/'); \ "

What is the expected behavior?

We should be able to see the added extra WordPress config values in wp-config.php file.

What do you see instead?

I am using WordPress docker image to build my Kubernetes application. But when I am adding value to the env variable WORDPRESS_EXTRA_WP_CONFIG_CONTENT they are not appending in the wp-config.php. I can see the values inside the pod but not in the wp-config.php file. image

dgomezleon commented 1 year ago

Hello @ayush-sachdev ,

I was not able to reproduce the error by applying the following change in the chart:

diff --git a/bitnami/wordpress/values.yaml b/bitnami/wordpress/values.yaml
index ab5b2979f..faa2c0b6f 100644
--- a/bitnami/wordpress/values.yaml
+++ b/bitnami/wordpress/values.yaml
@@ -230,7 +230,11 @@ args: []
 ##   - name: FOO
 ##     value: "bar"
 ##
-extraEnvVars: []
+extraEnvVars:
+  - name: WORDPRESS_EXTRA_WP_CONFIG_CONTENT
+    value: "define( 'WP_AUTO_UPDATE_CORE', false ); \
+                      define( 'WP_CACHE', true); \
+                      define( 'WPCACHEHOME', '/bitnami/wordpress/wp-content/plugins/wp-super-cache/'); \ "
 ## @param extraEnvVarsCM Name of existing ConfigMap containing extra env vars
 ##
 extraEnvVarsCM: ""

With this. result:

$ kubectl exec wp-wordpress-58677795f8-tp96b -- cat /opt/bitnami/wordpress/wp-config.php | grep CACHE

define( 'WP_AUTO_UPDATE_CORE', false ); define( 'WP_CACHE', true); define( 'WPCACHEHOME', '/bitnami/wordpress/wp-content/plugins/wp-super-cache/');

Could you please double-check it by removing the existing PVC?

github-actions[bot] commented 1 year ago

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] commented 1 year ago

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.