Skip to content

Commit 306aff6

Browse files
author
Alan Moran and Maria Shaldibina
committed
Merge branch 'doc'
Conflicts: warden/README.md
2 parents 413297a + d46d0ab commit 306aff6

File tree

3 files changed

+159
-100
lines changed

3 files changed

+159
-100
lines changed

warden/README.md

Lines changed: 47 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -14,54 +14,8 @@ network access. As of writing, the only supported OS is Linux.
1414

1515
## Getting Started
1616

17-
This short guide assumes Ruby 1.9 and Bundler are already available. Ensure that
18-
Ruby 1.9 has GNU readline library support through the package: 'libreadline-dev'
19-
and zlib support through the 'zlib1g-dev' package.
20-
21-
#### Install the right kernel
22-
23-
If you are running Ubuntu 10.04 (Lucid), make sure the backported Natty
24-
kernel is installed. After installing, reboot the system before
25-
continuing.
26-
27-
```
28-
sudo apt-get install -y linux-image-generic-lts-backport-natty
29-
```
30-
31-
#### Install dependencies
32-
33-
```
34-
sudo apt-get install -y build-essential debootstrap quota
35-
```
36-
37-
#### Setup Warden
38-
39-
Run the setup routine, which compiles the C code bundled with Warden and
40-
sets up the base file system for Linux containers.
41-
42-
```
43-
sudo bundle exec rake setup[config/linux.yml]
44-
```
45-
46-
**NOTE**:
47-
If `sudo` complains that `bundle` cannot be found, try `sudo
48-
env PATH=$PATH` to pass your current `PATH` to the `sudo` environment.
49-
50-
The setup routine sets up the file system for the containers at the directory
51-
path specified under the key: server -> container_rootfs_path in the
52-
config file: config/linux.yml.
53-
54-
#### Run Warden
55-
56-
```
57-
sudo bundle exec rake warden:start[config/linux.yml]
58-
```
59-
60-
#### Interact with Warden
61-
62-
```
63-
bundle exec bin/warden
64-
```
17+
* [On Ubuntu Lucid (10.04)](doc/getting\_started.ubuntu.md)
18+
* [On CentOS 6](doc/getting\_started.centos.md)
6519

6620
## Implementation for Linux
6721

@@ -191,42 +145,51 @@ default. Every command invocation is formatted as a JSON array, where
191145
the first element is the command name and subsequent elements can be any
192146
JSON object. The commands it responds to are as follows:
193147

194-
`create [BIND_MOUNTS] [--grace_time TIME] [--handle NAME] [--rootfs ROOTFS] [--network IP]`
148+
### `create [CONFIG]`
195149

196150
Creates a new container.
197151

198152
Returns the handle of the container which is used to identify it.
199153

200-
`--bind_mounts[]`
154+
The optional `CONFIG` parameter is a hash that specifies configuration
155+
options used during container creation. The supported options are:
201156

202-
If supplied, this is an array of hashes specifying a set of paths to be
203-
bind mounted inside the container. The notation is as follows:
157+
#### `bind_mounts`
204158

205-
`--bind_mounts[0].field1=val1 --bind_mounts[0].field2=val2 ...`
159+
If supplied, this specifies a set of paths to be bind mounted inside the
160+
container. The value must be an array. The elements in this array
161+
specify the bind mounts to execute, and are executed in order. Every
162+
element must be of the form:
206163

207-
The three fields must be specified for each element of the array:
208-
209-
* `src_path`: Path in the host filesystem
210-
* `dst_path`: Path in the container
211-
* `mode`: Mount in read-only (`RO`) or read-write (`RW`).
164+
```
165+
[
166+
# Path in the host filesystem
167+
"/host/path",
168+
169+
# Path in the container
170+
"/path/in/container",
171+
172+
# Optional hash with options. The `mode` key specifies whether the bind
173+
# mount should be remounted as `ro` (read-only) or `rw` (read-write).
174+
{
175+
"mode" => "ro|rw"
176+
}
177+
]
178+
```
212179

213-
`--grace_time`
180+
#### `grace_time`
214181

215182
If specified, this setting overrides the default time of a container not
216183
being referenced by any client until it is destroyed. The value can
217184
either be the number of seconds as floating point number or integer, or
218185
the `null` value to completely disable the grace time.
219186

220-
`--handle NAME`
221-
222-
If specified, this setting overrides the name of the container, instead
223-
of randomly generating one.
187+
#### `disk_size_mb`
224188

225-
`--network IP`
189+
If specified, this setting overrides the default size of the container's
190+
scratch filesystem. The value is expected to be an integer number.
226191

