centurion 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +18 -0
- data/bin/centurion +5 -1
- data/lib/centurion/deploy.rb +4 -1
- data/lib/centurion/docker_registry.rb +5 -6
- data/lib/centurion/docker_via_api.rb +2 -2
- data/lib/centurion/docker_via_cli.rb +6 -5
- data/lib/centurion/version.rb +1 -1
- data/lib/tasks/deploy.rake +5 -1
- data/lib/tasks/list.rake +2 -2
- data/spec/deploy_spec.rb +7 -0
- data/spec/docker_via_api_spec.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -154,6 +154,24 @@ must respond with a valid response in the 200 status range.
|
|
154
154
|
$ bundle exec centurion -p radio-radio -e staging -a rolling_deploy
|
155
155
|
````
|
156
156
|
|
157
|
+
**Rolling Deployment Settings**:
|
158
|
+
You can change the following settings in your config to tune how the rolling
|
159
|
+
deployment behaves. Each of these is controlled with `set(:var_name, 'value')`.
|
160
|
+
These can be different for each environment or put into a common block if they
|
161
|
+
are the same everywhere. Settings are per-project.
|
162
|
+
|
163
|
+
* `rolling_deploy_check_interval` => Controls how long Centurion will wait after
|
164
|
+
seeing a container as up before moving on to the next one. This should be
|
165
|
+
slightly longer than your load balancer check interval. Value in seconds.
|
166
|
+
Defaults to 5 seconds.
|
167
|
+
* `rolling_deploy_wait_time` => The amount of time to wait between unsuccessful
|
168
|
+
health checks before retrying. Value in seconds. Defaults to 5 seconds.
|
169
|
+
* `rolling_deploy_retries` => The number of times to retry a health check on
|
170
|
+
the container once it is running. This count multiplied by the
|
171
|
+
`rolling_deployment_wait_time` is the total time Centurion will wait for
|
172
|
+
an individual container to come up before giving up as a failure. Defaults
|
173
|
+
to 24 attempts.
|
174
|
+
|
157
175
|
###Deploy a project to a fleet of Docker servers
|
158
176
|
|
159
177
|
This will hard stop, then start containers on all the specified hosts. This
|
data/bin/centurion
CHANGED
@@ -22,7 +22,7 @@ def possible_environments.to_s
|
|
22
22
|
end
|
23
23
|
|
24
24
|
#
|
25
|
-
#
|
25
|
+
# Trollop option setup
|
26
26
|
#
|
27
27
|
require 'trollop'
|
28
28
|
|
@@ -34,6 +34,7 @@ opts = Trollop::options do
|
|
34
34
|
opt :tag, 'tag (latest...)', type: String, required: false, short: '-t'
|
35
35
|
opt :hosts, 'hosts, comma separated', type: String, required: false, short: '-h'
|
36
36
|
opt :docker_path, 'path to docker executable (default: docker)', type: String, default: 'docker', short: '-d'
|
37
|
+
opt :no_pull, 'Skip the pull_image step', type: :flag, default: false, long: '--no-pull'
|
37
38
|
end
|
38
39
|
|
39
40
|
unless possible_environments.include?(opts[:environment])
|
@@ -63,8 +64,11 @@ set :hosts, opts[:hosts].split(",") if opts[:hosts]
|
|
63
64
|
|
64
65
|
# Default tag should be "latest"
|
65
66
|
set :tag, 'latest' unless any?(:tag)
|
67
|
+
set :docker_registry, 'https://registry.hub.docker.com/'
|
66
68
|
|
67
69
|
# Specify a path to docker executable
|
68
70
|
set :docker_path, opts[:docker_path]
|
69
71
|
|
72
|
+
set :no_pull, opts[:no_pull]
|
73
|
+
|
70
74
|
invoke(opts[:action])
|
data/lib/centurion/deploy.rb
CHANGED
@@ -94,7 +94,10 @@ module Centurion::Deploy
|
|
94
94
|
}
|
95
95
|
|
96
96
|
if port_bindings
|
97
|
-
container_config['ExposedPorts']
|
97
|
+
container_config['ExposedPorts'] ||= {}
|
98
|
+
port_bindings.keys.each do |port|
|
99
|
+
container_config['ExposedPorts'][port] = {}
|
100
|
+
end
|
98
101
|
end
|
99
102
|
|
100
103
|
if env_vars
|
@@ -5,12 +5,11 @@ require 'uri'
|
|
5
5
|
module Centurion; end
|
6
6
|
|
7
7
|
class Centurion::DockerRegistry
|
8
|
-
def initialize()
|
9
|
-
|
10
|
-
@base_uri = 'http://chi-docker-registry.nr-ops.net'
|
8
|
+
def initialize(base_uri)
|
9
|
+
@base_uri = base_uri
|
11
10
|
end
|
12
11
|
|
13
|
-
def digest_for_tag(
|
12
|
+
def digest_for_tag(repository, tag)
|
14
13
|
path = "/v1/repositories/#{repository}/tags/#{tag}"
|
15
14
|
$stderr.puts "GET: #{path.inspect}"
|
16
15
|
response = Excon.get(
|
@@ -25,8 +24,8 @@ class Centurion::DockerRegistry
|
|
25
24
|
JSON.load('[' + response.body + ']').first
|
26
25
|
end
|
27
26
|
|
28
|
-
def
|
29
|
-
path = "/v1/repositories/#{
|
27
|
+
def repository_tags(repository)
|
28
|
+
path = "/v1/repositories/#{repository}/tags"
|
30
29
|
$stderr.puts "GET: #{path.inspect}"
|
31
30
|
response = Excon.get(@base_uri + path)
|
32
31
|
raise response.inspect unless response.status == 200
|
@@ -34,7 +34,7 @@ class Centurion::DockerViaApi
|
|
34
34
|
|
35
35
|
def old_containers_for_port(host_port)
|
36
36
|
old_containers = ps(all: true).select do |container|
|
37
|
-
container["Status"] =~ /^Exit /
|
37
|
+
container["Status"] =~ /^(Exit |Exited)/
|
38
38
|
end.select do |container|
|
39
39
|
inspected = inspect_container container["Id"]
|
40
40
|
container_listening_on_port?(inspected, host_port)
|
@@ -104,7 +104,7 @@ class Centurion::DockerViaApi
|
|
104
104
|
port_bindings = container['HostConfig']['PortBindings']
|
105
105
|
return false unless port_bindings
|
106
106
|
|
107
|
-
port_bindings.values.flatten.any? do |port_binding|
|
107
|
+
port_bindings.values.flatten.compact.any? do |port_binding|
|
108
108
|
port_binding['HostPort'].to_i == port.to_i
|
109
109
|
end
|
110
110
|
end
|
@@ -52,10 +52,7 @@ class Centurion::DockerViaCli
|
|
52
52
|
end
|
53
53
|
|
54
54
|
output_thread.kill
|
55
|
-
|
56
|
-
unless $?.success?
|
57
|
-
raise "The command failed with a non-zero exit status: #{$?.exitstatus}"
|
58
|
-
end
|
55
|
+
validate_status(command)
|
59
56
|
end
|
60
57
|
|
61
58
|
def run_with_echo( command )
|
@@ -64,8 +61,12 @@ class Centurion::DockerViaCli
|
|
64
61
|
IO.popen(command) do |io|
|
65
62
|
io.each_char { |char| print char }
|
66
63
|
end
|
64
|
+
validate_status(command)
|
65
|
+
end
|
66
|
+
|
67
|
+
def validate_status(command)
|
67
68
|
unless $?.success?
|
68
|
-
raise "The command failed with a non-zero exit status: #{$?.exitstatus}"
|
69
|
+
raise "The command failed with a non-zero exit status: #{$?.exitstatus}. Command: '#{command}'"
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
data/lib/centurion/version.rb
CHANGED
data/lib/tasks/deploy.rake
CHANGED
@@ -103,7 +103,7 @@ namespace :deploy do
|
|
103
103
|
end
|
104
104
|
|
105
105
|
task :determine_image_id do
|
106
|
-
registry = Centurion::DockerRegistry.new()
|
106
|
+
registry = Centurion::DockerRegistry.new(fetch(:docker_registry))
|
107
107
|
exact_image = registry.digest_for_tag(fetch(:image), fetch(:tag))
|
108
108
|
set :image_id, exact_image
|
109
109
|
$stderr.puts "RESOLVED #{fetch(:image)}:#{fetch(:tag)} => #{exact_image[0..11]}"
|
@@ -120,6 +120,10 @@ namespace :deploy do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
task :pull_image do
|
123
|
+
if fetch(:no_pull)
|
124
|
+
info "--no-pull option specified: skipping pull"
|
125
|
+
next
|
126
|
+
end
|
123
127
|
$stderr.puts "Fetching image #{fetch(:image)}:#{fetch(:tag)} IN PARALLEL\n"
|
124
128
|
|
125
129
|
target_servers = Centurion::DockerServerGroup.new(fetch(:hosts), fetch(:docker_path))
|
data/lib/tasks/list.rake
CHANGED
@@ -24,8 +24,8 @@ namespace :list do
|
|
24
24
|
|
25
25
|
task :tags do
|
26
26
|
begin
|
27
|
-
registry = Centurion::DockerRegistry.new()
|
28
|
-
tags = registry.
|
27
|
+
registry = Centurion::DockerRegistry.new(fetch(:docker_registry))
|
28
|
+
tags = registry.repository_tags(fetch(:image))
|
29
29
|
tags.each do |tag|
|
30
30
|
puts "\t#{tag[0]}\t-> #{tag[1][0..11]}"
|
31
31
|
end
|
data/spec/deploy_spec.rb
CHANGED
@@ -166,6 +166,13 @@ describe Centurion::Deploy do
|
|
166
166
|
expect(config.keys).to match_array(%w{ Hostname Image Volumes VolumesFrom })
|
167
167
|
expect(config['Volumes']['/tmp/chaucer']).to eq({})
|
168
168
|
end
|
169
|
+
|
170
|
+
it "exposes all ports" do
|
171
|
+
config = test_deploy.container_config_for(server, 'image_id', {1234 => 80, 9876 => 80})
|
172
|
+
|
173
|
+
expect(config['ExposedPorts']).to be_a(Hash)
|
174
|
+
expect(config['ExposedPorts'].keys).to eq [1234, 9876]
|
175
|
+
end
|
169
176
|
end
|
170
177
|
|
171
178
|
describe '#start_new_container' do
|
data/spec/docker_via_api_spec.rb
CHANGED
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.0.
|
4
|
+
version: 1.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -21,7 +21,7 @@ authors:
|
|
21
21
|
autorequire:
|
22
22
|
bindir: bin
|
23
23
|
cert_chain: []
|
24
|
-
date: 2014-
|
24
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
25
25
|
dependencies:
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: trollop
|