6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-12 14:17:46 +00:00

Make it possible to (de)activate individual data services

Close #114
This commit is contained in:
Régis Behmo 2019-03-20 18:59:09 +01:00
parent 58ca0beb39
commit f6d6fb642d
9 changed files with 147 additions and 38 deletions

View File

@ -25,21 +25,26 @@ Once the base configuration is created or updated, the environment is automatica
With an up-to-date environment, Tutor is ready to launch an Open edX platform and perform usual operations. Below, we document some of the configuration parameters. With an up-to-date environment, Tutor is ready to launch an Open edX platform and perform usual operations. Below, we document some of the configuration parameters.
Docker
------
.. _docker_images: .. _docker_images:
``DOCKER_IMAGE_*`` Custom Docker images Custom images
--------------------------------------- -------------
- ``DOCKER_IMAGE_OPENEDX`` (default: ``"regis/openedx:hawthorn"``)
- ``DOCKER_IMAGE_ANDROID`` (default: ``"regis/openedx-android:hawthorn"``)
- ``DOCKER_IMAGE_FORUM`` (default: ``"regis/openedx-forum:hawthorn"``)
- ``DOCKER_IMAGE_NOTES`` (default: ``"regis/openedx-notes:hawthorn"``)
- ``DOCKER_IMAGE_XQUEUE`` (default: ``"regis/openedx-xqueue:hawthorn"``)
These configuration parameters define which image to run for each service. These configuration parameters define which image to run for each service.
- ``DOCKER_IMAGE_OPENEDX`` (default: ``regis/openedx:hawthorn``) Custom registry
- ``DOCKER_IMAGE_ANDROID`` (default: ``regis/openedx-android:hawthorn``) ---------------
- ``DOCKER_IMAGE_FORUM`` (default: ``regis/openedx-forum:hawthorn``)
- ``DOCKER_IMAGE_NOTES`` (default: ``regis/openedx-notes:hawthorn``)
- ``DOCKER_IMAGE_XQUEUE`` (default: ``regis/openedx-xqueue:hawthorn``)
``DOCKER_REGISTRY`` Custom Docker registry - ``DOCKER_REGISTRY`` (default: ``""``)
------------------------------------------
You may want to pull/push images from/to a custom docker registry. For instance, for a registry running on ``localhost:5000``, define:: You may want to pull/push images from/to a custom docker registry. For instance, for a registry running on ``localhost:5000``, define::
@ -47,13 +52,58 @@ You may want to pull/push images from/to a custom docker registry. For instance,
(the trailing ``/`` is important) (the trailing ``/`` is important)
``ACTIVATE_*`` Optional features Vendor services
-------------------------------- ---------------
Some optional features may be activated or deactivated during the interactive configuration step. These features change configuration files (during the ``configure`` step) as well as make targets. MySQL
~~~~~
``ACTIVATE_HTTPS`` SSL/TLS certificates for HTTPS access - ``ACTIVATE_MYSQL`` (default: ``true``)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ``MYSQL_HOST`` (default: ``"mysql"``)
- ``MYSQL_PORT`` (default: ``3306``)
- ``MYSQL_DATABASE`` (default: ``"openedx"``)
- ``MYSQL_USERNAME`` (default: ``"openedx"``)
- ``MYSQL_PASSWORD`` (default: randomly generated): root user password. Note that you are responsible for creating the root user if you are using a managed database.
By default, a running Open edX platform deployed with Tutor includes all necessary 3rd-party services, such as MySQL, MongoDb, etc. But it's also possible to store data on a separate database, such as `Amazon RDS <https://aws.amazon.com/rds/>`_. For instance, to store data on an external MySQL database, set the following configuration::
ACTIVATE_MYSQL: false
MYSQL_HOST: yourhost
MYSQL_PASSWORD: <root user password>
Elasticsearch
~~~~~~~~~~~~~
- ``ELASTICSEARCH_HOST`` (default: ``"elasticsearch"``)
- ``ELASTICSEARCH_PORT`` (default: ``9200``)
Memcached
~~~~~~~~~
- ``MEMCACHED_HOST`` (default: ``"memcached"``)
- ``MEMCACHED_PORT`` (default: ``11211``)
Mongodb
~~~~~~~
- ``ACTIVATE_MONGODB`` (default: ``true``)
- ``MONGODB_HOST`` (default: ``"mongodb"``)
- ``MONGODB_DATABASE`` (default: ``"openedx"``)
Rabbitmq
~~~~~~~~
- ``RABBITMQ_HOST`` (default: ``"rabbitmq"``)
Optional features
-----------------
Some optional features may be activated or deactivated during the interactive configuration step (``tutor config save``).
SSL/TLS certificates for HTTPS access
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ``ACTIVATE_HTTPS`` (default: ``false``)
By activating this feature, a free SSL/TLS certificate from the `Let's Encrypt <https://letsencrypt.org/>`_ certificate authority will be created for your platform. With this feature, **your platform will no longer be accessible in HTTP**. Calls to http urls will be redirected to https url. By activating this feature, a free SSL/TLS certificate from the `Let's Encrypt <https://letsencrypt.org/>`_ certificate authority will be created for your platform. With this feature, **your platform will no longer be accessible in HTTP**. Calls to http urls will be redirected to https url.
@ -73,8 +123,10 @@ To renew the certificate, run this command once per month::
tutor local https renew tutor local https renew
``ACTIVATE_NOTES`` Student notes Student notes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
- ``ACTIVATE_NOTES`` (default: ``false``)
With `notes <https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/open-release-hawthorn.master/exercises_tools/notes.html?highlight=notes>`_, students can annotate portions of the courseware. With `notes <https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/open-release-hawthorn.master/exercises_tools/notes.html?highlight=notes>`_, students can annotate portions of the courseware.
@ -83,7 +135,9 @@ With `notes <https://edx.readthedocs.io/projects/open-edx-building-and-running-a
You should beware that the ``notes.<LMS_HOST>`` domain name should be activated and point to your server. For instance, if your LMS is hosted at http://myopenedx.com, the notes service should be found at http://notes.myopenedx.com. You should beware that the ``notes.<LMS_HOST>`` domain name should be activated and point to your server. For instance, if your LMS is hosted at http://myopenedx.com, the notes service should be found at http://notes.myopenedx.com.
``ACTIVATE_XQUEUE`` Xqueue Xqueue
~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
- ``ACTIVATE_XQUEUE`` (default: ``false``)
`Xqueue <https://github.com/edx/xqueue>`_ is for grading problems with external services. If you don't know what it is, you probably don't need it. `Xqueue <https://github.com/edx/xqueue>`_ is for grading problems with external services. If you don't know what it is, you probably don't need it.

