From 528089b1bb9d7f6fb4190f0baa3bb054a5baec1d Mon Sep 17 00:00:00 2001 From: Rush Tehrani Date: Tue, 31 Mar 2020 21:49:24 -0700 Subject: [PATCH 1/7] Update to support additional env vars - Added environment variables for: - Redis Host - Postgres Host - Change `POSTGRES_PASSWORD` => `CVAT_POSTGRES_PASSWORD` to avoid collision with other scripts. --- cvat/settings/production.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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', ''), } } From a51dbc9f18b3dd06698af8a8c6f9c34e8a9cc413 Mon Sep 17 00:00:00 2001 From: Aleksandr Melnikov Date: Wed, 1 Apr 2020 11:51:38 -0700 Subject: [PATCH 2/7] Using ENV vars in supervisord.conf --- supervisord.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/supervisord.conf b/supervisord.conf index 706f3ec871df..0c514e115372 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 %(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 %(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 %(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 %(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 %(CVAT_POSTGRES_HOST):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 \ From 1781a1bde4d3c2e818f7a34955c902bf33690bf5 Mon Sep 17 00:00:00 2001 From: Aleksandr Melnikov Date: Wed, 1 Apr 2020 12:36:14 -0700 Subject: [PATCH 3/7] Fixing ENV vars. --- supervisord.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/supervisord.conf b/supervisord.conf index 0c514e115372..9bf68b52bd21 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 %(CVAT_REDIS_HOST)s: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 %(CVAT_REDIS_HOST)s: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 %(CVAT_REDIS_HOST)s: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 %(CVAT_REDIS_HOST)s: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 From d8857e94bd4420789427b2ebe8fd2d9722798566 Mon Sep 17 00:00:00 2001 From: rushtehrani Date: Tue, 12 May 2020 09:55:44 -0700 Subject: [PATCH 4/7] add env vars to docker-compose.yml --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 3bb1eb701515..7135cd7e07ee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,6 +53,8 @@ services: environment: DJANGO_MODWSGI_EXTRA_ARGS: "" ALLOWED_HOSTS: '*' + CVAT_REDIS_HOST: "localhost" + CVAT_POSTGRES_HOST: "localhost" volumes: - cvat_data:/home/django/data - cvat_keys:/home/django/keys From 867db652d05083c221ffd242b943c8311d2a5cdc Mon Sep 17 00:00:00 2001 From: rushtehrani Date: Tue, 12 May 2020 10:03:23 -0700 Subject: [PATCH 5/7] merge supervisord.conf --- supervisord.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervisord.conf b/supervisord.conf index 9bf68b52bd21..dde373cf157a 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -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 %(CVAT_POSTGRES_HOST):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 \ From b83d4d10172c490ad67ce5e9fc39ab2c61e73c13 Mon Sep 17 00:00:00 2001 From: rushtehrani Date: Tue, 12 May 2020 13:27:00 -0700 Subject: [PATCH 6/7] update docker-compose env var values --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7135cd7e07ee..d615ef5e8590 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,8 +53,8 @@ services: environment: DJANGO_MODWSGI_EXTRA_ARGS: "" ALLOWED_HOSTS: '*' - CVAT_REDIS_HOST: "localhost" - CVAT_POSTGRES_HOST: "localhost" + CVAT_REDIS_HOST: "cvat_redis" + CVAT_POSTGRES_HOST: "cvat_db" volumes: - cvat_data:/home/django/data - cvat_keys:/home/django/keys From 52e6a30fe322420a8340eaef4d2540e34f6a7605 Mon Sep 17 00:00:00 2001 From: Rush Tehrani Date: Wed, 3 Jun 2020 14:09:04 -0700 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 858ec855c722..e195357b5033 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.1.0-alpha] - Unreleased ### Added - Throttling policy for unauthenticated users () +- Add environment variables for Redis and Postgres hosts for Kubernetes deployment support () ### Changed - Removed information about e-mail from the basic user information ()