Moving moodle.org to kubernetes

Re: Moving moodle.org to kubernetes

by Eduard Cercós -
Number of replies: 5
Picture of Moodle HQ
Hi Sachin,
You can create a docker image easily following any Docker file, or docker-compose, etc. If you never create one before I'd recommend to take a look to official Docker documentation here (https://docs.docker.com/get-started/). Here it is one Dockerfile similar to the ones we use to create a moodle site:
FROM ubuntu/nginx:latest
COPY /build/setup.sh /tmp/setup.sh
COPY /build/scripts /opt/scripts/
COPY /build/deploy_key.pri /root/.ssh/id_rsa
COPY /build/cron.json /opt/crons/cron.json
COPY /build/default.conf /etc/nginx/includes/default.conf
RUN bash /tmp/setup.sh
VOLUME ["/opt/app"]
VOLUME ["/opt/data"]
VOLUME ["/opt/logs"]
EXPOSE 80
CMD ["/bin/bash", "/opt/scripts/run.sh"]

Two key steps:
- setup.sh script contains anything you need to add to the base image (eg, packages, moodle code, config files, etc)
- run.sh script contains the entry point of the container. It wakes up the web server daemon, etc

Other recommendations:
- Make sure you have mounted the /opt/data filesystem in a shared volume
- Make sure the code directory (/opt/app here) is in a local volume. We usually add the code to the image so it is loaded in a local docker volume.
In reply to Eduard Cercós

Re: Moving moodle.org to kubernetes

by Karim Ayari -
Hello Eduard,

I'm currently working on a custom bitnami moodle image. why bitnami? because they have all the scripts needed for deployment and I don't really want to reinvent the wheel smile and they have a helm chart that I slightly modifiedand deploy with argocd.
However, I have questions regarding your kubernetes deployment:

How do you handle the upgrade? I would like to be able to do it by updating the image and not manually inside the container and especially how do you manage the reinstallation of the plugins?

thank you for your reply smile
Karim
In reply to Karim Ayari

Re: Moving moodle.org to kubernetes

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

It is time somebody carefully analyze the Bitnami Docker image for Moodle. It pops up sporadically in the forums and do not get useful answers, because it is so much different from the native installation of Moodle on LAMP and as a result the advice the regulars here do not apply.

In a recent workshop the Moodle Bitnami Docker and the plain vanilla LAMP installation on VPS came up site-by-side. Yes, the Docker image was installed and running in minutes. But as the workshop progressed, as people started upgrading, installing plug-ins, taking backups, etc., on the Bitname-Docker front there were always discussions about Docker and Bitnami whereas on the VPS front, there was nothing to discuss. Halfway though we swapped the Bitnami with a hand-made Docker image starting from Ubuntu Linux Server, but it came too late to undergo the same scrutiny.

At another occasion I came across a sophisticated clustered Docker/Kubernetes/Galera/.. environment for Moodle deployment. The sysops have gone in to great lengths on _deployment_, which means for them spawn a Moodle instance and forget it. They are obsessed with it. What they forgot was Moodle is a tiger by the tail. It can not be forgotten, it makes the users to make the noise. In plain text, they haven't looked in to the simplest thing about _running_ Moodle, like upgrading, "downgrading" ;(, the moodledata, like additional plug-ins, like backups, restore,... BTW, I don't even know whether the Docker images they took were Bitnami or something else, that was highly secret.

What we need is full documentation, the counterpart of, say https://docs.moodle.org/en/Installing_Moodle_on_Debian_based_distributions. I know, the Docker philosophy is one click and it runs. You don't have to look in to it. But if one doesn't have a clue, What and Where, he'll fall flat at the first user problem.

P.S. @Moderator: I propose to move this whole discussion to Installing and Upgrading help forum. This has nothing to do with performance. (I know, there are claims that this system is efficient and scalable. But this thread has no evidence, no load tests nor numbers supporting it. It is still about (easily) _installing_ Moodle.)
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: Moving moodle.org to kubernetes

by Karim Ayari -
I agree with you, you shouldn't do kubernetes because it's fashionable. I try to imagine a scenario in order to be able to offer a flexible and robust hosting service. I am in a test phase while remaining pragmatic 😉
In reply to Visvanath Ratnaweera

Re: Moving moodle.org to kubernetes

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I use Docker with Moodle for my development and testing work (not in production). I have a bunch of Docker Compose scripts and, yes, it makes Moodle a "one click" installation. But it's *my* one-click installation.

That's the problem - everybody who creates Docker (or Bitnami or whatever) installations for Moodle is building it for their own requirements - or at least some specific requirement - and therein lies the problem. So if you use my Docker install (help yourself) and it all goes wrong then you need to ask me, not these forums. And don't bother, because I'm too lazy to answer big grin

(there's a branch for Moodle 4.0/PHP 8)
Average of ratings: Useful (3)
In reply to Karim Ayari

Re: Moving moodle.org to kubernetes

by Eduard Cercós -
Picture of Moodle HQ
Hi Karim,

I wouldn't say using your own docker image is reinventing the wheel as using a customized SO installation isn't, is it? I found really useful adapt your containers to your needs and simplify the overall maintenance and upgrading process.

As we add the code to the image, we have a pipeline process that once the code is upgraded (including the desired plugins) the docker image is rebuilt. Once deployed, we launch the upgrade process (either manually or automatically) to finish the changes in the database.