As promised, a write-up of my experience...
There are a few significant differences between running LimeSurvey on a regular server versus running it on Openshift.
This write-up assumes you know the basic concepts of Openshift such as S2I, Persistent Volumes, ConfigMaps, Build and Deploy configurations, etc. If you don't, please read up on that first.
In this post I'm going to share some of my experiences as well as the roadblocks I faced and how we eventually solved them.
Before I begin, a bit of background on what components we use:
- LimeSurvey php code is stored in a git repository
- For the front end we use the latest Red Hat Software Collection Library (RHSCL) PHP 7.0 S2I image (for detatils see:
github.com/sclorg/s2i-php-container
)
- For the database we use the latest RHSCL MariaDB 10 image (for details see:
github.com/sclorg/mariadb-container
)
- Persistent Volumes for the "upload" directory and the database
- Liveness and readiness probes on both the webserver and the database
There were also a few additional requirements / restrictions applicable to Openshift in our company we had to think about:
- we have no access to any command line (either via the web console or via oc rsh) in UAT and PROD
- an applicaiton deployed on Openshift must come up in UAT and PROD without human intervention aside from pushing the 'promote' button which pushes it from INT to UAT and from UAT to PROD.
- in case of major disaster (eg full loss of the entire Openshift estate) one must be able to recover through the same initial deployment process and, where necessary, the restoration of the data in the persistent volumes from backup - no other manual intervention is allowed
So, this is how we achieved that:
1° created a number of secrets (for database usernames and passwords) which are then converted into environment variables in the respective pods
2° created a number of configmaps to contain the variables like database name, port, etc - these are then converted to environment variables as well
3° "config.php" is part of our git and refers to the environment variables created in 1° and 2° (see file in attached zip)
4° create a persistent volume for the "upload" directory and mount it in the pod instead of the real upload directory
5° added a command to the "run" script (see 7°) to populate the persistent volume created in 4° with the standard content of the upload directory (because, different from Docker, when you link storage in Openshift the original content of that directory is discarded so when the container starts the first time you need to pull it again from somewhere else - see 6° and 7°)
6° to achieve 5°, our git contains an additional directory "uploadsource" which is an exact copy of the original "upload" directory
7° the git repository contains a directory ".s2i" with a directory "bin" which contains the "run" script (see file in attached zip) - this then replaces the standard run script which is included in the S2I image. Line 57 contains the command mentioned in 5° (note: do not use this file! It contains other changes we needed to adapt a number of settings in the php.ini - If you need the command copy that line over to your "run" file - if you don't have the original you can pull it from the github mentioned earlier)
8° added "'updatable' => false," in the config.php file - this prevents that message "there's a new version of LimeSurvey" - because an update can't be done on the fly on Openshift we wanted this message to be removed permanently
9° Now, before you can bring up your application pods, you need to create the database. For this, we ran the standard install process on a development box (not openshift) and then exported the required mysql statements needed to populate the database. We then connected to the respective database route and executed that mysql, creating a blank LimeSurvey database. Only then would we bring up the PHP pods.
Our complete deploy config contains more things such as certificates for LDAP, custom HTTPD, php.ini and LDAP configs though I have removed these details to not confuse things too much.
I think that's about it... I'm attaching a zip file with the deploy config, the S2I run file and the config.php.
I hope this is helpful - any questions, let me know... (I'll try to respond asap)
B.