Backend.AI Manager with API Gateway
===================================
Package Structure
-----------------
* `ai.backend`
- `manager`: Abstraction of agents and computation kernels
- `gateway`: User and Admin API (REST/GraphQL) gateway based on aiohttp
Installation
------------
Please visit [the installation guides](https://github.com/lablup/backend.ai/wiki).
### Kernel/system configuration
#### Recommended resource limits:
**`/etc/security/limits.conf`**
```
root hard nofile 512000
root soft nofile 512000
root hard nproc 65536
root soft nproc 65536
user hard nofile 512000
user soft nofile 512000
user hard nproc 65536
user soft nproc 65536
```
**sysctl**
```
fs.file-max=2048000
net.core.somaxconn=1024
net.ipv4.tcp_max_syn_backlog=1024
net.ipv4.tcp_slow_start_after_idle=0
net.ipv4.tcp_fin_timeout=10
net.ipv4.tcp_window_scaling=1
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_early_retrans=1
net.ipv4.ip_local_port_range="10000 65000"
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem=4096 12582912 16777216
net.ipv4.tcp_wmem=4096 12582912 16777216
```
### For development
#### Prerequisites
* `libnsappy-dev` or `snappy-devel` system package depending on your distro
* Python 3.6 or higher with [pyenv](https://github.com/pyenv/pyenv)
and [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv) (optional but recommneded)
* Docker 18.03 or later with docker-compose (18.09 or later is recommended)
#### Common steps
Clone [the meta repository](https://github.com/lablup/backend.ai) and install a "halfstack"
configuration. The halfstack configuration installs and runs several dependency daemons such as etcd in
the background.
```console
$ git clone https://github.com/lablup/backend.ai halfstack
$ cd halfstack
$ docker-compose -f docker-compose.halfstack.yml up -d
```
Then prepare the source clone of the agent as follows.
First install the current working copy.
```console
$ git clone https://github.com/lablup/backend.ai-manager manager
$ cd manager
$ pyenv virtualenv venv-manager
$ pyenv local venv-manager
$ pip install -U pip setuptools
$ pip install -U -r requirements/dev.txt
```
From now on, let's assume all shell commands are executed inside the virtualenv.
### Halfstack (single-node development & testing)
#### Recommended directory structure
* `backend.ai-dev`
- `manager` (git clone from this repo)
- `agent` (git clone from [the agent repo](https://github.com/lablup/backend.ai-agent))
- `common` (git clone from [the common repo](https://github.com/lablup/backend.ai-common))
Install `backend.ai-common` as an editable package in the manager (and the agent) virtualenvs
to keep the codebase up-to-date.
```console
$ cd manager
$ pip install -U -e ../common -r requirements/dev.txt
```
#### Steps
Copy (or symlink) the halfstack configs:
```console
$ cp config/halfstack.toml ./manager.toml
$ cp config/halfstack.alembic.ini ./alembic.ini
```
Set up Redis:
```console
$ backend.ai mgr etcd put config/redis/addr 127.0.0.1:8110
```
> ℹ️ NOTE: You may replace `backend.ai mgr` with `python -m ai.backend.manager.cli` in case your `PATH` is unmodifiable.
Set up the public Docker registry:
```console
$ backend.ai mgr etcd put config/docker/registry/index.docker.io "https://registry-1.docker.io"
$ backend.ai mgr etcd put config/docker/registry/index.docker.io/username "lablup"
$ backend.ai mgr etcd rescan-images index.docker.io
```
Set up the vfolder paths:
```console
$ mkdir -p "$HOME/vfroot/local"
$ backend.ai mgr etcd put volumes/_mount "$HOME/vfroot"
$ backend.ai mgr etcd put volumes/_default_host local
```
Set up the allowed types of vfolder. Allowed values are "user" or "group".
If none is specified, "user" type is set implicitly:
```console
$ backend.ai mgr etcd put volumes/_types/user "" # enable user vfolder
$ backend.ai mgr etcd put volumes/_types/group "" # enable group vfolder
```
Set up the database:
```console
$ backend.ai mgr schema oneshot
$ backend.ai mgr fixture populate sample-configs/example-keypairs.json
$ backend.ai mgr fixture populate sample-configs/example-resource-presets.json
```
Then, run it (for debugging, append a `--debug` flag):
```console
$ backend.ai mgr start-server
```
To run tests:
```console
$ python -m flake8 src tests
$ python -m pytest -m 'not integration' tests
```
Now you are ready to install the agent.
Head to [the README of Backend.AI Agent](https://github.com/lablup/backend.ai-agent/blob/master/README.md).
NOTE: To run tests including integration tests, you first need to install and run the agent on the same host.
## Deployment
### Configuration
Put a TOML-formatted manager configuration (see the sample in `config/sample.toml`)
in one of the following locations:
* `manager.toml` (current working directory)
* `~/.config/backend.ai/manager.toml` (user-config directory)
* `/etc/backend.ai/manager.toml` (system-config directory)
Only the first found one is used by the daemon.
Also many configurations shared by both manager and agent are stored in etcd.
As you might have noticed above, the manager provides a CLI interface to access and manipulate the etcd
data. Check out the help page of our etcd command set:
```console
$ python -m ai.backend.manager.cli etcd --help
```
If you run etcd as a Docker container (e.g., via halfstack), you may use the native client as well.
In this case, PLEASE BE WARNED that you must prefix the keys with "/sorna/{namespace}" manaully:
```console
$ docker exec -it ${ETCD_CONTAINER_ID} /bin/ash -c 'ETCDCTL_API=3 etcdctl ...'
```
### Running from a command line
The minimal command to execute:
```sh
python -m ai.backend.gateway.server
```
For more arguments and options, run the command with `--help` option.
### Writing a wrapper script
To use with systemd, crontab, and other system-level daemons, you may need to write a shell script
that executes specific CLI commands provided by Backend.AI modules.
The following example shows how to set up pyenv and virtualenv for the script-local environment.
It runs the gateway server if no arguments are given, and execute the given arguments as a shell command
if any.
For instance, you may get/set configurations like: `run-manager.sh python -m ai.backend.manager.etcd ...`
where the name of scripts is `run-manager.sh`.
```bash
#! /bin/bash
if [ -z "$HOME" ]; then
export HOME="/home/devops"
fi
if [ -z "$PYENV_ROOT" ]; then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
fi
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv activate venv-bai-manager
if [ "$#" -eq 0 ]; then
exec python -m ai.backend.gateway.server
else
exec "$@"
fi
```
### Networking
The manager and agent should run in the same local network or different
networks reachable via VPNs, whereas the manager's API service must be exposed to
the public network or another private network that users have access to.
The manager requires access to the etcd, the PostgreSQL database, and the Redis server.
| User-to-Manager TCP Ports | Usage |
|:-------------------------:|-------|
| manager:{80,443} | Backend.AI API access |
| Manager-to-X TCP Ports | Usage |
|:----------------------:|-------|
| etcd:2379 | etcd API access |
| postgres:5432 | Database access |
| redis:6379 | Redis API access |
The manager must also be able to access TCP ports 6001, 6009, and 30000 to 31000 of the agents in default
configurations. You can of course change those port numbers and ranges in the configuration.
| Manager-to-Agent TCP Ports | Usage |
|:--------------------------:|-------|
| 6001 | ZeroMQ-based RPC calls from managers to agents |
| 6009 | HTTP watcher API |
| 30000-31000 | Port pool for in-container services |
LICENSES
--------
[GNU Lesser General Public License](https://github.com/lablup/backend.ai-manager/blob/master/LICENSE)
[Dependencies](https://github.com/lablup/backend.ai-manager
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共183个文件
py:168个
txt:5个
pkg-info:2个
资源分类:Python库 所属语言:Python 资源全名:backend.ai-manager-20.9.20.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
Python库 | backend.ai-manager-20.9.20.tar.gz (183个子文件)
setup.cfg 3KB
MANIFEST.in 48B
LICENSE 7KB
script.py.mako 494B
README.md 8KB
not-zip-safe 1B
PKG-INFO 9KB
PKG-INFO 9KB
registry.py 108KB
session.py 82KB
vfolder.py 80KB
kernel.py 48KB
user.py 37KB
gql.py 37KB
dispatcher.py 35KB
resource.py 32KB
auth.py 32KB
config.py 30KB
stream.py 27KB
server.py 25KB
base.py 24KB
vfolder.py 22KB
group.py 21KB
image.py 19KB
scaling_group.py 18KB
events.py 18KB
keypair.py 17KB
session_template.py 15KB
cluster_template.py 15KB
exceptions.py 14KB
domain.py 13KB
types.py 13KB
idle.py 12KB
groupconfig.py 11KB
etcd.py 11KB
resource_policy.py 11KB
logs.py 11KB
agent.py 10KB
utils.py 10KB
manager.py 10KB
f0f4ee907155_dynamic_resource_slots.py 9KB
userconfig.py 9KB
session_template.py 9KB
predicates.py 9KB
image.py 9KB
storage.py 9KB
wsproxy.py 9KB
4cc87e7fbfdf_stats_refactor.py 8KB
base.py 8KB
5d8e6043455e_add_user_group_ids_in_vfolder.py 8KB
domainconfig.py 8KB
9a91532c8534_add_scaling_group.py 7KB
utils.py 6KB
7ea324d0535b_vfolder_and_kernel.py 6KB
405aa2c39458_job_queue.py 6KB
819c2b3830a9_add_user_model.py 6KB
background.py 6KB
etcd.py 5KB
resource_preset.py 5KB
drf.py 5KB
c5e4e764f9e3_add_domain_group_user_fields_to_kernels.py 5KB
fifo.py 5KB
admin.py 5KB
__main__.py 5KB
529113b08c2c_add_vfolder_type_column.py 5KB
harbor.py 4KB
queryfilter.py 4KB
ratelimit.py 4KB
d5cc54fd36b5_update_for_multicontainer_sessions.py 4KB
error_monitor.py 4KB
dbschema.py 4KB
dbc1e053b880_add_keypair_resource_policy.py 3KB
docker.py 3KB
5de06da3c2b5_init.py 3KB
854bd902b1bc_change_kernel_identification.py 3KB
bae1a7326e8a_add_domain_model.py 3KB
e35332f8d23d_add_modified_at_to_users_and_kernels.py 3KB
0f3bc98edaa0_more_status.py 3KB
e18ed5fcfedf_add_superadmin_role_for_user.py 3KB
8e660aa31fe3_add_resource_presets.py 3KB
8679d0a7e22b_add_scheduled_to_kernelstatus.py 3KB
d52bf5ec9ef3_convert_cpu_gpu_slots_to_float.py 3KB
f8a71c3bffa2_stringify_userid.py 3KB
513164749de4_add_cancelled_to_kernelstatus.py 3KB
e421c02cf9e4_rename_kernel_dependencies_to_session_.py 3KB
exceptions.py 3KB
548cc8aa49c8_update_cluster_columns_in_kernels.py 2KB
0262e50e90e0_add_ssh_keypair_into_keypair.py 2KB
env.py 2KB
7a82e0c70122_add_group_model.py 2KB
0c5733f80e4d_index_kernel_timestamps.py 2KB
scaling_group.py 2KB
distributed.py 2KB
mof.py 2KB
fixture.py 2KB
22964745c12b_add_total_resource_slots_to_group.py 2KB
0d553d59f369_users_replace_is_active_to_status_and_its_info.py 2KB
a1fd4e7b7782_enumerate_vfolder_perms.py 2KB
ce209920f654_create_task_template_table.py 2KB
context.py 1KB
共 183 条
- 1
- 2
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 10Eclipse项目源码.jpg
- 大屏可视化数据课程项目
- Maven 快速入门指南:安装和配置方法详解
- STM32物信息通过MQTT协议上传云平台
- STM32物信息通过MQTT协议上传云平台
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6260.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6259.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6258.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6257.0)
- Screenshot_2024_0614_022736.png
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功