README.md 2.54 KB
Newer Older
1 2
# beiran poc

Furkan Mustafa's avatar
Furkan Mustafa committed
3
![Build Status](https://drone.rsnc.io/api/badges/rlab/beiran/status.svg)
4 5 6

## What is beiran

7 8
- [Draft Spec](Draft-Spec.md)
- [Roadmap](ROADMAP.md)
9

Furkan Mustafa's avatar
Furkan Mustafa committed
10 11
## Python libraries and tools

12 13 14 15 16 17
- [asyncio](https://docs.python.org/3/library/asyncio.html) (event loop)
- [tornado](https://www.tornadoweb.org) (http and network library)
- [pytest](https://pytest.org) (testing)
- [docker](https://github.com/docker/docker-py) (for querying docker daemon)
- [zeroconf](https://pypi.python.org/pypi/zeroconf) (for local node discovery)
- [click](https://pypi.python.org/pypi/click) (for cli options, commands)
Furkan Mustafa's avatar
Furkan Mustafa committed
18

19
## Docker Settings
Shota Nakamura's avatar
Shota Nakamura committed
20 21 22

### Install Docker

23
beiran is run on the machine on which Docker is installed.
Shota Nakamura's avatar
Shota Nakamura committed
24 25 26 27 28 29

### Change Storage Driver

You need to use `overlay2`. Stop your Docker daemon.

```sh
30
$ systemctl stop docker.service
Shota Nakamura's avatar
Shota Nakamura committed
31 32
```

33
Edit Systemd Service File. (/lib/systemd/system/docker.service)
Shota Nakamura's avatar
Shota Nakamura committed
34

35
```bash
Shota Nakamura's avatar
Shota Nakamura committed
36 37 38
ExecStart=/usr/bin/dockerd -H fd:// -s overlay2
```

39
Start Docker daemon.
Shota Nakamura's avatar
Shota Nakamura committed
40 41

```sh
42
$ systemctl daemon-reload
43
$ systemctl start docker.service
Shota Nakamura's avatar
Shota Nakamura committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
```

Check your Storage Driver.

```sh
$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.03.2-ce
Storage Driver: overlay2
...
```

60 61 62 63 64
### Install tar-split

beiran's docker plugin needs [tar-split](https://github.com/vbatts/tar-split) now. Please create the binary file and set `tar_split_path`;

```
65
$ go get -u github.com/vbatts/tar-split/cmd/tar-split
66 67 68 69 70 71 72 73 74 75 76
$ export BEIRAN_PACKAGE_DOCKER_CONFIG='tar_split_path=path/to/tar-split'
```

Or, copy the binary file to the plugin directory (deafult `tar-split_path` is there)

```
$ go get github.com/vbatts/tar-split
$ cp path/to/tar-split plugins/beiran_package_docker/
```


77 78
## Virtualenv

79
### - Setup
80

81 82
This will setup a virtualenv under `env` folder here

83
```sh
84
$ ./dev.sh
85 86 87 88
```

#### - Settings (Environment Variables)

89
```sh
90 91
export BEIRAN_LOG_LEVEL=DEBUG
export BEIRAN_LOG_FILE=$(pwd)/beirand.log
92 93
export BEIRAN_SOCKET_FILE=$(pwd)/beirand.sock
export BEIRAN_DB_FILE=$(pwd)/beiran.db
94
export BEIRAN_CONFIG_DIR=$(pwd)
95 96 97 98
```

#### - Start Daemon

99
```sh
100 101
./dev.sh
beirand
102 103
```

104 105 106
or as root (potentially UNSAFE) to allow beiran to peek into /var/lib/docker

```sh
107 108
./dev.sh
sudo -E beirand
109 110
```

111 112
#### - Use cli

113
```sh
114
beiran image list
115 116
```

117 118
## Build

119
```sh
120
docker-compose build
121
```
Furkan Mustafa's avatar
Furkan Mustafa committed
122

123 124 125 126
## Environment variables

All has default values.

127
```
128 129
BEIRAN_LISTEN_INTERFACE
BEIRAN_LISTEN_ADDRESS
130
BEIRAN_HOSTNAME
131
BEIRAN_SOCKET_FILE
132 133
```

134 135
## Using (PoC)

136
```sh
137
docker-compose up
138
```
Furkan Mustafa's avatar
Furkan Mustafa committed
139 140 141

CURL'ing unix socket

142
```sh
Furkan Mustafa's avatar
Furkan Mustafa committed
143 144
curl --no-buffer -XGET --unix-socket /var/run/beirand.sock http://localhost/events
```