Skip to content

Commit b8453de

Browse files
author
olevole
committed
update README.md
1 parent ba74bbb commit b8453de

File tree

1 file changed

+110
-32
lines changed

1 file changed

+110
-32
lines changed

README.md

+110-32
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,50 @@ Copyright (c) 2013-2021, The CBSD Development Team
44

55
Homepage: https://bsdstore.ru
66

7-
## Description
8-
9-
Provides a simplified API for creating and destroying CBSD virtual environments.
10-
117
#### Table of Contents
128

13-
1. [Project Description - What does the project do?](#project-description)
14-
2. [Usage - Configuration options and additional functionality](#usage)
15-
3. [Contributing - Contribute to the project](#contributing)
16-
4. [Support - Mailing List, Talks, Contacts](#support)
17-
18-
## Usage
19-
20-
21-
Init:
9+
1. [Project Description - What does the project do?](#description)
10+
2. [Installation - HowTo start](#installation)
11+
3. [Usage - Configuration options and additional functionality](#usage)
12+
4. [Contributing - Contribute to the project](#contributing)
13+
5. [Support - Mailing List, Talks, Contacts](#support)
2214

23-
set GOPATH
2415

25-
go get
26-
go run ./cbsd-mq-api [ -l listen]
16+
## Description
2717

18+
Provides a simplified API for creating and destroying CBSD virtual environments.
2819

29-
# Install
20+
## Installation
3021

31-
mkdir -p /var/db/cbsd-api /usr/jails/var/db/api/map
32-
chown -R cbsd:cbsd /var/db/cbsd-api /usr/jails/var/db/api/map
22+
Assuming you have a stock vanilla FreeBSD 13.0+ installation.
23+
The directives below configure a standalone installation ( single API + hoster env),
24+
however you can use any number of physical nodes for single API.
3325

34-
Install api.d module + enable in modules.conf, cbsd initenv.
26+
1) Install packages:
27+
```
28+
pkg install -y cbsd cbsd-mq-router cbsd-mq-api beanstalkd git
29+
```
3530

36-
Setup api.d module: make sure
31+
2) Configure beanstalkd service:
32+
```
33+
sysrc beanstalkd_flags="-l 127.0.0.1 -p 11300"
34+
service beanstalkd enable
35+
service beanstalkd restart
36+
```
3737

38-
"recomendation": "/usr/local/cbsd/modules/api.d/misc/recomendation.sh",
39-
"freejname": "/usr/local/cbsd/modules/api.d/misc/freejname.sh",
38+
3) Configure CBSD as usual
39+
```
40+
env workdir=/usr/jails /usr/local/cbsd/sudoexec/initenv
41+
```
4042

41-
script works (from cbsd user): chown cbsd:cbsd ~cbsd/etc/api.conf
43+
4) Configure MQ router
4244

43-
# On host
45+
First, get hoster FQDN via `hostname` command.
46+
Let's say your host has a name: apitest.my.domain
4447

45-
1) pkg install -y sysutils/cbsd-mq-router
48+
Open /usr/local/etc/cbsd-mq-router.json in any favorite editor and change
49+
"tube" and "reply_tube_prefix" ( cbsd_<hostname_without_dot> and cbsd_<hostname_without_dot>_result_id, e.g::
4650

47-
2) setup cbsd-mq-router.json, e.g:
4851

4952
```
5053
{
@@ -54,18 +57,68 @@ script works (from cbsd user): chown cbsd:cbsd ~cbsd/etc/api.conf
5457
"logfile": "/dev/stdout",
5558
"beanstalkd": {
5659
"uri": "127.0.0.1:11300",
57-
"tube": "cbsd_host1_example_com",
58-
"reply_tube_prefix": "cbsd_host1_example_com_result_id",
60+
"tube": "cbsd_apitest_my_domain",
61+
"reply_tube_prefix": "cbsd_cbsd_apitest_my_domain_result_id",
5962
"reconnect_timeout": 5,
6063
"reserve_timeout": 5,
6164
"publish_timeout": 5,
62-
"logdir": "/var/log/cloudmq"
65+
"logdir": "/var/log/cbsdmq"
6366
}
6467
}
6568
```
6669

67-
3) service cbsd-mq-router enable
68-
4) service cbsd-mq-router start
70+
## Usage
71+
72+
5) Start MQ router:
73+
```
74+
service cbsd-mq-router enable
75+
service cbsd-mq-router start
76+
```
77+
78+
6) Install CBSD API module:
79+
```
80+
cbsd module mode=install api
81+
echo 'api.d' >> ~cbsd/etc/modules.conf
82+
cbsd initenv
83+
```
84+
85+
7) Configure CBSD API module:
86+
```
87+
cp -a /usr/local/cbsd/modules/api.d/etc/api.conf ~cbsd/etc/
88+
cp -a /usr/local/cbsd/modules/api.d/etc/bhyve-api.conf ~cbsd/etc/
89+
cp -a /usr/local/cbsd/modules/api.d/etc/jail-api.conf ~cbsd/etc/
90+
```
91+
92+
Open ~cbsd/etc/api.conf in any favorite editor and set "server_list=" to FQDN, e.g:
93+
```
94+
...
95+
server_list="apitest.my.domain"
96+
...
97+
```
98+
99+
Set 'cbsd' user permission to ~cbsd/etc/api.conf:
100+
```
101+
chown cbsd:cbsd ~cbsd/etc/api.conf
102+
```
103+
104+
Here you can check that the API module scripts works:
105+
```
106+
su -m cbsd -c '/usr/local/cbsd/modules/api.d/misc/recomendation.sh'
107+
```
108+
must return the host from server_list ( apitest.my.domain )
109+
110+
```
111+
su -m cbsd -c '/usr/local/cbsd/modules/api.d/misc/freejname.sh'
112+
```
113+
must return the unique name 'envX'.
114+
115+
8) Configure RestAPI daemon:
116+
```
117+
mkdir -p /var/db/cbsd-api /usr/jails/var/db/api/map
118+
chown -R cbsd:cbsd /var/db/cbsd-api /usr/jails/var/db/api/map
119+
service cbsd-mq-api enable
120+
service cbsd-mq-api start
121+
```
69122

70123
## Usage
71124

@@ -79,6 +132,31 @@ curl -H "cid:<cid>" http://127.0.0.1:65531/api/v1/stop/<env>
79132
curl -H "cid:<cid>" http://127.0.0.1:65531/api/v1/destroy/<env>
80133
```
81134

135+
To test, lets create simple CBSDfile, where CLOUD_KEY - is your publickey string:
136+
```
137+
CLOUD_URL="http://127.0.0.1:65531"
138+
CLOUD_KEY="ssh-ed25519 AAAA..XXX your@localhost"
139+
140+
jail_minio1()
141+
{
142+
imgsize="10g"
143+
pkg_bootstrap=0
144+
}
145+
```
146+
147+
Run:
148+
```
149+
sudo cbsd up
150+
```
151+
152+
After jail start you can use:
153+
```
154+
cbsd jlogin
155+
cbsd destroy
156+
```
157+
158+
See documentation for detailed information.
159+
82160
## Contributing
83161

84162
* Fork me on GitHub: [https://github.com/cbsd/cbsd-mq-api.git](https://github.com/cbsd/cbsd-mq-api.git)

0 commit comments

Comments
 (0)