View File

@ -85,7 +85,19 @@ def openedx_image_names(config, image):
return [image] return [image]
def vendor_image_names(config, image): def vendor_image_names(config, image):
return VENDOR_IMAGES if image == "all" else [image] if image == "all":
images = VENDOR_IMAGES[:]
if not config['ACTIVATE_ELASTICSEARCH']:
images.remove('elasticsearch')
if not config['ACTIVATE_MEMCACHED']:
images.remove('memcached')
if not config['ACTIVATE_MONGODB']:
images.remove('mongodb')
if not config['ACTIVATE_MYSQL']:
images.remove('mysql')
if not config['ACTIVATE_RABBITMQ']:
images.remove('rabbitmq')
return [image]
images.add_command(build) images.add_command(build)
images.add_command(pull) images.add_command(pull)

View File

@ -21,7 +21,6 @@ def k8s():
def quickstart(root): def quickstart(root):
click.echo(fmt.title("Interactive platform configuration")) click.echo(fmt.title("Interactive platform configuration"))
tutor_config.save.callback(root, False, []) tutor_config.save.callback(root, False, [])
click.echo(fmt.title("Environment generation"))
click.echo(fmt.title("Stopping any existing platform")) click.echo(fmt.title("Stopping any existing platform"))
stop.callback() stop.callback()
click.echo(fmt.title("Starting the platform")) click.echo(fmt.title("Starting the platform"))
@ -32,10 +31,12 @@ def quickstart(root):
@click.command(help="Run all configured Open edX services") @click.command(help="Run all configured Open edX services")
@opts.root @opts.root
def start(root): def start(root):
config = tutor_config.load(root)
kubectl_no_fail("create", "-f", tutor_env.pathjoin(root, "k8s", "namespace.yml")) kubectl_no_fail("create", "-f", tutor_env.pathjoin(root, "k8s", "namespace.yml"))
kubectl("create", "configmap", "nginx-config", "--from-file", tutor_env.pathjoin(root, "apps", "nginx")) kubectl("create", "configmap", "nginx-config", "--from-file", tutor_env.pathjoin(root, "apps", "nginx"))
kubectl("create", "configmap", "mysql-config", "--from-env-file", tutor_env.pathjoin(root, "apps", "mysql", "auth.env")) if config['ACTIVATE_MYSQL']:
kubectl("create", "configmap", "mysql-config", "--from-env-file", tutor_env.pathjoin(root, "apps", "mysql", "auth.env"))
kubectl("create", "configmap", "openedx-settings-lms", "--from-file", tutor_env.pathjoin(root, "apps", "openedx", "settings", "lms")) kubectl("create", "configmap", "openedx-settings-lms", "--from-file", tutor_env.pathjoin(root, "apps", "openedx", "settings", "lms"))
kubectl("create", "configmap", "openedx-settings-cms", "--from-file", tutor_env.pathjoin(root, "apps", "openedx", "settings", "cms")) kubectl("create", "configmap", "openedx-settings-cms", "--from-file", tutor_env.pathjoin(root, "apps", "openedx", "settings", "cms"))
kubectl("create", "configmap", "openedx-config", "--from-file", tutor_env.pathjoin(root, "apps", "openedx", "config")) kubectl("create", "configmap", "openedx-config", "--from-file", tutor_env.pathjoin(root, "apps", "openedx", "config"))

