From 3a1fab608504c63de3ed74dd9d9ad657fa76b790 Mon Sep 17 00:00:00 2001 From: Wu Wenxiang Date: Thu, 5 Aug 2021 15:57:03 +0800 Subject: [PATCH] fix: add quick start with sqlite in README doc 1. add quick launch steps for skyline docker image with sqlite Change-Id: I6c29bdacae09ac5fec40d60b92c57c8786c0aa52 --- README-zh_CN.md | 234 +++++++++++++++++++++++++++--------------------- README.md | 234 +++++++++++++++++++++++++++--------------------- 2 files changed, 262 insertions(+), 206 deletions(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index d1ea624..3e8a197 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -22,85 +22,108 @@ Skyline 是一个经过 UI 和 UE 优化过的 OpenStack 仪表盘, 拥有现代 - 一个至少运行核心组件的 OpenStack 环境, 并能通过 Keystone endpoint 访问 OpenStack 组件 - 一个安装有容器引擎的 ([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 -$ 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) -``` + 可以参考 [sample file](etc/skyline.yaml.sample), 并根据实际的环境修改以下参数 -#### 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 -MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'localhost' IDENTIFIED BY 'SKYLINE_DBPASS'; -Query OK, 0 rows affected (0.001 sec) +1. 运行 skyline_bootstrap 容器进行初始化引导 -MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'%' IDENTIFIED BY 'SKYLINE_DBPASS'; -Query OK, 0 rows affected (0.001 sec) -``` + ```bash + 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 -# Source the admin credentials -$ source admin-openrc + # Check bootstrap is normal `exit 0` + docker logs skyline_bootstrap + ``` -# 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 | -+---------------------+----------------------------------+ +2. 初始化引导完成后运行 skyline 服务 -# Add the admin role to the skyline user: -$ openstack role add --project service --user skyline admin -``` + ```bash + 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 -- keystone_url -- default_region -- interface_type -- system_project_domain -- system_project -- system_user_domain -- system_user_name -- system_user_password +1. 连接 OpenStack 环境的数据库, 并创建 `skyline` 数据库 -#### 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 -docker run -d --name skyline_bootstrap -e KOLLA_BOOTSTRAP="" -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml --net=host skyline:latest +2. 授予对数据库的适当访问权限 -# Check bootstrap is normal `exit 0` -docker logs skyline_bootstrap -``` + 用合适的密码替换 `SKYLINE_DBPASS` -#### 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 -docker rm -f skyline_bootstrap + MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'%' IDENTIFIED BY 'SKYLINE_DBPASS'; + 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://: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 -- poetry >= 1.1.0 - ([安装指南](https://python-poetry.org/docs/#installation)) +- python >= 3.8 +- poetry >= 1.1.0 ([安装指南](https://python-poetry.org/docs/#installation)) +- node >= 10.22.0 +- yarn >= 1.22.4 ### 安装和运行 -#### 1. 安装依赖包 +1. 安装依赖包 -```bash -make install -``` + ```bash + make install + ``` -#### 2. 配置 `skyline.yaml` 文件 +2. 配置 `skyline.yaml` 文件 -```bash -cp etc/skyline.yaml.sample etc/skyline.yaml -export OS_CONFIG_DIR=$(pwd)/etc -``` + ```bash + cp etc/skyline.yaml.sample etc/skyline.yaml + export OS_CONFIG_DIR=$(pwd)/etc + ``` -可能你需要根据实际的环境修改以下参数: + 可能你需要根据实际的环境修改以下参数: -```yaml -- database_url -- keystone_url -- default_region -- interface_type -- system_project_domain -- system_project -- system_user_domain -- system_user_name -- system_user_password -``` + ```yaml + - database_url + - keystone_url + - default_region + - interface_type + - system_project_domain + - system_project + - system_user_domain + - system_user_name + - system_user_password + ``` -> 如果你为 `database_url` 设置了类似 `sqlite:////tmp/skyline.db` ,只需要执行以下操作。 -> 如果你为 `database_url` 设置了类似 `mysql://root:root@localhost:3306/skyline` ,你应该先参考 `配置和部署` 一章中的 `1` 和 `2` 步骤。 + > 如果你为 `database_url` 设置了类似 `sqlite:////tmp/skyline.db` ,只需要执行以下操作。 + > 如果你为 `database_url` 设置了类似 `mysql://root:root@localhost:3306/skyline` ,你应该先参考 `部署 - 数据库使用 MariaDB` 一章中的 `1` 和 `2` 步骤。 -#### 3. 初始化 skyline 数据库 +3. 初始化 skyline 数据库 -```bash -pushd libs/skyline-apiserver/ -make db_sync -popd -``` + ```bash + pushd libs/skyline-apiserver/ + make db_sync + popd + ``` -#### 4. 运行 skyline-apiserver +4. 运行 skyline-apiserver -```bash -$ poetry run uvicorn --reload --reload-dir libs/skyline-apiserver/skyline_apiserver --port 28000 --log-level debug skyline_apiserver.main:app + ```bash + $ 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: Started reloader process [154033] using statreload -INFO: Started server process [154037] -INFO: Waiting for application startup. -INFO: Application startup complete. -``` + INFO: Uvicorn running on http://127.0.0.1:28000 (Press CTRL+C to quit) + INFO: Started reloader process [154033] using statreload + INFO: Started server process [154037] + INFO: Waiting for application startup. + INFO: Application startup complete. + ``` -此时你可访问在线 API 文档:`http://127.0.0.1:28000/docs` + 此时你可访问在线 API 文档:`http://127.0.0.1:28000/docs` + +5. 构建镜像 + + ```bash + make build + ``` diff --git a/README.md b/README.md index 9c54bc0..58a1f78 100644 --- a/README.md +++ b/README.md @@ -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 - 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 -$ 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) -``` + You can refer to the [sample file](etc/skyline.yaml.sample), and modify the following parameters according to the actual environment -#### 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 -MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'localhost' IDENTIFIED BY 'SKYLINE_DBPASS'; -Query OK, 0 rows affected (0.001 sec) +1. Run the skyline_bootstrap container to bootstrap -MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'%' IDENTIFIED BY 'SKYLINE_DBPASS'; -Query OK, 0 rows affected (0.001 sec) -``` + ```bash + 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 -# Source the admin credentials -$ source admin-openrc + # Check bootstrap is normal `exit 0` + docker logs skyline_bootstrap + ``` -# 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 | -+---------------------+----------------------------------+ +2. Run the skyline service after bootstrap is complete -# Add the admin role to the skyline user: -$ openstack role add --project service --user skyline admin -``` + ```bash + 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 -- keystone_url -- default_region -- interface_type -- system_project_domain -- system_project -- system_user_domain -- system_user_name -- system_user_password +1. Connect to database of the OpenStack environment and create the `skyline` database -#### 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 -docker run -d --name skyline_bootstrap -e KOLLA_BOOTSTRAP="" -v /etc/skyline/skyline.yaml:/etc/skyline/skyline.yaml --net=host skyline:latest +2. Grant proper access to the databases -# Check bootstrap is normal `exit 0` -docker logs skyline_bootstrap -``` + Replace `SKYLINE_DBPASS` with a suitable password. -#### 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 -docker rm -f skyline_bootstrap + MariaDB [(none)]> GRANT ALL PRIVILEGES ON skyline.* TO 'skyline'@'%' IDENTIFIED BY 'SKYLINE_DBPASS'; + 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://:8080` @@ -110,63 +133,68 @@ You can now access the dashboard: `https://:8080` ### Dependent tools -- python >= 3.8 -- yarn >= 1.22.4 -- node >= 10.22.0 - make >= 3.82 -- poetry >= 1.1.0 - ([Installation Guide](https://python-poetry.org/docs/#installation)) +- python >= 3.8 +- poetry >= 1.1.0 ([Installation Guide](https://python-poetry.org/docs/#installation)) +- node >= 10.22.0 +- yarn >= 1.22.4 ### Install & Run -#### 1. Installing dependency packages +1. Installing dependency packages -```bash -make install -``` + ```bash + make install + ``` -#### 2. Set skyline.yaml config file +2. Set skyline.yaml config file -```bash -cp etc/skyline.yaml.sample etc/skyline.yaml -export OS_CONFIG_DIR=$(pwd)/etc -``` + ```bash + cp etc/skyline.yaml.sample etc/skyline.yaml + 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 -- database_url -- keystone_url -- default_region -- interface_type -- system_project_domain -- system_project -- system_user_domain -- system_user_name -- system_user_password -``` + ```yaml + - database_url + - keystone_url + - default_region + - interface_type + - system_project_domain + - system_project + - system_user_domain + - system_user_name + - system_user_password + ``` -> 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 `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 `Deployment with MariaDB` at first. -#### 3. Init skyline database +3. Init skyline database -```bash -pushd libs/skyline-apiserver/ -make db_sync -popd -``` + ```bash + pushd libs/skyline-apiserver/ + make db_sync + popd + ``` -#### 4. Run skyline-apiserver +4. Run skyline-apiserver -```bash -$ poetry run uvicorn --reload --reload-dir libs/skyline-apiserver/skyline_apiserver --port 28000 --log-level debug skyline_apiserver.main:app + ```bash + $ 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: Started reloader process [154033] using statreload -INFO: Started server process [154037] -INFO: Waiting for application startup. -INFO: Application startup complete. -``` + INFO: Uvicorn running on http://127.0.0.1:28000 (Press CTRL+C to quit) + INFO: Started reloader process [154033] using statreload + INFO: Started server process [154037] + INFO: Waiting for application startup. + 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 + ```