comap 1.0.0.pre.a → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 345671b15e5f677976017cfce2b49e64656e615ef7e322c93c379910e1e5f2a3
4
- data.tar.gz: e68376648d58e13b9c2853cb84988b2239d74ad061e6a93f466c0f092b37eb11
3
+ metadata.gz: 8b23f9e291fe03872cb3ef03ff0f00f659d80aee08457bb1fdcd9cb4e7c0260a
4
+ data.tar.gz: 7b959111f7c9eef215b443cd67b3496e9a16527d7cbc64eddbf37cc66a71f3dd
5
5
  SHA512:
6
- metadata.gz: eaf027710fde4a00a1a90ad69baae5d3cbd75f3213bd43200c7767c709aa9d823a5cbcd29ac7013530287709d4b9404d1d607aad7a9bdf888415232805f76aac
7
- data.tar.gz: '05980b38c30f048e76775eb6367dd018ca8774b68705c57e6dcc6f42e0753e7f7eddf70d4ed01e1dd44be2544c910dc46f27e748c2b1ff93958e0c8782b60903'
6
+ metadata.gz: dcc368e24710b48e06ee5b7e66f478b45c84d604ce2e86b3b071847484d52d905968ce9719b9d43b2f4bd88c86cbf5bcd9ce80c1ebdccdc0738936e672d1cb9f
7
+ data.tar.gz: 7581d6850ee0b40422698b9e9a4b6278c5fe60cdd8489742d2cc3137ded4b06cac28c1353086b01ee91f0edb14ef67681a05cd473276b376de257bc933550629
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ Changelog
2
+ =========
3
+
4
+ 1.0.0
5
+ -----
6
+
7
+ - Initial version with Docker Swarm support
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- comap (1.0.0.pre.pre)
4
+ comap (1.0.0)
5
5
  faraday (~> 0.13)
6
6
  json (~> 2.0)
7
7
  thin (~> 1.7)
data/README.md CHANGED
@@ -1,7 +1,21 @@
1
1
  COMAP
2
2
  =====
3
3
 
4
- Container Orchestrator Metrics Aggregator for Prometheus
4
+ Container Orchestrator Metrics Aggregator for Prometheus.
5
+
6
+ COMAP aggregates prometheus-formatted metrics from different instances of a
7
+ service in a Docker containers cluster environment (swarm mode) using Docker
8
+ API for service containers discovery.
9
+
10
+ By design, a single COMAP instance should monitor a single service.
11
+
12
+ It is best used within a container belonging to the same network as the
13
+ services it follows.
14
+
15
+ A *container* label is added to each metric with the original container name.
16
+
17
+ Aggregated metrics intended to be fetched as a target by Prometheus are exposed
18
+ on port 9417.
5
19
 
6
20
  Installation
7
21
  ------------
@@ -23,6 +37,76 @@ Or install it yourself as:
23
37
  Usage
24
38
  -----
25
39
 
