Skip to content

Project deploy on OpenShift

Oleg Ovcharenko edited this page Feb 22, 2022 · 1 revision

RD2L Ladder deploy on OpenShift


  1. Create project on openshift:
oc new-project rd2l
  1. Create ladder app from github source:
oc new-app https://github.com/UncleVasya/Dota2-EU-Ladder --name=ladder
  1. If you get Error 137 during build, you need to increase memory limit in buildconfig.

    Edit YAML for buildconfig (and deployconfig if first doesn't help):

    spec:
        resources:
    	limits:
    	    memory: "1Gi"
    

    or use console version:

    • buildconfig:
    oc.exe  patch bc/ladder --patch "{\"spec\":{\"resources\":{\"limits\":{\"memory\":\"1Gi\"}}}}"
    
    • deployconfig:
    oc.exe  patch dc/ladder --patch "{\"spec\":{\"resources\":{\"limits\":{\"memory\":\"1Gi\"}}}}"
    
  2. Add persistent storage for database:

oc set volume dc/ladder --add --name=data --claim-name=ladder-data --type pvc --claim-size=1Gi --mount-path /opt/app-root/src/data
  1. Expose app for web requests:
oc expose svc/ladder

Or create Route in web console manually.

At this point you should be able to visit ladder web interface.

  1. Create superuser. Open running pod in a terminal and run:
python manage.py createsuperuser
  1. Add environment vars to DeployConfig:
BOT_LOGIN=euladder_bot
BOT_PASSWORD=****
LOBBY_PASSWORD=****
LEAGUE_ID=****
DISCORD_BOT_TOKEN=****
BASE_URL=https://inhouse.rd2l.eu

Hints for local development on Windows:

  1. In .virtualenv\Scripts\activate.bat set env variables:
set "BOT_LOGIN=euladder_bot"
set "BOT_PASSWORD=****"
set "LOBBY_PASSWORD=****"
set "LEAGUE_ID=****"
set "DISCORD_BOT_TOKEN=****"
  1. If wokring from PyCharm, its terminal won't have these variables set by default. You need to deactivate / activate virtualenv manually:
.virtualenv\Scripts\deactivate.bat
.virtualenv\Scripts\activate.bat

Working with tmux


Create a session for website:

tmux new -s website

Inside tmux:

1) gunicorn -b 0.0.0.0:8000 dota2_eu_ladder.wsgi:application
2) press Ctrl+B to enter commands mode
3) press 'd' to detach from session

Create a session for dota bot:

tmux new -s dota_bot

Inside tmux:

1) python manage.py dota_bot -n 3
2) press Ctrl+B to enter commands mode
3) press 'd' to detach from session

Then do the same for discord bot:

tmux new -s discord_bot

To connect to exisiting session

tmux a -t dota_bot

Database backup

oc rsync ladder-63-9c5m5:/opt/app-root/src/data ./_backups

Clone this wiki locally