nutkins 0.10.3 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nutkins/version.rb +1 -1
- data/lib/nutkins.rb +9 -5
- data/readme.md +169 -0
- metadata +3 -3
- data/README.md +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52cf42f9bda34623d363c0949b12a37820f19ee6
|
4
|
+
data.tar.gz: 81197095413f31fac40a8e43b9e04dff878d824b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b76082e30b1f978daed27171a39039017754c894f34795f40b15b2d1602bb6676247b42318abda039c4b473868307402264158381e0c38daf23089ed882c4c3d
|
7
|
+
data.tar.gz: 3958e780eb1148ba2a9e879848bcfca8f87f99c783a2d05495f4d5272df82bdd7fb366576e2eb65422a18da2eaaf9e0b09e820a0309a3a4b7a9932b279814305
|
data/lib/nutkins/version.rb
CHANGED
data/lib/nutkins.rb
CHANGED
@@ -30,6 +30,7 @@ module Nutkins
|
|
30
30
|
@img_configs = {}
|
31
31
|
# when an image is built true is stored against it's name to avoid building it again
|
32
32
|
@built = {}
|
33
|
+
@etcd_running = false
|
33
34
|
@project_root = project_dir || Dir.pwd
|
34
35
|
cfg_path = File.join(@project_root, CONFIG_FILE_NAME)
|
35
36
|
if File.exists? cfg_path
|
@@ -153,6 +154,8 @@ module Nutkins
|
|
153
154
|
def run path, reuse: false, shell: false
|
154
155
|
cfg = get_image_config path
|
155
156
|
tag = cfg['tag']
|
157
|
+
|
158
|
+
start_etcd_container if cfg['etcd']
|
156
159
|
create_args = []
|
157
160
|
if shell
|
158
161
|
raise '--shell and --reuse arguments are incompatible' if reuse
|
@@ -237,11 +240,14 @@ module Nutkins
|
|
237
240
|
puts "TODO: exec #{path}: #{cmd.join ' '}"
|
238
241
|
end
|
239
242
|
|
240
|
-
# TODO: move this stuff into another file
|
241
243
|
def start_etcd_container
|
244
|
+
return if @etcd_running
|
245
|
+
# TODO: move this stuff into another file
|
242
246
|
name = get_etcd_container_name
|
243
247
|
return unless name
|
244
248
|
|
249
|
+
# TODO: update existing etcd server rather than creating new container...
|
250
|
+
# this will let confd instances respond to updates
|
245
251
|
existing = Docker.container_id_for_name name
|
246
252
|
if existing
|
247
253
|
Docker.run 'stop', name
|
@@ -298,6 +304,7 @@ module Nutkins
|
|
298
304
|
puts res
|
299
305
|
end
|
300
306
|
end
|
307
|
+
@etcd_running = true
|
301
308
|
else
|
302
309
|
puts 'failed to start etcd container'
|
303
310
|
end
|
@@ -319,10 +326,7 @@ module Nutkins
|
|
319
326
|
end
|
320
327
|
|
321
328
|
private
|
322
|
-
def get_etcd_container_name
|
323
|
-
repository = @config.repository
|
324
|
-
repository && "nutkins-etcd-#{repository}"
|
325
|
-
end
|
329
|
+
def get_etcd_container_name; "nutkins-etcd"; end
|
326
330
|
|
327
331
|
# path should be "." or a single element path referencing the project root
|
328
332
|
def get_image_config path
|
data/readme.md
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
# Nutkins
|
2
|
+
|
3
|
+
[![build status](https://circleci.com/gh/ohjames/nutkins.png)](https://circleci.com/gh/ohjames/nutkins)
|
4
|
+
|
5
|
+
nutkins provides a way to build and test clusters based on one or more containers.
|
6
|
+
* A easier and more flexible way to build docker images than `Dockerfile`.
|
7
|
+
* Can run multiple commands to build a layer with comments for each.
|
8
|
+
* No need for `.dockerignore`.
|
9
|
+
* Caches each command in a layer and rebuilds from cache in a fraction of a second.
|
10
|
+
* Test services that use multiple containers without having to use VMs.
|
11
|
+
* Support for etcd/environment variables and confd.
|
12
|
+
* nutkins can manage a local etcd server and its data to test confd configurations.
|
13
|
+
* nutkins can manage a confd configuration using a sensible convention-over-configuration approach.
|
14
|
+
* Manages secrets encrypted with gpg.
|
15
|
+
|
16
|
+
nutkins works great with:
|
17
|
+
* [etcd](https://github.com/coreos/etcd) - a distributed key-value data store.
|
18
|
+
* [confd](https://github.com/kelseyhightower/confd) - a system for building configuration files from data stored using `etcd` (and other data stores).
|
19
|
+
* [smell-baron](https://github.com/ohjames/smell-baron) - an init system for docker containers
|
20
|
+
|
21
|
+
## installation
|
22
|
+
|
23
|
+
```bash
|
24
|
+
gem install nutkins
|
25
|
+
```
|
26
|
+
|
27
|
+
## configuring nutkins
|
28
|
+
|
29
|
+
### The project root
|
30
|
+
|
31
|
+
In the project root there should be a `nutkins.yaml` which may contain global configuration:
|
32
|
+
|
33
|
+
```yaml
|
34
|
+
version: 0.0.1
|
35
|
+
repository: myorg
|
36
|
+
```
|
37
|
+
|
38
|
+
With this configuration each built image will be tagged `myorg/${image_name}:0.0.1` where `0.0.1` may also be overridden per image.
|
39
|
+
|
40
|
+
For projects that consist of a single `nutkin.yaml` in the project root then `nutkins.yaml` may be omitted and these fields should be present in the `nutkin.yaml`.
|
41
|
+
|
42
|
+
### Images
|
43
|
+
|
44
|
+
Each subdirectory in the project root that contains a file `nutkin.yaml` is used to build a docker image. The following project contains an image in a subdirectory `base` that extends the `ubuntu:16.04` container hosted on docker hub:
|
45
|
+
|
46
|
+
```yaml
|
47
|
+
base: ubuntu:16.04
|
48
|
+
|
49
|
+
build:
|
50
|
+
resources:
|
51
|
+
-
|
52
|
+
source: https://github.com/ohjames/smell-baron/releases/download/v0.3.1/smell-baron
|
53
|
+
dest: bin/smell-baron
|
54
|
+
mode: 0755
|
55
|
+
-
|
56
|
+
source: https://github.com/kelseyhightower/confd/releases/download/v0.12.0-alpha3/confd-0.12.0-alpha3-linux-amd64
|
57
|
+
dest: bin/confd
|
58
|
+
mode: 0755
|
59
|
+
-
|
60
|
+
source: https://github.com/coreos/etcd/releases/download/v3.0.6/etcd-v3.0.6-linux-amd64.tar.gz
|
61
|
+
extract: "*/etcdctl"
|
62
|
+
dest: bin/etcdctl
|
63
|
+
mode: 0755
|
64
|
+
commands:
|
65
|
+
- run:
|
66
|
+
- apt-get update
|
67
|
+
- apt-get install -y vim zsh less nano rsync git net-tools
|
68
|
+
- groupadd -g 5496 sslcerts
|
69
|
+
- add: bin/* /bin/
|
70
|
+
- entrypoint: ["/bin/smell-baron"]
|
71
|
+
```
|
72
|
+
|
73
|
+
The `resources` section downloads files to local directories so that they can be used in the image. In the case of `confd` it also extracts a file from a `tar.gz` compressed archive.
|
74
|
+
|
75
|
+
The `commands` section is like a `Dockerfile` and is used to build a container. In this case it runs multiple commands, add some files to the image and sets an `entrypoint`. This image would be tagged `myorg/base:0.0.1`. The image name comes from the subdirectory but can be overriden along with the `version`:
|
76
|
+
|
77
|
+
```yaml
|
78
|
+
base: ubuntu:16.04
|
79
|
+
image: base_image
|
80
|
+
version: 0.0.2
|
81
|
+
build:
|
82
|
+
# ... as before
|
83
|
+
```
|
84
|
+
|
85
|
+
To build this image:
|
86
|
+
```bash
|
87
|
+
nutkins build base
|
88
|
+
```
|
89
|
+
|
90
|
+
This will output various information as it builds the image. If the same command is run again it will reuse data from the cache, exiting in less than a second:
|
91
|
+
|
92
|
+
```bash
|
93
|
+
% nutkins build base
|
94
|
+
cached: apt-get update && apt-get install -y vim zsh less nano rsync git net-tools && groupadd -g 5496 sslcerts
|
95
|
+
cached: #(nop) add bin/confd:33472f6b8f9522ec7bdb01a8feeb03fb bin/etcdctl:8edfaac7c726e8231c6e0e8f75ffb678 bin/smell-baron:909345dcbc4a029d42f39278486a32b9 /bin/
|
96
|
+
cached: #(nop) entrypoint ["/bin/smell-baron"]
|
97
|
+
unchanged image: myorg/base:0.0.1
|
98
|
+
```
|
99
|
+
|
100
|
+
To run a container from this image (this first rebuilds the image):
|
101
|
+
```bash
|
102
|
+
nutkins run base
|
103
|
+
```
|
104
|
+
|
105
|
+
To run a container from this image and open an interactive shell (this only works if the `entrypoint` is [smell-baron](https://github.com/ohjames/smell-baron)):
|
106
|
+
```bash
|
107
|
+
nutkins run -s base
|
108
|
+
```
|
109
|
+
|
110
|
+
### Image project dependencies
|
111
|
+
|
112
|
+
When a `nutkin.yaml` file refers to a `base` image that exists in the current project then `nutkins` ensures the base image is up to date before any images are built that use or extend it.
|
113
|
+
|
114
|
+
### Sharing local data with images
|
115
|
+
|
116
|
+
When using `nutkins` to test images it can be useful to share data in the host system with the running containers:
|
117
|
+
|
118
|
+
```yaml
|
119
|
+
base: base
|
120
|
+
|
121
|
+
build:
|
122
|
+
commands:
|
123
|
+
# ... build commands go here
|
124
|
+
create:
|
125
|
+
volumes:
|
126
|
+
- ssl -> /etc/ssl
|
127
|
+
- ejabberd-etc -> /tmp/ejabberd-etc
|
128
|
+
- ejabberd-var -> /var/lib/ejabberd
|
129
|
+
```
|
130
|
+
|
131
|
+
If `nutkins.yaml` is in the directory `subdir` the volume `ssl` will be searched for first in `subdir/volumes/ssl` and then `volumes/ssl`.
|
132
|
+
|
133
|
+
### Sharing ports with the host operating system
|
134
|
+
|
135
|
+
```yaml
|
136
|
+
create:
|
137
|
+
ports:
|
138
|
+
- 5222
|
139
|
+
- 5269
|
140
|
+
```
|
141
|
+
|
142
|
+
### Testing images configured with etcd
|
143
|
+
|
144
|
+
The following `nutkin.yaml` shows how to manage a local `etcd` cluster:
|
145
|
+
|
146
|
+
```yaml
|
147
|
+
base: base
|
148
|
+
|
149
|
+
build:
|
150
|
+
commands:
|
151
|
+
# ... as before
|
152
|
+
create:
|
153
|
+
# ... as before
|
154
|
+
etcd:
|
155
|
+
data:
|
156
|
+
ejabberd/node_name: ejabberd@myhost
|
157
|
+
ejabberd/hostname: myhost.net
|
158
|
+
ejabberd/muc_host: c.@HOST@
|
159
|
+
```
|
160
|
+
|
161
|
+
When running a container that has etcd data `nutkins` will first start up a helper container running `etcd` and use it to serve the etcd data from every `nutkin.yaml` in the project. To access this `etcd` data from within the container:
|
162
|
+
|
163
|
+
```bash
|
164
|
+
etcd2_host=$(ip route | grep '^default' | cut -d' ' -f3)
|
165
|
+
# use confd to build the configuration files from the data stored in etcd
|
166
|
+
confd -onetime -backend etcd -node http://$etcd_host:2379
|
167
|
+
```
|
168
|
+
|
169
|
+
The same command will work within a CoreOS cluster or any other etcd backed cluster.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nutkins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Pike
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,7 +78,6 @@ files:
|
|
78
78
|
- ".rspec"
|
79
79
|
- ".travis.yml"
|
80
80
|
- Gemfile
|
81
|
-
- README.md
|
82
81
|
- Rakefile
|
83
82
|
- bin/console
|
84
83
|
- bin/nutkins
|
@@ -91,6 +90,7 @@ files:
|
|
91
90
|
- lib/nutkins/download.rb
|
92
91
|
- lib/nutkins/version.rb
|
93
92
|
- nutkins.gemspec
|
93
|
+
- readme.md
|
94
94
|
homepage: http://github.com/ohjames/nutkins
|
95
95
|
licenses: []
|
96
96
|
metadata:
|
data/README.md
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# Nutkins
|
2
|
-
|
3
|
-
[![build status](https://circleci.com/gh/ohjames/nutkins.png)](https://circleci.com/gh/ohjames/nutkins)
|
4
|
-
|
5
|
-
Nutkins is a tool to help build and test multiple docker containers configured via etcd and confd. You can:
|
6
|
-
* Describe test volumes and etcd variables using yaml.
|
7
|
-
* Easily rebuild and test containers with a few simple commands.
|