@@ -4,47 +4,50 @@ Copyright (c) 2013-2021, The CBSD Development Team
4
4
5
5
Homepage: https://bsdstore.ru
6
6
7
- ## Description
8
-
9
- Provides a simplified API for creating and destroying CBSD virtual environments.
10
-
11
7
#### Table of Contents
12
8
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 )
22
14
23
- set GOPATH
24
15
25
- go get
26
- go run ./cbsd-mq-api [ -l listen]
16
+ ## Description
27
17
18
+ Provides a simplified API for creating and destroying CBSD virtual environments.
28
19
29
- # Install
20
+ ## Installation
30
21
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.
33
25
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
+ ```
35
30
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
+ ```
37
37
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
+ ```
40
42
41
- script works (from cbsd user): chown cbsd : cbsd ~ cbsd/etc/api.conf
43
+ 4 ) Configure MQ router
42
44
43
- # On host
45
+ First, get hoster FQDN via ` hostname ` command.
46
+ Let's say your host has a name: apitest.my.domain
44
47
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::
46
50
47
- 2 ) setup cbsd-mq-router.json, e.g:
48
51
49
52
```
50
53
{
@@ -54,18 +57,68 @@ script works (from cbsd user): chown cbsd:cbsd ~cbsd/etc/api.conf
54
57
"logfile": "/dev/stdout",
55
58
"beanstalkd": {
56
59
"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 ",
59
62
"reconnect_timeout": 5,
60
63
"reserve_timeout": 5,
61
64
"publish_timeout": 5,
62
- "logdir": "/var/log/cloudmq "
65
+ "logdir": "/var/log/cbsdmq "
63
66
}
64
67
}
65
68
```
66
69
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
+ ```
69
122
70
123
## Usage
71
124
@@ -79,6 +132,31 @@ curl -H "cid:<cid>" http://127.0.0.1:65531/api/v1/stop/<env>
79
132
curl -H "cid:<cid>" http://127.0.0.1:65531/api/v1/destroy/<env>
80
133
```
81
134
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
+
82
160
## Contributing
83
161
84
162
* Fork me on GitHub: [ https://github.com/cbsd/cbsd-mq-api.git ] ( https://github.com/cbsd/cbsd-mq-api.git )
0 commit comments