View File

@ -124,6 +124,9 @@ def databases(root):
ops.migrate(root, run_bash) ops.migrate(root, run_bash)
def init_mysql(root): def init_mysql(root):
config = tutor_config.load(root)
if not config['ACTIVATE_MYSQL']:
return
mysql_data_path = tutor_env.data_path(root, "mysql", "mysql") mysql_data_path = tutor_env.data_path(root, "mysql", "mysql")
if os.path.exists(mysql_data_path): if os.path.exists(mysql_data_path):
return return

View File

@ -1,4 +1,9 @@
--- ---
ACTIVATE_ELASTICSEARCH: true
ACTIVATE_MEMCACHED: true
ACTIVATE_MONGODB: true
ACTIVATE_MYSQL: true
ACTIVATE_RABBITMQ: true
ANDROID_RELEASE_STORE_PASSWORD: "android store password" ANDROID_RELEASE_STORE_PASSWORD: "android store password"
ANDROID_RELEASE_KEY_PASSWORD: "android release key password" ANDROID_RELEASE_KEY_PASSWORD: "android release key password"
ANDROID_RELEASE_KEY_ALIAS: "android release key alias" ANDROID_RELEASE_KEY_ALIAS: "android release key alias"

View File

@ -116,6 +116,7 @@ spec:
persistentVolumeClaim: persistentVolumeClaim:
claimName: lms-data claimName: lms-data
{% if ACTIVATE_ELASTICSEARCH %}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@ -150,7 +151,9 @@ spec:
- name: data - name: data
persistentVolumeClaim: persistentVolumeClaim:
claimName: elasticsearch claimName: elasticsearch
{% endif %}
{% if ACTIVATE_MEMCACHED %}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@ -171,7 +174,9 @@ spec:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MEMCACHED }} image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MEMCACHED }}
ports: ports:
- containerPort: 11211 - containerPort: 11211
{% endif %}
{% if ACTIVATE_MONGODB %}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@ -199,7 +204,9 @@ spec:
volumes: volumes:
- name: data - name: data
emptyDir: {} emptyDir: {}
{% endif %}
{% if ACTIVATE_MYSQL %}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@ -233,6 +240,7 @@ spec:
- name: data - name: data
persistentVolumeClaim: persistentVolumeClaim:
claimName: mysql claimName: mysql
{% endif %}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
@ -290,6 +298,7 @@ spec:
persistentVolumeClaim: persistentVolumeClaim:
claimName: lms-data claimName: lms-data
{% if ACTIVATE_RABBITMQ %}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@ -317,4 +326,4 @@ spec:
- name: data - name: data
persistentVolumeClaim: persistentVolumeClaim:
claimName: rabbitmq claimName: rabbitmq
{% endif %}