40
+ Launch COMAP as a Swarm service, specifying the service (specified by
41
+ service\_name and its internal port) to follow.
42
+
43
+ It need to access the docker socket of a manager. For a small cluster
44
+ containing managers only, it is possible to mount the docker socket as volume.
45
+ In other (most) case, it is recommended to use tls connection.
46
+
47
+ ```bash
48
+ sdir=/run/secrets docker service create \
49
+ --network your_network \
50
+ --publish '9397:9397' \
51
+ --secret cert.pem --secret key.pem --secret ca.pem \
52
+ makeorg/comap \
53
+ -H manager -p 2376 \
54
+ -s client_cert=$sdir/cert.pem,client_key=$sdir/key.pem,ca_file=$sdir/ca.pem \
55
+ -n your_network service_name:port
56
+ ```
57
+
58
+ If standalone or within your docker image:
59
+ ```bash
60
+ Usage: comap [options] swarm_service
61
+ -H, --docker_host HOST Docker Engine API Host
62
+ (default: http://127.0.0.1)
63
+ -p, --docker_port PORT Docker Engine API Port (default: 2375)
64
+ -s, --docker_ssl k1=v1,k2=v2 Docker Engine API SSL (default: none)
65
+ -n, --docker_network NETWORK Docker swarm service network (default: none)
66
+ -m, --metrics_path Metrics path (default: none)
67
+ -h, --help Display this screen
68
+ ```
69
+
70
+ Quickstart
71
+ -------------
72
+
73
+ [Kitchen](https://kitchen.ci/) is currently used during development for test
74
+ purpose. However, the kitchen test suite can be set up if you just want to
75
+ quickly see COMAP running :
76
+
77
+ $ kitchen converge
78
+
79
+ That should brings up a functional docker-in-docker swarm environment with a
80
+ manager/worker and a stand-alone consul. Configuration is automatically
81
+ handled with Chef and some
82
+ [Chef Platform cookbooks](https://gitlab.com/chef-platform/).
83
+
84
+ $ kitchen login comap-swarm-manager-centos-7
85
+
86
+ You can now play with the services running in the swarm :
87
+
88
+
89
+ A metrics service with two replicas exposing prometheus-formatted metrics
90
+ on 5678 port
91
+
92
+
93
+ [root@comap-swarm-manager-centos-7 /]# curl localhost:5678
94
+ # TYPE metrics_sample_seconds gauge
95
+ metrics_sample_seconds 42
96
+ # TYPE metrics_sample_2_seconds gauge
97
+ metrics_sample_2_seconds 24
98
+
99
+ A single COMAP service exposing aggregated metrics from previous service
100
+ on 9397 port
101
+
102
+ [root@comap-swarm-manager-centos-7 /]# curl localhost:9397
103
+ # TYPE metrics_sample_seconds gauge
104
+ metrics_sample_seconds{container="metrics.1"} 42
105
+ metrics_sample_seconds{container="metrics.2"} 42
106
+ # TYPE metrics_sample_2_seconds gauge
107
+ metrics_sample_2_seconds{container="metrics.1"} 24
108
+ metrics_sample_2_seconds{container="metrics.2"} 24
109
+
26
110
  Development
27
111
  -----------
28
112
 
data/Rakefile CHANGED
@@ -26,7 +26,11 @@ task default: :spec
26
26
  desc 'Prepare files directory for kitchen tests'
27
27
  task kitchen: :build do
28
28
  mkdir_p('files')
29
- cp("pkg/comap-#{COMAP::VERSION}.gem", 'files/comap.gem', preserve: false)
29
+ version = if COMAP::VERSION.include?('-')
30
+ COMAP::VERSION.split('-').insert(1, 'pre').join('.')
31
+ else COMAP::VERSION
32
+ end
33
+ cp("pkg/comap-#{version}.gem", 'files/comap.gem', preserve: false)
30
34
  cp('Dockerfile', 'files/.', preserve: false)
31
35
  end
32
36
  CLEAN.include('files', 'pkg')
data/lib/comap.rb CHANGED
@@ -43,20 +43,20 @@ module COMAP
43
43
  end
44
44
 
45
45
  def add_docker_ssl_option(opts)
46
- desc = "Docker Engine API SSL (default: #{@config[:docker_ssl]})"
46
+ desc = 'Docker Engine API SSL (default: none)'
47
47
  help = '--docker_ssl k1=v1,k2=v2'
48
48
  opts.on('-s', help, desc) { |v| @config[:docker_ssl] = v }
49
49
  end
50
50
 
51
51
  def add_network_option(opts)
52
- desc = "Docker swarm service network (default: #{@config[:network]})"
52
+ desc = 'Docker swarm service network (default: none)'
53
53
  help = '--docker_network NETWORK'
54
54
  opts.on('-n', help, desc) { |v| @config[:network] = v }
55
55
  end
56
56
 
57
57
  def add_metrics_path_option(opts)
58
58
  desc = "Metrics path (default: #{@config[:metrics_path]})"
59
- help = '--metrics_path'
59
+ help = '--metrics_path METRICS_PATH'
60
60
  opts.on('-m', help, desc) { |v| @config[:metrics_path] = v }
61
61
  end
62
62
 
@@ -93,7 +93,7 @@ module COMAP
93
93
  }
94
94
  parse_opts
95
95
  app = COMAP::App.new(@config)
96
- Rack::Server.start(app: app, Host: '0.0.0.0', Port: 9100)
96
+ Rack::Server.start(app: app, Host: '0.0.0.0', Port: 9397)
97
97
  end
98
98
  end
99
99
  # rubocop:enable Metrics/MethodLength
data/lib/comap/app.rb CHANGED
@@ -71,7 +71,7 @@ module COMAP
71
71
  data.lines.each_with_object({}) do |value, hash|
72
72
  next hash[value] = nil if value.start_with?('#')
73
73
  (hash[hash.keys.last] ||= []) << add_label(value, "#{service}.#{slot}")
74
- end
74
+ end.compact
75
75
  end
76
76
 
77
77
  def scrape_metrics(url, service)
@@ -85,7 +85,7 @@ module COMAP
85
85
 
86
86
  def add_label(line, label)
87
87
  replace = %(container="#{label}")
88
- line.gsub(/ /, "{#{replace}} ").gsub(/}{/, ',')
88
+ line.sub(/ /, "{#{replace}} ").sub(/}{/, ',')
89
89
  end
90
90
 
91
91
  def containers(service)
@@ -103,7 +103,7 @@ module COMAP
103
103
  'desired-state' => { 'running' => true }
104
104
  }