227-
If specified, this setting specifies the external IP address of the container.
228-
229-
`spawn --handle HANDLE --script SCRIPT [OPTS]`
192+
### `spawn HANDLE SCRIPT [OPTS]`
230193

231194
Run the script `SCRIPT` in the container identified by `HANDLE`.
232195

@@ -237,11 +200,11 @@ may go away and reconnect later while still being able to reap the job.
237200
The optional `OPTS` parameter is a hash that specifies options modifying the
238201
command being run. The supported options are:
239202

240-
`privileged`
203+
#### `privileged`
241204

242205
If true, this specifies that the script should be run as root.
243206

244-
`link --handle HANDLE --job_id JOB_ID`
207+
### `link HANDLE JOB_ID`
245208

246209
Reap the script identified by `JOB_ID`, running in the container
247210
identified by `HANDLE`.
@@ -251,7 +214,7 @@ containing its `STDOUT` and a string containing its `STDERR`. These
251214
elements may be `null` when they cannot be determined (e.g. the
252215
script couldn't be executed, was killed, etc.).
253216

254-
`stream --handle HANDLE --job_id JOB_ID`
217+
### `stream HANDLE JOB_ID`
255218

256219
Stream `STDOUT` and `STDERR` of scripts identified by `JOB_ID`, running
257220
in the container identified by `HANDLE`.
@@ -261,32 +224,27 @@ or `STDERR` as the first element, and a chunk of the stream as the
261224
second element. Returns an empty tuple when no more data is available
262225
in the stream.
263226

264-
`limit_memory --handle HANDLE [--limit_in_bytes BYTES]`
265-
266-
Set or get memory limits for the container identified by `HANDLE`.
227+
### `limit HANDLE (mem) [VALUE]`
267228

268-
The memory limit is specified in number of bytes. It is enforced using
269-
the control group associated with the container. When a container
270-
exceeds this limit, one or more of its processes will be killed by the
271-
kernel. Additionally, the Warden will be notified that an OOM happened
272-
and it subsequently tears down the container.
229+
Set or get resource limits for the container identified by `HANDLE`.
273230

274-
`limit_disk --handle HANDLE`
231+
The following resources can be limited:
275232

276-
Set or get disk limits for the container identified by `HANDLE`.
233+
* The memory limit is specified in number of bytes. It is enforced using
234+
the control group associated with the container. When a container
235+
exceeds this limit, one or more of its processes will be killed by the
236+
kernel. Additionally, the Warden will be notified that an OOM happened
237+
and it subsequently tears down the container.
277238

278-
There are several ways to specify disk limits. See `limit_disk --help`
279-
for options.
280-
281-
`net_in --handle HANDLE [--host_port PORT] [--container_port PORT]`
239+
### `net HANDLE in`
282240

283241
Forward a port on the external interface of the host to the container
284242
identified by `HANDLE`.
285243

286244
Returns the port number that is mapped to the container. This port
287245
number is the same on the inside of the container.
288246

289-
`net_out --handle HANDLE [--network ADDRESS[/MASK]] [--port PORT]`
247+
### `net HANDLE out ADDRESS[/MASK][:PORT]`
290248

291249
Allow traffic from the container identified by `HANDLE` to the network
292250
address specified by `ADDRESS`. Additionally, the address may be masked
@@ -295,7 +253,7 @@ specific port.
295253

296254
Returns `ok`.
297255

298-
`copy_in --handle HANDLE --src_path SRC_PATH --dst_path DST_PATH`
256+
### `copy HANDLE in SRC_PATH DST_PATH`
299257

300258
Copy the contents at `SRC_PATH` on the host to `DST_PATH` in the
301259
container identified by `HANDLE`.
@@ -308,7 +266,7 @@ contents of the directory will be copied. Otherwise, the outermost
308266
directory, along with its contents, will be copied. The unprivileged
309267
user will be the owner of the files in the container.
310268

311-
`copy_out --handle HANDLE --src_path SRC_PATH --dst_path DST_PATH [--owner OWNER]`
269+
### `copy HANDLE out SRC_PATH DST_PATH [OWNER]`
312270

313271
Copy the contents at `SRC_PATH` in the container identified by `HANDLE`
314272
to `DST_PATH` on the host.
@@ -321,7 +279,7 @@ root. If the `OWNER` argument is supplied (in the form of `USER:GROUP`),
321279
files on the host will be chowned to this user/group after the copy has
322280
completed.
323281

324-
`stop --handle HANDLE [--background] [--kill]`
282+
### `stop HANDLE`
325283

326284
Stop processes running inside the container identified by `HANDLE`.
327285

@@ -330,7 +288,7 @@ Returns `ok`.
330288
Because all processes are taken down, unfinished scripts will likely
331289
terminate without an exit status being available.
332290

333-
`destroy --handle HANDLE`
291+
### `destroy HANDLE`
334292

335293
Stop processes and destroy all resources associated with the container
336294
identified `HANDLE`.
@@ -363,17 +321,6 @@ Other dependencies are:
363321

364322
Further bootstrapping of Warden can be done by running `rake setup`.
365323

366-
## Logs
367-
368-
Warden uses [steno](https://github.com/cloudfoundry/steno) for its logging. Here are some examples for each log level:
369-
370-
* `error` - a command has timed out or printed too much output
371-
* `warn` - a shell command sent to a container has failed
372-
* `info` - a container is being destroyed due to a timeout, warden displays how long a command
373-
took
374-
* `debug2` - a shell command sent to a container has succeeded, a timer has been set or stopped
375-
* `debug` - a snapshot has been taken, a container was created or destroyed normally
376-
377324
## Hacking
378325

379326
The included tests create and destroy real containers, so require system
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Getting started on CentOS 6
2+
3+
TBD.
4+
5+
## Install dependencies
6+
7+
```
8+
sudo yum install -y glibc-static
9+
...
10+
```
11+
12+
## Setup system
13+
14+
### SELinux
15+
16+
SELinux prevents warden from fully isolating a container's filesystem.
17+
To make warden work on CentOS, SELinux needs to be entirely disabled, by
18+
setting `SELINUX=disabled` in `/etc/selinux/config`.
19+
Alternatively, it is possible that some set of SELinux policies can make the
20+
combination work (this has not been confirmed to be possible).
21+
22+
### Networking
23+
24+
CentOS comes with a set of firewall rules that are too restrictive for warden
25+
to work out of the box.
26+
In particular, there is one rule that rejects all traffic in the `FORWARD`
27+
chain on the `filter` table.
28+
Traffic originating from containers goes through this chain and is rejected
29+
immediately.
30+
The entire set of firewall rules can be disabled by running
31+
`/etc/init.d/iptables stop`, or should be tweaked such that it doesn't collide
32+
with warden's networking requirements.
33+
34+
## Setup Warden
35+
36+
Run the setup routine, which compiles the C code bundled with Warden and
37+
sets up the base file system for Linux containers.
38+
39+
```
40+
sudo bundle exec rake setup[config/linux.yml]
41+
```
42+
43+
> If `sudo` complains that `bundle` cannot be found, try `sudo
44+
> env PATH=$PATH` to pass your current `PATH` to the `sudo` environment.
45+
46+
The setup routine sets up the file system for the containers at the directory
47+
path specified under the key: `server -> container_rootfs_path` in the
48+
config file: config/linux.yml.
49+
50+
## Run Warden
51+
52+
```
53+
sudo bundle exec rake warden:start[config/linux.yml]
54+
```
55+
56+
## Interact with Warden
57+
58+
```
59+
bundle exec bin/warden
60+
```
61+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Getting started on Ubuntu Lucid (10.04)
2+
3+
This short guide assumes Ruby 1.9 and Bundler are already available. Ensure that
4+
Ruby 1.9 has GNU readline library support through the package: 'libreadline-dev'
5+
and zlib support through the 'zlib1g-dev' package.
6+
7+
## Install the right kernel
8+
9+
If you are running Ubuntu 10.04 (Lucid), make sure the backported Natty
10+
kernel is installed. After installing, reboot the system before
11+
continuing.
12+
13+
```
14+
sudo apt-get install -y linux-image-generic-lts-backport-natty
15+
```
16+
17+
## Install dependencies
18+
19+
```
20+
sudo apt-get install -y build-essential
21+
sudo apt-get install -y debootstrap
22+
sudo apt-get install -y quota
23+
```
24+
25+
## Setup Warden
26+
27+
Run the setup routine, which compiles the C code bundled with Warden and
28+
sets up the base file system for Linux containers.
29+
30+
```
31+
sudo bundle exec rake setup[config/linux.yml]
32+
```
33+
34+
> If `sudo` complains that `bundle` cannot be found, try `sudo
35+
> env PATH=$PATH` to pass your current `PATH` to the `sudo` environment.
36+
37+
The setup routine sets up the file system for the containers at the directory
38+
path specified under the key: `server -> container_rootfs_path` in the
39+
config file: config/linux.yml.
40+
41+
## Run Warden
42+
43+
```
44+
sudo bundle exec rake warden:start[config/linux.yml]
45+
```
46+
47+
## Interact with Warden
48+
49+
```
50+
bundle exec bin/warden
51+
```

0 commit comments

Comments
 (0)