|
1 | 1 | # OpenShift
|
2 | 2 |
|
3 |
| -Coming soon |
| 3 | +## Pre-Requirements |
| 4 | + |
| 5 | +- [Global deployment pre-requirements](index.md#pre-requirements) |
| 6 | +- [OpenShift CLI](https://docs.openshift.com/container-platform/4.3/cli_reference/openshift_cli/getting-started-cli.html#cli-installing-cli_cli-developer-commands) version 3.11+ |
| 7 | + |
| 8 | + |
| 9 | +## Deploying InvenioRDM |
| 10 | + |
| 11 | +First of all login and select the right project in your OpenShift cluster: |
| 12 | + |
| 13 | +```console |
| 14 | +$ oc login <your.openshift.cluster> |
| 15 | +$ oc project invenio |
| 16 | +``` |
| 17 | + |
| 18 | +### Secrets |
| 19 | + |
| 20 | +Before deploying in need to provide the credentials so the application can access the different services: |
| 21 | + |
| 22 | +**Database secrets:** |
| 23 | + |
| 24 | +```console |
| 25 | +$ POSTGRESQL_PASSWORD=$(openssl rand -hex 8) |
| 26 | +$ POSTGRESQL_USER=invenio |
| 27 | +$ POSTGRESQL_HOST=db |
| 28 | +$ POSTGRESQL_PORT=5432 |
| 29 | +$ POSTGRESQL_DATABASE=invenio |
| 30 | +$ oc create secret generic \ |
| 31 | + --from-literal="POSTGRESQL_PASSWORD=$POSTGRESQL_PASSWORD" \ |
| 32 | + --from-literal="SQLALCHEMY_DB_URI=postgresql+psycopg2://$POSTGRESQL_USER:$POSTGRESQL_PASSWORD@$POSTGRESQL_HOST:$POSTGRESQL_PORT/$POSTGRESQL_DATABASE" \ |
| 33 | + db-secrets |
| 34 | +secret "db-secrets" created |
| 35 | +``` |
| 36 | + |
| 37 | +**RabbitMQ secrets:** |
| 38 | + |
| 39 | +```console |
| 40 | +$ RABBITMQ_DEFAULT_PASS=$(openssl rand -hex 8) |
| 41 | +$ oc create secret generic \ |
| 42 | + --from-literal="RABBITMQ_DEFAULT_PASS=$RABBITMQ_DEFAULT_PASS" \ |
| 43 | + --from-literal="CELERY_BROKER_URL=amqp://guest:$RABBITMQ_DEFAULT_PASS@mq:5672/" \ |
| 44 | + mq-secrets |
| 45 | +secret "mq-secrets" created |
| 46 | +``` |
| 47 | + |
| 48 | +**Elasticsearch secrets:** |
| 49 | + |
| 50 | +!!! info "Elasticaserch variables" |
| 51 | + Currently, and until [invenio-search#198](https://github.com/inveniosoftware/invenio-search/issues/198) has been addressed, the Elasticsearch configuration |
| 52 | + has to be loaded in a single environment variable. |
| 53 | + |
| 54 | +``` console |
| 55 | +$ export INVENIO_SEARCH_ELASTIC_HOSTS="[{'host': 'localhost', 'timeout': 30, 'port': 9200, 'use_ssl': True, 'http_auth':('USERNAME_CHANGEME', 'PASSWORD_CHANGEME')}]" |
| 56 | +$ oc create secret generic \ |
| 57 | + --from-literal="INVENIO_SEARCH_ELASTIC_HOSTS=$INVENIO_SEARCH_ELASTIC_HOSTS" \ |
| 58 | + elasticsearch-secrets |
| 59 | +``` |
| 60 | + |
| 61 | +!!! info "Extra configuration is possible" |
| 62 | + Note that you might need to add extra configuration to the elasticsearch hosts, sucha as vertificate verification (`verify_certs`), prefixing (`url_prefix`) and more. |
| 63 | + |
| 64 | +### Install InvenioRDM |
| 65 | + |
| 66 | +Before installing you need to configure two things, the rest are optional and you can read more about it [here](configuration.md): |
| 67 | + |
| 68 | +- Your host in a `values.yaml` file. |
| 69 | +- The web/worker docker images. |
| 70 | + |
| 71 | +``` yaml |
| 72 | +host: yourhost.localhost |
| 73 | + |
| 74 | +web: |
| 75 | + image: your/invenio-image |
| 76 | + |
| 77 | +worker: |
| 78 | + image: your/invenio-image |
| 79 | +``` |
| 80 | +
|
| 81 | +The next step is the installation itself, with your own configuration in the `values.yaml`. If you added the repository you can install it by using the chart name and the desired version: |
| 82 | + |
| 83 | +``` console |
| 84 | +$ helm install -f values.yaml invenio helm-invenio/invenio --version 0.2.0 |
| 85 | +``` |
| 86 | + |
| 87 | +If you want to install from GitHub, in a clone you can do so as follows: |
| 88 | + |
| 89 | +``` console |
| 90 | +$ cd helm-invenio/ |
| 91 | +$ helm install -f values.yaml invenio ./invenio [--disable-openapi-validation] |
| 92 | +``` |
| 93 | + |
| 94 | +In both cases the output will be: |
| 95 | + |
| 96 | +``` console |
| 97 | +NAME: invenio |
| 98 | +LAST DEPLOYED: Mon Mar 9 16:25:15 2020 |
| 99 | +NAMESPACE: default |
| 100 | +STATUS: deployed |
| 101 | +REVISION: 1 |
| 102 | +TEST SUITE: None |
| 103 | +NOTES:Invenio is ready to rock :rocket: |
| 104 | +``` |
| 105 | + |
| 106 | +!!! warning "Bypassing openapi validation" |
| 107 | + We must pass `--disable-openapi-validation` as there is currently a problem with OpenShift objects and Helm when it comes to client side validation, see [issue](https://github.com/openshift/origin/issues/24060). |
| 108 | + |
| 109 | + |
| 110 | +### Setup the instance |
| 111 | + |
| 112 | +Once the instance has been installed you have to set up the services. Note that this step is only needed the first time, if you are upgrading the instance this is not needed. |
| 113 | + |
| 114 | +Get a bash terminal in a web pod: |
| 115 | + |
| 116 | +```console |
| 117 | +$ oc get pods |
| 118 | +$ oc exec -it <web-pod> bash |
| 119 | +``` |
| 120 | + |
| 121 | +Setup the instance using the `invenio` commands: |
| 122 | + |
| 123 | +``` console |
| 124 | +$ . scl_source enable rh-python36 |
| 125 | +$ invenio db init # If the db does not exist already, otherwise `create` is enough |
| 126 | +$ invenio db create |
| 127 | +$ invenio index init |
| 128 | +$ invenio index queue init purge |
| 129 | +$ invenio files location --default 'default-location' $(invenio shell --no-term-title -c "print(app.instance_path)")'/data' |
| 130 | +$ invenio roles create admin |
| 131 | +$ invenio access allow superuser-access role admin |
| 132 | +``` |
| 133 | + |
| 134 | +#### Launching jobs |
| 135 | + |
| 136 | +**One time job** |
| 137 | + |
| 138 | +In some cases you might want to run jobs, for example to populate the instance with records. |
| 139 | + |
| 140 | +``` console |
| 141 | +$ oc process -f job.yml --param JOB_NAME='demo-data-1' \ |
| 142 | + --param JOB_COMMAND='invenio rdm-records demo' | oc create -f - |
| 143 | +``` |
| 144 | + |
| 145 | +**Cron job** |
| 146 | + |
| 147 | +Now imagine you might have some bulk record creation that needs to be indexed, or any other task that you have to do every certain period of time. |
| 148 | +For that you can define cronjobs: |
| 149 | + |
| 150 | +``` console |
| 151 | +$ oc process -f cronjob.yml --param JOB_NAME=index-run \ |
| 152 | + --param JOB_COMMAND=invenio index run -d | oc create -f - |
| 153 | +``` |
| 154 | + |
| 155 | +### Upgrade your instance |
| 156 | + |
| 157 | +If you have performed some changes to your instance (e.g. configuration) or you want to upgrade the version of the charts, you can do so with |
| 158 | +the `upgrade` command of `helm`, note that you still need to disable the openapi validation which is only supoprted after version 3.1.2: |
| 159 | + |
| 160 | +``` console |
| 161 | +$ helm upgrade -f values.yaml --disable-openapi-validation |
| 162 | +``` |
0 commit comments