105
105
  @client.call('tasks', filters).keep_if do |task|
106
- task['Status']['State'] == 'running'
106
+ task['Status']['State'] == 'running' if task.is_a?(Hash)
107
107
  end
108
108
  end
109
109
 
data/lib/comap/version.rb CHANGED
@@ -17,5 +17,5 @@
17
17
 
18
18
  # Define version
19
19
  module COMAP
20
- VERSION = '1.0.0-a'
20
+ VERSION = '1.0.0'
21
21
  end
@@ -29,7 +29,7 @@ cookbook_file '/root/pkg/comap.gem' do
29
29
  end
30
30
 
31
31
  execute 'docker build comap' do
32
- command 'docker build . -t makeorg/comap'
32
+ command 'docker build . -t makeorg/comap-for-kitchen-test'
33
33
  cwd '/root'
34
34
  action :nothing
35
35
  end
@@ -44,23 +44,20 @@ end
44
44
 
45
45
  server = 'https://comap-swarm-manager-centos-7'
46
46
  ssl = {
47
- 'verify' => false, # https://github.com/berkshelf/berkshelf/issues/1458
48
47
  'client_cert' => '/run/secrets/cert.pem',
49
48
  'client_key' => '/run/secrets/key.pem',
50
49
  'ca_file' => '/run/secrets/ca.pem'
51
50
  }
52
51
  ssl_opt = ssl.map { |k, v| "#{k}=#{v}" }.join(',')
53
- puts "-H #{server} -p 2376 -s #{ssl_opt} -n kitchen metrics:5678"
54
52
 
55
- # TODO: give options as an array in docker-platform
56
53
  docker_platform_service 'comap' do
57
54
  options(
58
55
  mode: 'replicated',
59
56
  network: 'kitchen',
60
- publish: '9100:9100',
57
+ publish: '9397:9397',
61
58
  secret: %w[cert.pem key.pem ca.pem]
62
59
  )
63
- image 'makeorg/comap'
60
+ image 'makeorg/comap-for-kitchen-test'
64
61
  command "-H #{server} -p 2376 -s #{ssl_opt} -n kitchen metrics:5678"
65
62
  action :create
66
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.a
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Arrambourg
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-02-09 00:00:00.000000000 Z
12
+ date: 2018-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -138,6 +138,7 @@ files:
138
138
  - ".ruby-version"
139
139
  - ".travis.yml"
140
140
  - Berksfile
141
+ - CHANGELOG.md
141
142
  - CONTRIBUTING.md
142
143
  - Dockerfile
143
144
  - Gemfile
@@ -171,9 +172,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
172
  version: '0'
172
173
  required_rubygems_version: !ruby/object:Gem::Requirement
173
174
  requirements:
174
- - - ">"
175
+ - - ">="
175
176
  - !ruby/object:Gem::Version
176
- version: 1.3.1
177
+ version: '0'
177
178
  requirements: []
178
179
  rubyforge_project:
179
180
  rubygems_version: 2.7.3