View File

@ -37,6 +37,7 @@ spec:
selector: selector:
app: lms app: lms
{% if ACTIVATE_ELASTICSEARCH %}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -49,7 +50,9 @@ spec:
protocol: TCP protocol: TCP
selector: selector:
app: elasticsearch app: elasticsearch
{% endif %}
{% if ACTIVATE_MEMCACHED %}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -62,7 +65,9 @@ spec:
protocol: TCP protocol: TCP
selector: selector:
app: memcached app: memcached
{% endif %}
{% if ACTIVATE_MONGODB %}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -75,7 +80,9 @@ spec:
protocol: TCP protocol: TCP
selector: selector:
app: mongodb app: mongodb
{% endif %}
{% if ACTIVATE_MYSQL %}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -88,6 +95,7 @@ spec:
protocol: TCP protocol: TCP
selector: selector:
app: mysql app: mysql
{% endif %}
--- ---
apiVersion: v1 apiVersion: v1
@ -108,6 +116,7 @@ spec:
selector: selector:
app: nginx app: nginx
{% if ACTIVATE_RABBITMQ %}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -120,4 +129,4 @@ spec:
protocol: TCP protocol: TCP
selector: selector:
app: rabbitmq app: rabbitmq
{% endif %}

View File

@ -22,6 +22,7 @@ spec:
requests: requests:
storage: 2Gi storage: 2Gi
{% if ACTIVATE_ELASTICSEARCH %}
--- ---
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
@ -33,7 +34,9 @@ spec:
resources: resources:
requests: requests:
storage: 2Gi storage: 2Gi
{% endif %}
{% if ACTIVATE_MYSQL %}
--- ---
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
@ -45,6 +48,7 @@ spec:
resources: resources:
requests: requests:
storage: 5Gi storage: 5Gi
{% endif %}
--- ---
apiVersion: v1 apiVersion: v1
@ -58,6 +62,7 @@ spec:
requests: requests:
storage: 1Gi storage: 1Gi
{% if ACTIVATE_RABBITMQ %}
--- ---
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
@ -69,3 +74,4 @@ spec:
resources: resources:
requests: requests:
storage: 1Gi storage: 1Gi
{% endif %}

View File

