centurion 1.9.2 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/centurion/service.rb +5 -5
- data/lib/centurion/version.rb +1 -1
- data/spec/service_spec.rb +43 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0e77b37bcb7efd62a50dd92c69364667c196592
|
4
|
+
data.tar.gz: e95dbfec1e39272cc02616dca556d809ead0ed43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 952974644249e8f679725f253469168a1ae54843a110e7916bfcb75e06d0b694996c7a203da91914c3e6fd8e4848acbf0021917f9621b7cae7ad7cdb6039afc1
|
7
|
+
data.tar.gz: 48a37f571045722257bc4a026be4baa2788a274bf84c0470693b283100dcc4c182108fbcff85457270c59dafca1a6d1a6e986293ff6c6a447ec00a3317feb039
|
data/README.md
CHANGED
@@ -271,6 +271,17 @@ In `host` and `container...` network modes, you may specify a
|
|
271
271
|
for container health checks. The mapping itself, while still passed via the API,
|
272
272
|
will be ignored by Docker.
|
273
273
|
|
274
|
+
### PID modes
|
275
|
+
|
276
|
+
You may specify the PID mode you would like a container to use via:
|
277
|
+
|
278
|
+
```ruby
|
279
|
+
set :pid_mode, 'pidmode'
|
280
|
+
```
|
281
|
+
|
282
|
+
Docker (and therefore Centurion) supports one of nothing (the default), `host`,
|
283
|
+
and `container:<container-id>` for this argument.
|
284
|
+
|
274
285
|
### CGroup Resource Constraints
|
275
286
|
|
276
287
|
Limits on memory and CPU can be specified with the `memory` and `cpu_shares`
|
data/lib/centurion/service.rb
CHANGED
@@ -5,7 +5,7 @@ module Centurion
|
|
5
5
|
class Service
|
6
6
|
extend ::Capistrano::DSL
|
7
7
|
|
8
|
-
attr_accessor :command, :dns, :extra_hosts, :image, :name, :volumes, :port_bindings, :network_mode, :cap_adds, :cap_drops, :ipc_mode, :security_opt
|
8
|
+
attr_accessor :command, :dns, :extra_hosts, :image, :name, :volumes, :port_bindings, :network_mode, :pid_mode, :cap_adds, :cap_drops, :ipc_mode, :security_opt
|
9
9
|
attr_reader :memory, :cpu_shares, :env_vars, :labels
|
10
10
|
|
11
11
|
def initialize(name)
|
@@ -35,6 +35,7 @@ module Centurion
|
|
35
35
|
s.volumes = fetch(:binds, [])
|
36
36
|
s.port_bindings = fetch(:port_bindings, [])
|
37
37
|
s.network_mode = fetch(:network_mode, 'bridge')
|
38
|
+
s.pid_mode = fetch(:pid_mode, nil)
|
38
39
|
s.command = fetch(:command, nil)
|
39
40
|
s.memory = fetch(:memory, 0)
|
40
41
|
s.cpu_shares = fetch(:cpu_shares, 0)
|
@@ -76,10 +77,6 @@ module Centurion
|
|
76
77
|
@cap_drops = capabilites
|
77
78
|
end
|
78
79
|
|
79
|
-
def network_mode=(mode)
|
80
|
-
@network_mode = mode
|
81
|
-
end
|
82
|
-
|
83
80
|
def memory=(bytes)
|
84
81
|
if !bytes || !is_a_uint64?(bytes)
|
85
82
|
raise ArgumentError, "invalid value for cgroup memory constraint: #{bytes}, value must be a between 0 and 18446744073709551615"
|
@@ -159,6 +156,9 @@ module Centurion
|
|
159
156
|
# Set the network mode
|
160
157
|
host_config['NetworkMode'] = network_mode
|
161
158
|
|
159
|
+
# Set the pid mode if specified
|
160
|
+
host_config['PidMode'] = pid_mode if pid_mode
|
161
|
+
|
162
162
|
# DNS if specified
|
163
163
|
host_config['Dns'] = dns if dns
|
164
164
|
|
data/lib/centurion/version.rb
CHANGED
data/spec/service_spec.rb
CHANGED
@@ -18,6 +18,8 @@ describe Centurion::Service do
|
|
18
18
|
set(:port_bindings, [ Centurion::Service::PortBinding.new(12340, 80, 'tcp') ])
|
19
19
|
set(:labels, labels)
|
20
20
|
set(:security_opt, ['seccomp=unconfined'])
|
21
|
+
set(:network_mode, 'host')
|
22
|
+
set(:pid_mode, 'host')
|
21
23
|
|
22
24
|
svc = Centurion::Service.from_env
|
23
25
|
expect(svc.name).to eq('mycontainer')
|
@@ -29,6 +31,8 @@ describe Centurion::Service do
|
|
29
31
|
expect(svc.port_bindings.first.container_port).to eq(80)
|
30
32
|
expect(svc.labels).to eq(labels)
|
31
33
|
expect(svc.security_opt).to eq(['seccomp=unconfined'])
|
34
|
+
expect(svc.network_mode).to eq('host')
|
35
|
+
expect(svc.pid_mode).to eq('host')
|
32
36
|
end
|
33
37
|
|
34
38
|
it 'starts with a command' do
|
@@ -64,6 +68,14 @@ describe Centurion::Service do
|
|
64
68
|
expect(service.dns).to eq('redis.example.com')
|
65
69
|
end
|
66
70
|
|
71
|
+
it 'has a default network mode' do
|
72
|
+
expect(service.network_mode).to eq('bridge')
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'has no default pid mode' do
|
76
|
+
expect(service.pid_mode).to be(nil)
|
77
|
+
end
|
78
|
+
|
67
79
|
it 'boots from a docker image' do
|
68
80
|
service.image = 'registry.hub.docker.com/library/redis'
|
69
81
|
expect(service.image).to eq('registry.hub.docker.com/library/redis')
|
@@ -309,4 +321,35 @@ describe Centurion::Service do
|
|
309
321
|
})
|
310
322
|
end
|
311
323
|
|
324
|
+
it 'builds docker configuration for container-linked pids' do
|
325
|
+
service.pid_mode = 'container:a2e8937b'
|
326
|
+
expect(service.build_host_config(Centurion::Service::RestartPolicy.new('on-failure', 50))).to eq({
|
327
|
+
'Binds' => [],
|
328
|
+
'CapAdd' => [],
|
329
|
+
'CapDrop' => [],
|
330
|
+
'NetworkMode' => 'bridge',
|
331
|
+
'PidMode' => 'container:a2e8937b',
|
332
|
+
'PortBindings' => {},
|
333
|
+
'RestartPolicy' => {
|
334
|
+
'Name' => 'on-failure',
|
335
|
+
'MaximumRetryCount' => 50
|
336
|
+
}
|
337
|
+
})
|
338
|
+
end
|
339
|
+
|
340
|
+
it 'builds docker configuration for host pids' do
|
341
|
+
service.pid_mode = 'host'
|
342
|
+
expect(service.build_host_config(Centurion::Service::RestartPolicy.new('on-failure', 50))).to eq({
|
343
|
+
'Binds' => [],
|
344
|
+
'CapAdd' => [],
|
345
|
+
'CapDrop' => [],
|
346
|
+
'NetworkMode' => 'bridge',
|
347
|
+
'PidMode' => 'host',
|
348
|
+
'PortBindings' => {},
|
349
|
+
'RestartPolicy' => {
|
350
|
+
'Name' => 'on-failure',
|
351
|
+
'MaximumRetryCount' => 50
|
352
|
+
}
|
353
|
+
})
|
354
|
+
end
|
312
355
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: centurion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nic Benders
|
@@ -21,7 +21,7 @@ authors:
|
|
21
21
|
autorequire:
|
22
22
|
bindir: bin
|
23
23
|
cert_chain: []
|
24
|
-
date: 2018-
|
24
|
+
date: 2018-10-12 00:00:00.000000000 Z
|
25
25
|
dependencies:
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: trollop
|
@@ -291,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
291
|
version: '0'
|
292
292
|
requirements: []
|
293
293
|
rubyforge_project:
|
294
|
-
rubygems_version: 2.
|
294
|
+
rubygems_version: 2.5.2.3
|
295
295
|
signing_key:
|
296
296
|
specification_version: 4
|
297
297
|
summary: A deployment tool for Docker. Takes containers from a Docker registry and
|