Run background runner as Kubernetes deployment
The runner uses a separate container, based on a Python 3.5 image (which
is already available on the Toolforge docker registry, but not yet as a
webservice backend), with the source code and the database credentials
bind-mounted into it read-only. It uses its own virtual environment that
is set up each time the container is started, to avoid conflicts with
the webservice venv which still has to support Python 3.4.
The deployment.yaml file is based on Stashbot’s [1], with some commands
mentioned in the README based on its stashbot.sh script [2]. The
commands to set up the runner’s virtual environment are based on the
webservice-python-bootstrap script [3] and encoded into the YAML file
using a trick from a StackOverflow answer [4].
[1]: https://phabricator.wikimedia.org/diffusion/LTST/browse/master/etc/deployment.yaml
[2]: https://phabricator.wikimedia.org/diffusion/LTST/browse/master/bin/stashbot.sh
[3]: https://phabricator.wikimedia.org/diffusion/ODIT/browse/master/python35/web/webservice-python-bootstrap
[4]: https://stackoverflow.com/a/49801587/1420237