Skip to content

Commit

Permalink
Add a section on how to use helm stable/postgresql for the hub
Browse files Browse the repository at this point in the history
Reference #567

Signed-off-by: Gaetan Semet <gaetan@xeberon.net>
  • Loading branch information
gsemet committed Mar 12, 2018
1 parent f464ddd commit 9f96e38
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions doc/source/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,59 @@ and **google cloud's ingress controller**.
This should provision a certificate, and keep renewing it whenever it gets close
to expiry!


## Using PostgreSQL as database for you Hub.

Four types of settings are allowed for storing hub state, as described in
the key ``hub.db.type``:

- ``sqlite-pvc``
- ``sqlite-memory``
- ``mysql``
- ``postgres``

Using PostgreSql or MySQL provides the main advantage to allow seemless update
of your hub without discontinuity of service (logged in users can always
continue to work on running server, even with SQLite, but the difference between
SQLite and MySQL/PostgreSQL are for new user, in order to allow them to log in
even when a new hub is starting).

The easiest way of running PostgreSQL for the Hub is to use Helm
'stable/postgresal' chart:

```bash
$ cat > pg-values.yaml <<EOF
postgresUser: jupyterhub
postgresPassword: jupyterhub
postgresDatabase: jupyterhub
persistence:
enabled: False # see helm 'stable/postgresql` documentation if you want pesistance
EOF
$ helm upgrade --install --name hub-db -f pg-values.yaml stable/postgresql
```

And then set `hub.db.type` to:

```yaml
hub:
db:
type: postgresql
url: postpostgres+psycopg2://jupyerhub:jupyterhub@hub-db-postgresql:5432/jupyterhub
```
Note the following points when using PostgreSQL as database for the Hub:
- If you do not use a persistant volume on PostgreSQL, your database will be
lost when the PostgreSQL server will restart. Do not use `--recreate-pods`
helm option. It will not cause any data loss for user, just the proxy will
not be able to route logged users.
- even without persistance, your hub can still be upgraded smoothly for the
users, because a Hub restart will not cause the PostgreSQL pod to restart.
- The Hub will use Rolling Update, so a new hub will be started while the
other is still running and the transition will be transparent for the user.
- if case of DB loss or reset, simply ensure all your server are shutdown
(all Kubernetes pods starting with `jupyter-*`) before restarting the Hub.

## Arbitrary extra code and configuration in `jupyterhub_config.py`

Sometimes the various options exposed via the helm-chart's `values.yaml` is not
Expand Down

0 comments on commit 9f96e38

Please sign in to comment.