This is the code for the Kubernetes WordPress Operator used at EPFL.
We (ISAS-FSD) are managing roughly 1,000 WordPress sites, all consolidated under one domain, https://www.epfl.ch.
While we would be happy for you to give it a try, this is not an Operator that
you can use "off-the-shelf" within your cluster. First, it needs a fine-tuned
WordPress image that contains all the plugins your users are allowed to use.
Then, you have to understand that the secrets needed by "wp-config.php" are
managed within the Nginx configuration to be passed to PHP-FPM as FastCGI
parameters (fastcgi_param
directive). A homemade entrypoint takes care of the
loading of the WordPress framework without a proper wp-config.php
, so what
we can serve 1 to many WordPress sites using the very same image. Last but not
least, you will need to dive into some PHP scripts that manage the installation
/ configuration of the site, themes and plugins through options in the site's
database.
This operator is built with Kopf (Kubernetes Operators Framework) and rely on the MariaDB Operator.
A make up
command in our development environment (wp-dev) should clone
everything needed to get started, including this repo and wp-ops, which
contains Ansible configuration as code. The operator is meant to deploy the
WordPressSite Custom Resource Definition by itself.
To make it work on your device, follow these steps:
- Make sure you have Python3 installed
- Install all the dependencies using
pip install -r requirements.txt
- If outside the EPFL network, check additional steps
- Run the operator using
make operator
Whenever outside the EPFL network, you will need to:
- Install KubeVPN
- Connect the VPN to your cluster using
kubevpn connect
- If you are on Linux → make sure to run these commands:
resolvectl dns utun0 $(kubectl get -n kube-system \ service/rke2-coredns-rke2-coredns \ -o jsonpath='{$.spec.clusterIP}') NAMESPACE=wordpress-test resolvectl domain utun0 $NAMESPACE.svc.cluster.local \ svc.cluster.local cluster.local
- Quickly check that your VPN is connected using
kubevpn status
This repository contains the Dockerfile and an example (operator.yaml) to deploy it in a cluster.
Just run make
for help. Otherwise, use:
make image
to build a new (latest) imagemake delete
(when needed) to remove previously installed operatormake deploy
to apply the new operator
When in a development process, use WP_OPERATOR_IMAGE_TAG=2024-000 make delete image deploy
to have a rapid cycle.
Please note that our deployment is done by Ansible, so dive into wp-ops to find the latest version.
If you want to contribute to this repository, please read the CONTRIBUTING.md file.