Score:0

Running PHP application with plugin-support

cn flag

I've a PHP application that is running fine in Kubernetes, except one scenario. The "problem" is that the application can be extended using plugin. In this case, we're simply adding the plugin to the container, rebuild the container and deploy it again. Next time the Administrator logs in, he needs to confirm the installation of the plugin. So far so good. But! Our problem is that we cannot uninstall these plugins anymore because the plugins are creating (plugin-specific) tables and entries in different tables within the database.

During the uninstall-process, the plugin removes the tables and so on. But since our application is located in the pods, the files in the file system remains active. So after reloading the page, the application finds the new plugin and will install it again.

Basically, after removing one plugin, we need to rebuild the container without the plugin and deploy it again. Then we can remove the next plugin, rebuild the container and so on... but that's no solution.

So we think there must be another way. The best solution would be to have it installed in a volume, because in this case all pods are using the same volume and we can share them between php-fpm pod and webserver pods. So we can scale them independently from each other. But in this case the question is, if there's anything like a "setup"-container which runs on each deployment. So whenever we upgrade our deployment the container runs once and is uninstalling old plugins / installing new plugins / installing upgrades of our application. In this scenario, our pods need just ReadOnlyMany (ROX) and only one pod (the setup-pod) need write permissions.

I know there're init-containers but as far as I know they're run each time a new pod is started. Is anyone having any suggestion how to solve this issue or faced similar issues?

Klamber avatar
ru flag
Since the PHP app wouldn't have write to this volume you need to delegate it to a pod that has write access. I'd use some kind of background jobs processor running in a privileged pod/job. App detects plugin upgrade/delete -> puts the action into a job queue and polls for status changes or error messages. A worker pod checks the job queue and executes necessary actions, updates status or sets a return message on error. There are ofc many ways you can implement background jobs, but I don't know whats your app framework.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.