diff --git a/CHANGELOG.md b/CHANGELOG.md index ba1990279785..c3410b3544ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Throttling policy for unauthenticated users () - Added default label color table for mask export (https://github.com/opencv/cvat/pull/1549) +- Added environment variables for Redis and Postgres hosts for Kubernetes deployment support () - Added visual identification for unavailable formats (https://github.com/opencv/cvat/pull/1567) ### Changed diff --git a/cvat/settings/production.py b/cvat/settings/production.py index 4f9195187ce3..9b591f7ad365 100644 --- a/cvat/settings/production.py +++ b/cvat/settings/production.py @@ -11,9 +11,9 @@ ] for key in RQ_QUEUES: - RQ_QUEUES[key]['HOST'] = 'cvat_redis' + RQ_QUEUES[key]['HOST'] = os.getenv('CVAT_REDIS_HOST', 'cvat_redis') -CACHEOPS_REDIS['host'] = 'cvat_redis' +CACHEOPS_REDIS['host'] = os.getenv('CVAT_REDIS_HOST', 'cvat_redis') # Django-sendfile: # https://github.com/johnsensible/django-sendfile @@ -25,9 +25,9 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', - 'HOST': 'cvat_db', + 'HOST': os.getenv('CVAT_POSTGRES_HOST', 'cvat_db'), 'NAME': 'cvat', 'USER': 'root', - 'PASSWORD': os.getenv('POSTGRES_PASSWORD', ''), + 'PASSWORD': os.getenv('CVAT_POSTGRES_PASSWORD', ''), } } diff --git a/docker-compose.yml b/docker-compose.yml index 9cc31629564a..38e478f224a7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,6 +53,8 @@ services: environment: DJANGO_MODWSGI_EXTRA_ARGS: "" ALLOWED_HOSTS: '*' + CVAT_REDIS_HOST: "cvat_redis" + CVAT_POSTGRES_HOST: "cvat_db" volumes: - cvat_data:/home/django/data - cvat_keys:/home/django/keys diff --git a/supervisord.conf b/supervisord.conf index 706f3ec871df..dde373cf157a 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -23,26 +23,26 @@ priority=1 autorestart=true [program:rqworker_default] -command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \ +command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \ "exec /usr/bin/python3 %(ENV_HOME)s/manage.py rqworker -v 3 default" environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock" numprocs=2 process_name=rqworker_default_%(process_num)s [program:rqworker_low] -command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \ +command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \ "exec /usr/bin/python3 %(ENV_HOME)s/manage.py rqworker -v 3 low" environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock" numprocs=1 [program:git_status_updater] -command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \ +command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \ "/usr/bin/python3 ~/manage.py update_git_states" environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock" numprocs=1 [program:rqscheduler] -command=%(ENV_HOME)s/wait-for-it.sh redis:6379 -t 0 -- bash -ic \ +command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_REDIS_HOST)s:6379 -t 0 -- bash -ic \ "/usr/bin/python3 /usr/local/bin/rqscheduler --host redis -i 30" environment=SSH_AUTH_SOCK="/tmp/ssh-agent.sock" numprocs=1 @@ -53,7 +53,7 @@ numprocs=1 ; apps are dynamically loaded by an environment variable. It can lead to issues ; with docker cache. Thus it is necessary to run collectstatic here for such ; apps. -command=%(ENV_HOME)s/wait-for-it.sh db:5432 -t 0 -- bash -ic \ +command=%(ENV_HOME)s/wait-for-it.sh %(ENV_CVAT_POSTGRES_HOST)s:5432 -t 0 -- bash -ic \ "rm -f /tmp/cvat-server/httpd.pid && /usr/bin/python3 ~/manage.py migrate && \ /usr/bin/python3 ~/manage.py collectstatic --no-input && \ exec /usr/bin/python3 $HOME/manage.py runmodwsgi --log-to-terminal --port 8080 \