Skip to content

Prepare Databases for Manager

Joongi Kim edited this page Dec 29, 2017 · 29 revisions

Load initial etcd data

Edit image-metadata.sample.yml and image-aliases.sample.yml according to your setup. By default you can pull the images listed in the sample via docker pull lablup/kernel-xxxx:tag as they are hosted on the public Docker registry.

Load image registry metadata

$ python -m ai.backend.manager.cli etcd update-kernels \
  --namespace=NS --etcd-addr=ETCDADDR \
  -f image-metadata.sample.yml

Load image aliases

$ python -m ai.backend.manager.cli etcd update-aliases \
  --namespace=NS --etcd-addr=ETCDADDR \
  -f image-aliases.sample.yml

Set the default storage mount for virtual folders

$ ETCDCTL_API=3 etcdctl put /sorna/NS/volumes/_vfroot mystorage

Create a new database

$ psql -h DBHOST -U DBPASS
postgres=# CREATE DATABASE backend;
postgres=# \q

Set up database schema

Backend.AI uses alembic to manage database schema and its migration during version upgrades. First, localize the sample config:

$ cp alembic.ini.sample alembic.ini

Modify the line where sqlalchemy.url is set. You may use the following shell command: (ensure that special characters in your password are properly escaped)

$ sed -i'' -e 's!^sqlalchemy.url = .*$!sqlalchemy.url = postgresql://DBUSER:DBPASS@DBHOST/backend!' alembic.ini
$ python -m ai.backend.manager.cli schema oneshot head

NOTE: All sub-commands under "schema" uses alembic.ini to establish database connections.

Load initial fixtures

Edit ai/backend/manager/models/fixtures.py so that you have a randomized admin keypair.

(TODO: automate here!)

Then pour it to the database:

$ python -m ai.backend.manager.cli \
  --db-addr=DBHOST:DBPORT --db-user=DBUSER --db-password=DBPASS --db-name=backend \
  fixture populate example_keypair
Clone this wiki locally