marathon-srv 0.1.1 → 0.2.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 +0 -2
- data/lib/marathon/srv/cli.rb +0 -14
- data/lib/marathon/srv/client.rb +16 -7
- data/lib/marathon/srv/version.rb +1 -1
- data/marathon-srv.gemspec +2 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f715198df145818dbb69e69744f6a1afdf4f56d4
|
4
|
+
data.tar.gz: 33040bfa1df9d3590454b0d7c19debebca393959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 459686d8421eef8b2fc03312d8008c3bfe7e52bcef720c622f028f3593f34507fb51b98ad455955f0e3db7ed90ca81634f85366e7406c4bd07d3bbe53d5bc131
|
7
|
+
data.tar.gz: 52f66d636cdc2294e95ec5321207f2aa63a35fef81f1cc2ceea5597013ef685cbe6f692fe13c0541c7b6835596a0f026180678f2b07ea54262926ce0be2894d4
|
data/README.md
CHANGED
@@ -41,8 +41,6 @@ tl;dr poor man's port/service discovery for BRIDGEd Docker Containerized Maratho
|
|
41
41
|
client = Marathon::Srv::Client.new "http://marathon.domain.tld:8080", "username", "password", {:log_level => Logger::DEBUG}
|
42
42
|
client.get_bridged_port_array "best-redis-cluster", true # 2nd parameter : consider healthy tasks only
|
43
43
|
|
44
|
-
( n.b.: The Client object returns all BRIDGEd ports, the CLI filters these down to only --container-port )
|
45
|
-
|
46
44
|
## Notes
|
47
45
|
|
48
46
|
### Tests
|
data/lib/marathon/srv/cli.rb
CHANGED
@@ -28,20 +28,6 @@ module Marathon
|
|
28
28
|
begin
|
29
29
|
hosts = client.get_bridged_port_array options[:app_id], (options[:healthy] ? true : falses)
|
30
30
|
|
31
|
-
|
32
|
-
hosts.reject! do |host|
|
33
|
-
|
34
|
-
host[:services].reject! do |protocol, services|
|
35
|
-
|
36
|
-
services.reject! {|port, host_port| port.to_s != options[:container_port]}
|
37
|
-
services.size == 0
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
host[:services].size == 0
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
31
|
if options[:json]
|
46
32
|
puts JSON hosts
|
47
33
|
else
|
data/lib/marathon/srv/client.rb
CHANGED
@@ -35,9 +35,9 @@ module Marathon
|
|
35
35
|
|
36
36
|
end
|
37
37
|
|
38
|
-
def get_bridged_port_array(application_id, healthy_tasks_only=false)
|
38
|
+
def get_bridged_port_array(application_id, healthy_tasks_only=false, filter_ports=[])
|
39
39
|
|
40
|
-
@logger.debug "Attempting to fetch application #{application_id} object from API, healthy_tasks_only: #{healthy_tasks_only} "
|
40
|
+
@logger.debug "Attempting to fetch application #{application_id} object from API, healthy_tasks_only: #{healthy_tasks_only}, interested in container ports #{filter_ports} "
|
41
41
|
|
42
42
|
api = URI::join(marathon_api, PATH_FIND_APP % application_id)
|
43
43
|
Net::HTTP.new(api.host, api.port).start do |http|
|
@@ -74,17 +74,24 @@ module Marathon
|
|
74
74
|
|
75
75
|
end
|
76
76
|
@logger.debug "All health checks passing - filtering ports for task #{task}"
|
77
|
-
ports.push filter_ports(app, task) if passing
|
77
|
+
ports.push filter_ports(app, task, filter_ports) if passing
|
78
78
|
|
79
79
|
else
|
80
80
|
# just add task
|
81
81
|
@logger.debug "Ignoring health checks - filtering ports for task #{task}"
|
82
|
-
ports.push filter_ports(app, task)
|
82
|
+
ports.push filter_ports(app, task, filter_ports)
|
83
83
|
|
84
84
|
end
|
85
85
|
|
86
86
|
end
|
87
87
|
|
88
|
+
ports.reject! do |host|
|
89
|
+
|
90
|
+
host[:services].reject! {|protocol, services| services.size == 0 }
|
91
|
+
host[:services].size == 0
|
92
|
+
|
93
|
+
end
|
94
|
+
|
88
95
|
@logger.debug "Collected ports #{ports}"
|
89
96
|
ports
|
90
97
|
|
@@ -99,11 +106,13 @@ module Marathon
|
|
99
106
|
end
|
100
107
|
|
101
108
|
protected
|
102
|
-
def filter_ports(app, task)
|
109
|
+
def filter_ports(app, task, filter_ports=[])
|
103
110
|
port = {:host => task["host"], :services => {}}
|
104
111
|
app["container"]["docker"]["portMappings"].each_with_index do |port_mapping, port_i|
|
105
|
-
|
106
|
-
|
112
|
+
if (filter_ports.size == 0 || (filter_ports.member? port_mapping["containerPort"]))
|
113
|
+
port[:services][port_mapping["protocol"]] = {} unless port[:services].has_key? port_mapping["protocol"]
|
114
|
+
port[:services][port_mapping["protocol"]][port_mapping["containerPort"]] = task["ports"][port_i]
|
115
|
+
end
|
107
116
|
|
108
117
|
end
|
109
118
|
|
data/lib/marathon/srv/version.rb
CHANGED
data/marathon-srv.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.license = "MIT"
|
12
12
|
|
13
13
|
spec.summary = %q{A simple CLI/library to resolve (BRIDGE networked) ports of Docker containerized Marathon application tasks/instances to Mesos slave host names and host ports}
|
14
|
-
spec.description = %q{Uses the Marathon API to match one or more ports set up under BRIDGE Docker networking for a Marathon application
|
14
|
+
spec.description = %q{Uses the Marathon API to match one or more ports set up under BRIDGE Docker networking for a Marathon application to Mesos slave ip/s and host port/s}
|
15
15
|
spec.homepage = "https://github.com/andlaz/marathon-srv"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
+
spec.required_ruby_version = '~> 2.2'
|
22
23
|
spec.add_dependency "thor", "~> 0.19.1"
|
23
24
|
spec.add_dependency "json", "~> 1.8.3"
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.11"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marathon-srv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andras Szerdahelyi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -109,8 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 1.22.6
|
111
111
|
description: Uses the Marathon API to match one or more ports set up under BRIDGE
|
112
|
-
Docker networking for a Marathon application
|
113
|
-
slave (host) port/s
|
112
|
+
Docker networking for a Marathon application to Mesos slave ip/s and host port/s
|
114
113
|
email:
|
115
114
|
- andras.szerdahelyi@gmail.com
|
116
115
|
executables:
|
@@ -145,9 +144,9 @@ require_paths:
|
|
145
144
|
- lib
|
146
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
147
146
|
requirements:
|
148
|
-
- - "
|
147
|
+
- - "~>"
|
149
148
|
- !ruby/object:Gem::Version
|
150
|
-
version: '
|
149
|
+
version: '2.2'
|
151
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
151
|
requirements:
|
153
152
|
- - ">="
|