fix: add quick start with sqlite in README doc

1. add quick launch steps for skyline docker image with sqlite

Change-Id: I6c29bdacae09ac5fec40d60b92c57c8786c0aa52
This commit is contained in:
Wu Wenxiang 2021-08-05 15:57:03 +08:00
parent c78ef2f522
commit 3a1fab6085
2 changed files with 262 additions and 206 deletions

View File

@ -22,85 +22,108 @@ Skyline 是一个经过 UI 和 UE 优化过的 OpenStack 仪表盘, 拥有现代
- 一个至少运行核心组件的 OpenStack 环境, 并能通过 Keystone endpoint 访问 OpenStack 组件 - 一个至少运行核心组件的 OpenStack 环境, 并能通过 Keystone endpoint 访问 OpenStack 组件
- 一个安装有容器引擎的 ([docker](https://docs.docker.com/engine/install/) 或 [podman](https://podman.io/getting-started/installation)) 的 Linux 服务器 - 一个安装有容器引擎的 ([docker](https://docs.docker.com/engine/install/) 或 [podman](https://podman.io/getting-started/installation)) 的 Linux 服务器
### 配置和部署 ### 配置
#### 1. 连接 OpenStack 环境的数据库, 并创建 `skyline` 数据库 1. 在 Linux 服务器中编辑 `/etc/skyline/skyline.yaml` 文件
```bash 可以参考 [sample file](etc/skyline.yaml.sample), 并根据实际的环境修改以下参数
$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS skyline DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
Query OK, 1 row affected (0.001 sec)
```
#### 2. 授予对数据库的适当访问权限 - database_url
- keystone_url
- default_region
- interface_type
- system_project_domain
- system_project
- system_user_domain
- system_user_name
- system_user_password
用合适的密码替换 `SKYLINE_DBPASS` ### 部署 - 数据库使用 Sqlite
```bash 1. 运行 skyline_bootstrap 容器进行初始化引导
MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'localhost' IDENTIFIED BY 'SKYLINE_DBPASS';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'%' IDENTIFIED BY 'SKYLINE_DBPASS'; ```bash
Query OK, 0 rows affected (0.001 sec) rm -rf /tmp/skyline && mkdir /tmp/skyline
```
#### 3. 创建 skyline 服务凭证 docker run -d --name skyline_bootstrap -e KOLLA_BOOTSTRAP="" -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml -v /tmp/skyline:/tmp --net=host 99cloud/skyline:latest
```bash # Check bootstrap is normal `exit 0`
# Source the admin credentials docker logs skyline_bootstrap
$ source admin-openrc ```
# Create the skyline user 2. 初始化引导完成后运行 skyline 服务
$ openstack user create --domain default --password-prompt skyline
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 1qaz2wsx3edc4rfv5tgb6yhn7ujm8ikl |
| name | skyline |
| options | {} |
| password_expires_at | 2020-08-08T08:08:08.123456 |
+---------------------+----------------------------------+
# Add the admin role to the skyline user: ```bash
$ openstack role add --project service --user skyline admin docker rm -f skyline_bootstrap
```
#### 4. 在 Linux 服务器中编辑 `/etc/skyline/skyline.yaml` 文件 docker run -d --name skyline --restart=always -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml -v /tmp/skyline:/tmp --net=host 99cloud/skyline:latest
```
可以参考 [sample file](etc/skyline.yaml.sample), 并根据实际的环境修改以下参数 ### 部署 - 数据库使用 MariaDB
- database_url 1. 连接 OpenStack 环境的数据库, 并创建 `skyline` 数据库
- keystone_url
- default_region
- interface_type
- system_project_domain
- system_project
- system_user_domain
- system_user_name
- system_user_password
#### 5. 运行 skyline_bootstrap 容器进行初始化引导 ```bash
$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS skyline DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
Query OK, 1 row affected (0.001 sec)
```
```bash 2. 授予对数据库的适当访问权限
docker run -d --name skyline_bootstrap -e KOLLA_BOOTSTRAP="" -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml --net=host skyline:latest
# Check bootstrap is normal `exit 0` 用合适的密码替换 `SKYLINE_DBPASS`
docker logs skyline_bootstrap
```
#### 5. 初始化引导完成后运行 skyline 服务 ```bash
MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'localhost' IDENTIFIED BY 'SKYLINE_DBPASS';
Query OK, 0 rows affected (0.001 sec)
```bash MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'%' IDENTIFIED BY 'SKYLINE_DBPASS';
docker rm -f skyline_bootstrap Query OK, 0 rows affected (0.001 sec)
```
docker run -d --name skyline --restart=always -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml --net=host skyline:latest 3. 创建 skyline 服务凭证
```
#### 6. 完成安装 ```bash
# Source the admin credentials
$ source admin-openrc
# Create the skyline user
$ openstack user create --domain default --password-prompt skyline
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 1qaz2wsx3edc4rfv5tgb6yhn7ujm8ikl |
| name | skyline |
| options | {} |
| password_expires_at | 2020-08-08T08:08:08.123456 |
+---------------------+----------------------------------+
# Add the admin role to the skyline user:
$ openstack role add --project service --user skyline admin
```
4. 运行 skyline_bootstrap 容器进行初始化引导
```bash
docker run -d --name skyline_bootstrap -e KOLLA_BOOTSTRAP="" -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml --net=host 99cloud/skyline:latest
# Check bootstrap is normal `exit 0`
docker logs skyline_bootstrap
```
5. 初始化引导完成后运行 skyline 服务
```bash
docker rm -f skyline_bootstrap
docker run -d --name skyline --restart=always -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml --net=host 99cloud/skyline:latest
```
### 访问测试
现在你可以访问仪表盘: `https://<ip_address>:8080` 现在你可以访问仪表盘: `https://<ip_address>:8080`
@ -110,63 +133,68 @@ docker run -d --name skyline --restart=always -v /etc/skyline/skyline.yaml:/etc/
### 依赖工具 ### 依赖工具
- python >= 3.8
- yarn >= 1.22.4
- node >= 10.22.0
- make >= 3.82 - make >= 3.82
- poetry >= 1.1.0 - python >= 3.8
([安装指南](https://python-poetry.org/docs/#installation)) - poetry >= 1.1.0 ([安装指南](https://python-poetry.org/docs/#installation))
- node >= 10.22.0
- yarn >= 1.22.4
### 安装和运行 ### 安装和运行
#### 1. 安装依赖包 1. 安装依赖包
```bash ```bash
make install make install
``` ```
#### 2. 配置 `skyline.yaml` 文件 2. 配置 `skyline.yaml` 文件
```bash ```bash
cp etc/skyline.yaml.sample etc/skyline.yaml cp etc/skyline.yaml.sample etc/skyline.yaml
export OS_CONFIG_DIR=$(pwd)/etc export OS_CONFIG_DIR=$(pwd)/etc
``` ```
可能你需要根据实际的环境修改以下参数: 可能你需要根据实际的环境修改以下参数:
```yaml ```yaml
- database_url - database_url
- keystone_url - keystone_url
- default_region - default_region
- interface_type - interface_type
- system_project_domain - system_project_domain
- system_project - system_project
- system_user_domain - system_user_domain
- system_user_name - system_user_name
- system_user_password - system_user_password
``` ```
> 如果你为 `database_url` 设置了类似 `sqlite:////tmp/skyline.db` ,只需要执行以下操作。 > 如果你为 `database_url` 设置了类似 `sqlite:////tmp/skyline.db` ,只需要执行以下操作。
> 如果你为 `database_url` 设置了类似 `mysql://root:root@localhost:3306/skyline` ,你应该先参考 `配置和部署` 一章中的 `1``2` 步骤。 > 如果你为 `database_url` 设置了类似 `mysql://root:root@localhost:3306/skyline` ,你应该先参考 `部署 - 数据库使用 MariaDB` 一章中的 `1``2` 步骤。
#### 3. 初始化 skyline 数据库 3. 初始化 skyline 数据库
```bash ```bash
pushd libs/skyline-apiserver/ pushd libs/skyline-apiserver/
make db_sync make db_sync
popd popd
``` ```
#### 4. 运行 skyline-apiserver 4. 运行 skyline-apiserver
```bash ```bash
$ poetry run uvicorn --reload --reload-dir libs/skyline-apiserver/skyline_apiserver --port 28000 --log-level debug skyline_apiserver.main:app $ poetry run uvicorn --reload --reload-dir libs/skyline-apiserver/skyline_apiserver --port 28000 --log-level debug skyline_apiserver.main:app
INFO: Uvicorn running on http://127.0.0.1:28000 (Press CTRL+C to quit) INFO: Uvicorn running on http://127.0.0.1:28000 (Press CTRL+C to quit)
INFO: Started reloader process [154033] using statreload INFO: Started reloader process [154033] using statreload
INFO: Started server process [154037] INFO: Started server process [154037]
INFO: Waiting for application startup. INFO: Waiting for application startup.
INFO: Application startup complete. INFO: Application startup complete.
``` ```
此时你可访问在线 API 文档:`http://127.0.0.1:28000/docs` 此时你可访问在线 API 文档:`http://127.0.0.1:28000/docs`
5. 构建镜像
```bash
make build
```

234
README.md
View File

@ -22,85 +22,108 @@ Skyline is an OpenStack dashboard optimized by UI and UE. It has a modern techno
- An OpenStack environment that runs at least core components and can access OpenStack components through Keystone endpoints - An OpenStack environment that runs at least core components and can access OpenStack components through Keystone endpoints
- A Linux server with container engine ([docker](https://docs.docker.com/engine/install/) or [podman](https://podman.io/getting-started/installation)) installed - A Linux server with container engine ([docker](https://docs.docker.com/engine/install/) or [podman](https://podman.io/getting-started/installation)) installed
### Configure and deployment ### Configure
#### 1. Connect to database of the OpenStack environment and create the `skyline` database 1. Edit the `/etc/skyline/skyline.yaml` file in linux server
```bash You can refer to the [sample file](etc/skyline.yaml.sample), and modify the following parameters according to the actual environment
$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS skyline DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
Query OK, 1 row affected (0.001 sec)
```
#### 2. Grant proper access to the databases - database_url
- keystone_url
- default_region
- interface_type
- system_project_domain
- system_project
- system_user_domain
- system_user_name
- system_user_password
Replace `SKYLINE_DBPASS` with a suitable password. ### Deployment with Sqlite
```bash 1. Run the skyline_bootstrap container to bootstrap
MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'localhost' IDENTIFIED BY 'SKYLINE_DBPASS';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'%' IDENTIFIED BY 'SKYLINE_DBPASS'; ```bash
Query OK, 0 rows affected (0.001 sec) rm -rf /tmp/skyline && mkdir /tmp/skyline
```
#### 3. Create skyline service credentials docker run -d --name skyline_bootstrap -e KOLLA_BOOTSTRAP="" -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml -v /tmp/skyline:/tmp --net=host 99cloud/skyline:latest
```bash # Check bootstrap is normal `exit 0`
# Source the admin credentials docker logs skyline_bootstrap
$ source admin-openrc ```
# Create the skyline user 2. Run the skyline service after bootstrap is complete
$ openstack user create --domain default --password-prompt skyline
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 1qaz2wsx3edc4rfv5tgb6yhn7ujm8ikl |
| name | skyline |
| options | {} |
| password_expires_at | 2020-08-08T08:08:08.123456 |
+---------------------+----------------------------------+
# Add the admin role to the skyline user: ```bash
$ openstack role add --project service --user skyline admin docker rm -f skyline_bootstrap
```
#### 4. Edit the `/etc/skyline/skyline.yaml` file in linux server docker run -d --name skyline --restart=always -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml -v /tmp/skyline:/tmp --net=host 99cloud/skyline:latest
```
You can refer to the [sample file](etc/skyline.yaml.sample), and modify the following parameters according to the actual environment ### Deployment with MariaDB
- database_url 1. Connect to database of the OpenStack environment and create the `skyline` database
- keystone_url
- default_region
- interface_type
- system_project_domain
- system_project
- system_user_domain
- system_user_name
- system_user_password
#### 5. Run the skyline_bootstrap container to bootstrap ```bash
$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS skyline DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
Query OK, 1 row affected (0.001 sec)
```
```bash 2. Grant proper access to the databases
docker run -d --name skyline_bootstrap -e KOLLA_BOOTSTRAP="" -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml --net=host skyline:latest
# Check bootstrap is normal `exit 0` Replace `SKYLINE_DBPASS` with a suitable password.
docker logs skyline_bootstrap
```
#### 5. Run the skyline service after bootstrap is complete ```bash
MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'localhost' IDENTIFIED BY 'SKYLINE_DBPASS';
Query OK, 0 rows affected (0.001 sec)
```bash MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'%' IDENTIFIED BY 'SKYLINE_DBPASS';
docker rm -f skyline_bootstrap Query OK, 0 rows affected (0.001 sec)
```
docker run -d --name skyline --restart=always -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml --net=host skyline:latest 3. Create skyline service credentials
```
#### 6. finish installation ```bash
# Source the admin credentials
$ source admin-openrc
# Create the skyline user
$ openstack user create --domain default --password-prompt skyline
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 1qaz2wsx3edc4rfv5tgb6yhn7ujm8ikl |
| name | skyline |
| options | {} |
| password_expires_at | 2020-08-08T08:08:08.123456 |
+---------------------+----------------------------------+
# Add the admin role to the skyline user:
$ openstack role add --project service --user skyline admin
```
4. Run the skyline_bootstrap container to bootstrap
```bash
docker run -d --name skyline_bootstrap -e KOLLA_BOOTSTRAP="" -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml --net=host 99cloud/skyline:latest
# Check bootstrap is normal `exit 0`
docker logs skyline_bootstrap
```
5. Run the skyline service after bootstrap is complete
```bash
docker rm -f skyline_bootstrap
docker run -d --name skyline --restart=always -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml --net=host 99cloud/skyline:latest
```
### Test Access
You can now access the dashboard: `https://<ip_address>:8080` You can now access the dashboard: `https://<ip_address>:8080`
@ -110,63 +133,68 @@ You can now access the dashboard: `https://<ip_address>:8080`
### Dependent tools ### Dependent tools
- python >= 3.8
- yarn >= 1.22.4
- node >= 10.22.0
- make >= 3.82 - make >= 3.82
- poetry >= 1.1.0 - python >= 3.8
([Installation Guide](https://python-poetry.org/docs/#installation)) - poetry >= 1.1.0 ([Installation Guide](https://python-poetry.org/docs/#installation))
- node >= 10.22.0
- yarn >= 1.22.4
### Install & Run ### Install & Run
#### 1. Installing dependency packages 1. Installing dependency packages
```bash ```bash
make install make install
``` ```
#### 2. Set skyline.yaml config file 2. Set skyline.yaml config file
```bash ```bash
cp etc/skyline.yaml.sample etc/skyline.yaml cp etc/skyline.yaml.sample etc/skyline.yaml
export OS_CONFIG_DIR=$(pwd)/etc export OS_CONFIG_DIR=$(pwd)/etc
``` ```
Maybe you should change the params with your real environment as followed: Maybe you should change the params with your real environment as followed:
```yaml ```yaml
- database_url - database_url
- keystone_url - keystone_url
- default_region - default_region
- interface_type - interface_type
- system_project_domain - system_project_domain
- system_project - system_project
- system_user_domain - system_user_domain
- system_user_name - system_user_name
- system_user_password - system_user_password
``` ```
> If you set such as `sqlite:////tmp/skyline.db` for `database_url` , just do as followed. > If you set such as `sqlite:////tmp/skyline.db` for `database_url` , just do as followed.
> If you set such as `mysql://root:root@localhost:3306/skyline` for `database_url` , you should refer to steps `1` and `2` of the chapter `Configure and deployment` at first. > If you set such as `mysql://root:root@localhost:3306/skyline` for `database_url` , you should refer to steps `1` and `2` of the chapter `Deployment with MariaDB` at first.
#### 3. Init skyline database 3. Init skyline database
```bash ```bash
pushd libs/skyline-apiserver/ pushd libs/skyline-apiserver/
make db_sync make db_sync
popd popd
``` ```
#### 4. Run skyline-apiserver 4. Run skyline-apiserver
```bash ```bash
$ poetry run uvicorn --reload --reload-dir libs/skyline-apiserver/skyline_apiserver --port 28000 --log-level debug skyline_apiserver.main:app $ poetry run uvicorn --reload --reload-dir libs/skyline-apiserver/skyline_apiserver --port 28000 --log-level debug skyline_apiserver.main:app
INFO: Uvicorn running on http://127.0.0.1:28000 (Press CTRL+C to quit) INFO: Uvicorn running on http://127.0.0.1:28000 (Press CTRL+C to quit)
INFO: Started reloader process [154033] using statreload INFO: Started reloader process [154033] using statreload
INFO: Started server process [154037] INFO: Started server process [154037]
INFO: Waiting for application startup. INFO: Waiting for application startup.
INFO: Application startup complete. INFO: Application startup complete.
``` ```
You can now access the online API documentation: `http://127.0.0.1:28000/docs` You can now access the online API documentation: `http://127.0.0.1:28000/docs`
5. Build Image
```bash
make build
```