@ -3,10 +3,13 @@ services:
############# External services ############# External services
{% if ACTIVATE_MEMCACHED %}
memcached: memcached:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MEMCACHED }} image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MEMCACHED }}
restart: unless-stopped restart: unless-stopped
{% endif %}
{% if ACTIVATE_MONGODB %}
mongodb: mongodb:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MONGODB }} image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MONGODB }}
# Use WiredTiger in all environments, just like at edx.org # Use WiredTiger in all environments, just like at edx.org
@ -14,7 +17,9 @@ services:
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ../../data/mongodb:/data/db - ../../data/mongodb:/data/db
{% endif %}
{% if ACTIVATE_MYSQL %}
mysql: mysql:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }} image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }}
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
@ -22,7 +27,9 @@ services:
volumes: volumes:
- ../../data/mysql:/var/lib/mysql - ../../data/mysql:/var/lib/mysql
env_file: ../apps/mysql/auth.env env_file: ../apps/mysql/auth.env
{% endif %}
{% if ACTIVATE_ELASTICSEARCH %}
elasticsearch: elasticsearch:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_ELASTICSEARCH }} image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_ELASTICSEARCH }}
environment: environment:
@ -36,6 +43,7 @@ services:
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ../../data/elasticsearch:/usr/share/elasticsearch/data - ../../data/elasticsearch:/usr/share/elasticsearch/data
{% endif %}
openedx-assets: openedx-assets:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_OPENEDX }} image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_OPENEDX }}
@ -60,11 +68,13 @@ services:
- cms - cms
{% if ACTIVATE_NOTES %}- notes{% endif %} {% if ACTIVATE_NOTES %}- notes{% endif %}
{% if ACTIVATE_RABBITMQ %}
rabbitmq: rabbitmq:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_RABBITMQ }} image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_RABBITMQ }}
volumes: volumes:
- ../../data/rabbitmq:/var/lib/rabbitmq - ../../data/rabbitmq:/var/lib/rabbitmq
restart: unless-stopped restart: unless-stopped
{% endif %}
# Simple SMTP server # Simple SMTP server
smtp: smtp:
@ -80,8 +90,8 @@ services:
MONGOHQ_URL: "mongodb://{{ MONGODB_HOST }}/cs_comments_service" MONGOHQ_URL: "mongodb://{{ MONGODB_HOST }}/cs_comments_service"
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
- elasticsearch {% if ACTIVATE_ELASTICSEARCH %}- elasticsearch{% endif %}
- mongodb {% if ACTIVATE_MONGODB %}- mongodb{% endif %}
############# LMS and CMS ############# LMS and CMS
@ -97,12 +107,12 @@ services:
- ../apps/openedx/config/:/openedx/config/ - ../apps/openedx/config/:/openedx/config/
- ../../data/lms:/openedx/data - ../../data/lms:/openedx/data
depends_on: depends_on:
- elasticsearch {% if ACTIVATE_ELASTICSEARCH %}- elasticsearch{% endif %}
- forum - forum
- memcached {% if ACTIVATE_MEMCACHED %}- memcached{% endif %}
- mongodb {% if ACTIVATE_MONGODB %}- mongodb{% endif %}
- mysql {% if ACTIVATE_MYSQL %}- mysql{% endif %}
- rabbitmq {% if ACTIVATE_RABBITMQ %}- rabbitmq{% endif %}
- smtp - smtp
cms: cms:
@ -117,11 +127,11 @@ services:
- ../apps/openedx/config/:/openedx/config/ - ../apps/openedx/config/:/openedx/config/
- ../../data/cms:/openedx/data - ../../data/cms:/openedx/data
depends_on: depends_on:
- elasticsearch {% if ACTIVATE_ELASTICSEARCH %}- elasticsearch{% endif %}
- memcached {% if ACTIVATE_MEMCACHED %}- memcached{% endif %}
- mongodb {% if ACTIVATE_MONGODB %}- mongodb{% endif %}
- mysql {% if ACTIVATE_MYSQL %}- mysql{% endif %}
- rabbitmq {% if ACTIVATE_RABBITMQ %}- rabbitmq{% endif %}
- smtp - smtp
############# LMS and CMS workers ############# LMS and CMS workers
@ -174,7 +184,7 @@ services:
- ../../data/notes:/openedx/data - ../../data/notes:/openedx/data
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
- mysql {% if ACTIVATE_MYSQL %}- mysql{% endif %}
{% endif %} {% endif %}
{% if ACTIVATE_XQUEUE %} {% if ACTIVATE_XQUEUE %}
@ -188,7 +198,7 @@ services:
DJANGO_SETTINGS_MODULE: xqueue.tutor DJANGO_SETTINGS_MODULE: xqueue.tutor
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
- mysql {% if ACTIVATE_MYSQL %}- mysql{% endif %}
xqueue_consumer: xqueue_consumer:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_XQUEUE }} image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_XQUEUE }}
@ -200,5 +210,5 @@ services:
restart: unless-stopped restart: unless-stopped
command: ./manage.py run_consumer command: ./manage.py run_consumer
depends_on: depends_on:
- mysql {% if ACTIVATE_MYSQL %}- mysql{% endif %}
{% endif %} {% endif %}