[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Deploy wordpress with persistent volume



Not sure which wordpress image/example you're using since there are two in there, but if you started from this one: https://github.com/openshift/origin/blob/master/examples/wordpress/template/wordpress-mysql.json, then the wordpress source lives in /opt/app-root/src within the image and since you're mounting a PV to that path, you're replacing the /opt/app-root/src image content with the contents of your PV.

Fundamentally that wordpress image isn't designed to have /opt/app-root/src be a volume.

If you want the source code to be on a PV so you can safely edit it and have your changes persisted, you need an image that's going to, on startup, copy its source from a location within the image, to a location that you're mounting the PV at, and then run the source from that PV directory.

But in general that would not be a recommended pattern.  Your goal should be to have an image that is immutable w/ respect to application logic.



On Fri, Jul 8, 2016 at 11:29 AM, Robson Ramos Barreto <robson rbarreto gmail com> wrote:
Hello Guys,

I'm trying to deploy wordpress with persistent volume on openshift enterprise 3.2 (30 Day Self-Supported) as in the example [1] but the git files aren't being wirtten in the NFS path. MySQL is being deployed properly in the NFS persistent volume

# ls -ld /exports/wordpress/mysql/
drwxrwxrwx. 5 nfsnobody nfsnobody 4096 Jul  8 10:35 /exports/wordpress/mysql/

# ls -lr /exports/wordpress/mysql/
total 88084
drwx------. 2 27 27       19 Jul  8 09:48 wordpress
drwx------. 2 27 27     4096 Jul  8 09:48 performance_schema
-rw-rw----. 1 27 27        2 Jul  8 10:35 mysql-1-ijptl.pid
-rw-rw----. 1 27 27        2 Jul  8 09:48 mysql-1-1soui.pid
drwx------. 2 27 27     4096 Jul  8 09:48 mysql
-rw-rw----. 1 27 27 38797312 Jul  8 09:48 ib_logfile1
-rw-rw----. 1 27 27 38797312 Jul  8 10:35 ib_logfile0
-rw-rw----. 1 27 27 12582912 Jul  8 10:35 ibdata1
-rw-rw----. 1 27 27       56 Jul  8 09:48 auto.cnf

# ls -ld /exports/wordpress/wp/
drwxrwxrwx. 2 nfsnobody nfsnobody 26 Jul  7 18:43 /exports/wordpress/wp/

# ls -lr /exports/wordpress/wp/
total 0

$ oc get pods
NAME                              READY     STATUS      RESTARTS   AGE
mysql-1-ijptl                     1/1       Running     0          44m
wordpress-mysql-example-1-1clom   1/1       Running     0          41m
wordpress-mysql-example-1-build   0/1       Completed   0          44m

$ oc rsh wordpress-mysql-example-1-1clom
sh-4.2$ pwd
/opt/app-root/src
sh-4.2$ df -h /opt/app-root/src
Filesystem                         Size  Used Avail Use% Mounted on
192.168.0.9:/exports/wordpress/wp   50G   11G   40G  22% /opt/app-root/src
sh-4.2$ ls
sh-4.2$ echo "Create file from pod" > teste.txt

# ls -lr /exports/wordpress/wp/
total 4
-rw-r--r--. 1 1001 nfsnobody 21 Jul  8 11:21 teste.txt

# cat /exports/wordpress/wp/teste.txt
Create file from pod

$ oc get pvc
NAME          STATUS    VOLUME      CAPACITY   ACCESSMODES   AGE
claim-mysql   Bound     nfs-pv007   5Gi        RWO           19h
claim-wp      Bound     nfs-pv008   2Gi        RWO,RWX       19h

$ oc volumes dc --all
deploymentconfigs/mysql
  pvc/claim-mysql (allocated 5GiB) as mysql-data
    mounted at /var/lib/mysql/data
deploymentconfigs/wordpress-mysql-example
  pvc/claim-wp (allocated 2GiB) as wordpress-mysql-example-data
    mounted at /opt/app-root/src

Template

172           spec: {¬                                                             
173             volumes: [¬                                                        
174               {¬                                                               
175                 name: ${APP_NAME}-data,¬                                       
176                 persistentVolumeClaim: {¬                                      
177                   claimName: ${CLAIM_WP_NAME}¬                                 
178                 }¬                                                             
179               }¬                                                               
180             ],¬                                                                
181             containers: [¬                                                     
182               {¬                                                               
183                 name: ${APP_NAME},¬                                            
184                 image: ${APP_NAME},¬                                           
185                 ports: [¬                                                      
186                   {¬                                                           
187                     containerPort: 8080,¬                                      
188                     name: wp-server¬                                           
189                   }¬                                                           
190                 ],¬                                                            
191                 volumeMounts: [¬                                               
192                   {¬                                                           
193                     name: ${APP_NAME}-data,¬                                   
194                     mountPath: ${WP_PATH}¬                                     
195                   }¬                                                           
196                 ],¬                            


Any help will very appreciate

Thank you
Robson

_______________________________________________
users mailing list
users lists openshift redhat com
http://lists.openshift.redhat.com/openshiftmm/listinfo/users




--
Ben Parees | OpenShift


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]