kumonos 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/example/envoy_config.yml +17 -0
- data/exe/kumonos +3 -16
- data/lib/kumonos/envoy.rb +35 -14
- data/lib/kumonos/version.rb +1 -1
- data/lib/schemas/envoy.json +55 -118
- metadata +3 -3
- data/example/envoy.json +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 915ab24e5e48fa1761ae23b2c8a2ba09a666da2d
|
4
|
+
data.tar.gz: 288b08db40ab2aea699a74307b73785dca54c7ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d72019bf70fb44ddf776d3f372b0b4d465e668f2bcf78c070f59d48a40c1fc4e9767b1f4c8a5d85d7dfb99c13402e978f551719513029b46c4ea3791aa0d4b5
|
7
|
+
data.tar.gz: ca3f1c8d749de34b5ee3e6df3e930dfeeaee1728de0d4b48dd4488620eb5e73c652059dc15a1fb55c7a26628f214252c6437c82c6fdad34c9509f423503aea11
|
data/.rubocop.yml
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
version: 1
|
2
|
+
listener:
|
3
|
+
address: tcp://0.0.0.0:9211
|
4
|
+
access_log_path: /dev/stdout
|
5
|
+
admin:
|
6
|
+
address: tcp://0.0.0.0:9901
|
7
|
+
access_log_path: /dev/stdout
|
8
|
+
discovery_service:
|
9
|
+
lb: nginx:80
|
10
|
+
tls: false
|
11
|
+
refresh_delay_ms: 30000
|
12
|
+
connect_timeout_ms: 1000
|
13
|
+
statsd:
|
14
|
+
address: relay:2000
|
15
|
+
tls: false
|
16
|
+
type: strict_dns
|
17
|
+
connect_timeout_ms: 1000
|
data/exe/kumonos
CHANGED
@@ -12,26 +12,13 @@ class KumonosCli < Thor
|
|
12
12
|
end
|
13
13
|
|
14
14
|
desc 'envoy ENVOY_DEFINITION', 'Generate envoy configuration'
|
15
|
+
method_option :output, aliases: '-o', desc: 'Output path', required: true, type: :string
|
15
16
|
def envoy(path)
|
16
17
|
validate_path!(path)
|
17
|
-
definition =
|
18
|
+
definition = YAML.load_file(path)
|
18
19
|
validate_envoy_definition!(definition, path)
|
19
|
-
puts JSON.dump(Kumonos::Envoy.generate(definition))
|
20
|
-
end
|
21
20
|
|
22
|
-
|
23
|
-
def init_envoy
|
24
|
-
path = 'envoy.json'
|
25
|
-
definition = JSON.parse(File.read(File.expand_path('../example/envoy.json', __dir__)))
|
26
|
-
definition.delete('statsd')
|
27
|
-
cluster = definition.fetch('ds').fetch('cluster')
|
28
|
-
host = 'your-load-balancer-to-discovery-service'
|
29
|
-
cluster['name'] = host
|
30
|
-
cluster['hosts'] = [{ url: "tcp://#{host}:443" }]
|
31
|
-
cluster['tls'] = true
|
32
|
-
definition.fetch('ds')['cluster'] = cluster
|
33
|
-
File.write(path, JSON.pretty_generate(definition) + "\n")
|
34
|
-
puts path
|
21
|
+
File.write(options.fetch(:output), JSON.dump(Kumonos::Envoy.generate(definition)))
|
35
22
|
end
|
36
23
|
|
37
24
|
desc 'clusters SERVIVE_DEFINITION', 'Generate clusters configuration'
|
data/lib/kumonos/envoy.rb
CHANGED
@@ -7,29 +7,42 @@ module Kumonos
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
EnvoyConfig = Struct.new(:version, :
|
10
|
+
EnvoyConfig = Struct.new(:version, :discovery_service, :statsd, :listener, :admin) do
|
11
11
|
class << self
|
12
12
|
def build(h)
|
13
|
-
|
13
|
+
discovery_service = DiscoverService.build(h.fetch('discovery_service'))
|
14
14
|
new(
|
15
15
|
h.fetch('version'),
|
16
|
-
|
17
|
-
h['statsd'] ?
|
18
|
-
Listener.build(h.fetch('listener'),
|
16
|
+
discovery_service,
|
17
|
+
h['statsd'] ? build_statsd_cluster(h['statsd']) : nil,
|
18
|
+
Listener.build(h.fetch('listener'), discovery_service),
|
19
19
|
Admin.build(h.fetch('admin'))
|
20
20
|
)
|
21
21
|
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def build_statsd_cluster(h)
|
26
|
+
Cluster.new(
|
27
|
+
'statsd',
|
28
|
+
h.fetch('type'),
|
29
|
+
h.fetch('tls'),
|
30
|
+
h.fetch('connect_timeout_ms'),
|
31
|
+
'round_robin',
|
32
|
+
[{ 'url' => "tcp://#{h.fetch('address')}" }]
|
33
|
+
)
|
34
|
+
end
|
22
35
|
end
|
23
36
|
|
24
37
|
def to_h
|
25
38
|
h = super
|
26
39
|
h.delete(:version)
|
27
|
-
h.delete(:
|
40
|
+
h.delete(:discovery_service)
|
28
41
|
h.delete(:statsd)
|
29
42
|
h.delete(:listener)
|
30
43
|
h[:admin] = admin.to_h
|
31
44
|
h[:listeners] = [listener.to_h]
|
32
|
-
h[:cluster_manager] = { cds:
|
45
|
+
h[:cluster_manager] = { cds: discovery_service.to_h, clusters: [] }
|
33
46
|
|
34
47
|
if statsd
|
35
48
|
h[:statsd_tcp_cluster_name] = statsd.name
|
@@ -40,16 +53,16 @@ module Kumonos
|
|
40
53
|
end
|
41
54
|
end
|
42
55
|
|
43
|
-
Listener = Struct.new(:address, :access_log_path, :
|
56
|
+
Listener = Struct.new(:address, :access_log_path, :discovery_service) do
|
44
57
|
class << self
|
45
|
-
def build(h,
|
46
|
-
new(h.fetch('address'), h.fetch('access_log_path'),
|
58
|
+
def build(h, discovery_service)
|
59
|
+
new(h.fetch('address'), h.fetch('access_log_path'), discovery_service)
|
47
60
|
end
|
48
61
|
end
|
49
62
|
|
50
63
|
def to_h
|
51
64
|
h = super
|
52
|
-
h.delete(:
|
65
|
+
h.delete(:discovery_service)
|
53
66
|
h.delete(:access_log_path)
|
54
67
|
h[:filters] = [
|
55
68
|
{
|
@@ -60,9 +73,9 @@ module Kumonos
|
|
60
73
|
stat_prefix: 'egress_http',
|
61
74
|
access_log: [{ path: access_log_path }],
|
62
75
|
rds: {
|
63
|
-
cluster:
|
76
|
+
cluster: discovery_service.cluster.name,
|
64
77
|
route_config_name: DEFAULT_ROUTE_NAME,
|
65
|
-
refresh_delay_ms:
|
78
|
+
refresh_delay_ms: discovery_service.refresh_delay_ms
|
66
79
|
},
|
67
80
|
filters: [{ type: 'decoder', name: 'router', config: {} }]
|
68
81
|
}
|
@@ -75,7 +88,15 @@ module Kumonos
|
|
75
88
|
DiscoverService = Struct.new(:refresh_delay_ms, :cluster) do
|
76
89
|
class << self
|
77
90
|
def build(h)
|
78
|
-
|
91
|
+
cluster = Cluster.new(
|
92
|
+
'discovery_service',
|
93
|
+
'strict_dns',
|
94
|
+
h.fetch('tls'),
|
95
|
+
h.fetch('connect_timeout_ms'),
|
96
|
+
'round_robin',
|
97
|
+
[{ 'url' => "tcp://#{h.fetch('lb')}" }]
|
98
|
+
)
|
99
|
+
new(h.fetch('refresh_delay_ms'), cluster)
|
79
100
|
end
|
80
101
|
end
|
81
102
|
|
data/lib/kumonos/version.rb
CHANGED
data/lib/schemas/envoy.json
CHANGED
@@ -6,171 +6,108 @@
|
|
6
6
|
"additionalProperties": true,
|
7
7
|
"required": [
|
8
8
|
"version",
|
9
|
-
"ds",
|
10
9
|
"listener",
|
11
|
-
"admin"
|
10
|
+
"admin",
|
11
|
+
"discovery_service"
|
12
12
|
],
|
13
13
|
"properties": {
|
14
14
|
"version": {
|
15
15
|
"type": "integer",
|
16
16
|
"id": "/properties/version"
|
17
17
|
},
|
18
|
-
"
|
18
|
+
"listener": {
|
19
19
|
"type": "object",
|
20
|
-
"id": "/properties/
|
20
|
+
"id": "/properties/listener",
|
21
21
|
"additionalProperties": false,
|
22
22
|
"required": [
|
23
|
-
"
|
24
|
-
"
|
23
|
+
"address",
|
24
|
+
"access_log_path"
|
25
25
|
],
|
26
26
|
"properties": {
|
27
|
-
"
|
28
|
-
"type": "
|
29
|
-
"id": "/properties/
|
27
|
+
"address": {
|
28
|
+
"type": "string",
|
29
|
+
"id": "/properties/listener/properties/address"
|
30
30
|
},
|
31
|
-
"
|
32
|
-
"type": "
|
33
|
-
"id": "/properties/
|
34
|
-
"additionalProperties": false,
|
35
|
-
"required": [
|
36
|
-
"name",
|
37
|
-
"type",
|
38
|
-
"tls",
|
39
|
-
"connect_timeout_ms",
|
40
|
-
"lb_type",
|
41
|
-
"hosts"
|
42
|
-
],
|
43
|
-
"properties": {
|
44
|
-
"name": {
|
45
|
-
"type": "string",
|
46
|
-
"id": "/properties/ds/properties/cluster/properties/name"
|
47
|
-
},
|
48
|
-
"type": {
|
49
|
-
"type": "string",
|
50
|
-
"id": "/properties/ds/properties/cluster/properties/type"
|
51
|
-
},
|
52
|
-
"tls": {
|
53
|
-
"type": "boolean",
|
54
|
-
"id": "/properties/ds/properties/cluster/properties/tls"
|
55
|
-
},
|
56
|
-
"connect_timeout_ms": {
|
57
|
-
"type": "integer",
|
58
|
-
"id": "/properties/ds/properties/cluster/properties/connect_timeout_ms"
|
59
|
-
},
|
60
|
-
"lb_type": {
|
61
|
-
"type": "string",
|
62
|
-
"id": "/properties/ds/properties/cluster/properties/lb_type"
|
63
|
-
},
|
64
|
-
"hosts": {
|
65
|
-
"type": "array",
|
66
|
-
"id": "/properties/ds/properties/cluster/properties/hosts",
|
67
|
-
"items": {
|
68
|
-
"type": "object",
|
69
|
-
"id": "/properties/ds/properties/cluster/properties/hosts/items",
|
70
|
-
"additionalProperties": false,
|
71
|
-
"required": [
|
72
|
-
"url"
|
73
|
-
],
|
74
|
-
"properties": {
|
75
|
-
"url": {
|
76
|
-
"type": "string",
|
77
|
-
"id": "/properties/ds/properties/cluster/properties/hosts/items/properties/url"
|
78
|
-
}
|
79
|
-
}
|
80
|
-
}
|
81
|
-
}
|
82
|
-
}
|
31
|
+
"access_log_path": {
|
32
|
+
"type": "string",
|
33
|
+
"id": "/properties/listener/properties/access_log_path"
|
83
34
|
}
|
84
35
|
}
|
85
36
|
},
|
86
|
-
"
|
37
|
+
"admin": {
|
87
38
|
"type": "object",
|
88
|
-
"id": "/properties/
|
39
|
+
"id": "/properties/admin",
|
89
40
|
"additionalProperties": false,
|
90
41
|
"required": [
|
91
|
-
"
|
92
|
-
"
|
93
|
-
"type",
|
94
|
-
"tls",
|
95
|
-
"lb_type",
|
96
|
-
"hosts"
|
42
|
+
"address",
|
43
|
+
"access_log_path"
|
97
44
|
],
|
98
45
|
"properties": {
|
99
|
-
"
|
100
|
-
"type": "string",
|
101
|
-
"id": "/properties/statsd/properties/name"
|
102
|
-
},
|
103
|
-
"connect_timeout_ms": {
|
104
|
-
"type": "integer",
|
105
|
-
"id": "/properties/statsd/properties/connect_timeout_ms"
|
106
|
-
},
|
107
|
-
"type": {
|
46
|
+
"address": {
|
108
47
|
"type": "string",
|
109
|
-
"id": "/properties/
|
110
|
-
},
|
111
|
-
"tls": {
|
112
|
-
"type": "boolean",
|
113
|
-
"id": "/properties/statsd/properties/tls"
|
48
|
+
"id": "/properties/admin/properties/address"
|
114
49
|
},
|
115
|
-
"
|
50
|
+
"access_log_path": {
|
116
51
|
"type": "string",
|
117
|
-
"id": "/properties/
|
118
|
-
},
|
119
|
-
"hosts": {
|
120
|
-
"type": "array",
|
121
|
-
"id": "/properties/statsd/properties/hosts",
|
122
|
-
"items": {
|
123
|
-
"type": "object",
|
124
|
-
"id": "/properties/statsd/properties/hosts/items",
|
125
|
-
"additionalProperties": false,
|
126
|
-
"required": [
|
127
|
-
"url"
|
128
|
-
],
|
129
|
-
"properties": {
|
130
|
-
"url": {
|
131
|
-
"type": "string",
|
132
|
-
"id": "/properties/statsd/properties/hosts/items/properties/url"
|
133
|
-
}
|
134
|
-
}
|
135
|
-
}
|
52
|
+
"id": "/properties/admin/properties/access_log_path"
|
136
53
|
}
|
137
54
|
}
|
138
55
|
},
|
139
|
-
"
|
56
|
+
"discovery_service": {
|
140
57
|
"type": "object",
|
141
|
-
"id": "/properties/
|
58
|
+
"id": "/properties/discovery_service",
|
142
59
|
"additionalProperties": false,
|
143
60
|
"required": [
|
144
|
-
"
|
145
|
-
"
|
61
|
+
"lb",
|
62
|
+
"tls",
|
63
|
+
"refresh_delay_ms",
|
64
|
+
"connect_timeout_ms"
|
146
65
|
],
|
147
66
|
"properties": {
|
148
|
-
"
|
67
|
+
"lb": {
|
149
68
|
"type": "string",
|
150
|
-
"id": "/properties/
|
69
|
+
"id": "/properties/discovery_service/properties/properties/lb"
|
151
70
|
},
|
152
|
-
"
|
153
|
-
"type": "
|
154
|
-
"id": "/properties/
|
71
|
+
"tls": {
|
72
|
+
"type": "boolean",
|
73
|
+
"id": "/properties/discovery_service/properties/properties/tls"
|
74
|
+
},
|
75
|
+
"refresh_delay_ms": {
|
76
|
+
"type": "integer",
|
77
|
+
"id": "/properties/discovery_service/properties/refresh_delay_ms"
|
78
|
+
},
|
79
|
+
"connect_timeout_ms": {
|
80
|
+
"type": "integer",
|
81
|
+
"id": "/properties/discovery_service/properties/properties/connect_timeout_ms"
|
155
82
|
}
|
156
83
|
}
|
157
84
|
},
|
158
|
-
"
|
85
|
+
"statsd": {
|
159
86
|
"type": "object",
|
160
|
-
"id": "/properties/
|
87
|
+
"id": "/properties/statsd",
|
161
88
|
"additionalProperties": false,
|
162
89
|
"required": [
|
163
90
|
"address",
|
164
|
-
"
|
91
|
+
"tls",
|
92
|
+
"type",
|
93
|
+
"connect_timeout_ms"
|
165
94
|
],
|
166
95
|
"properties": {
|
167
96
|
"address": {
|
168
97
|
"type": "string",
|
169
|
-
"id": "/properties/
|
98
|
+
"id": "/properties/statsd/properties/address"
|
170
99
|
},
|
171
|
-
"
|
100
|
+
"tls": {
|
101
|
+
"type": "boolean",
|
102
|
+
"id": "/properties/statsd/properties/tls"
|
103
|
+
},
|
104
|
+
"type": {
|
172
105
|
"type": "string",
|
173
|
-
"id": "/properties/
|
106
|
+
"id": "/properties/statsd/properties/type"
|
107
|
+
},
|
108
|
+
"connect_timeout_ms": {
|
109
|
+
"type": "integer",
|
110
|
+
"id": "/properties/statsd/properties/connect_timeout_ms"
|
174
111
|
}
|
175
112
|
}
|
176
113
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kumonos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taiki Ono
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -159,7 +159,7 @@ files:
|
|
159
159
|
- bin/setup
|
160
160
|
- bump
|
161
161
|
- example/book.yml
|
162
|
-
- example/
|
162
|
+
- example/envoy_config.yml
|
163
163
|
- example/example-with-tls.yml
|
164
164
|
- exe/kumonos
|
165
165
|
- exe/kumonos-relay
|
data/example/envoy.json
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"version": 1,
|
3
|
-
"ds": {
|
4
|
-
"refresh_delay_ms": 30000,
|
5
|
-
"cluster": {
|
6
|
-
"name": "ds",
|
7
|
-
"type": "strict_dns",
|
8
|
-
"tls": false,
|
9
|
-
"connect_timeout_ms": 1000,
|
10
|
-
"lb_type": "round_robin",
|
11
|
-
"hosts": [
|
12
|
-
{
|
13
|
-
"url": "tcp://nginx:80"
|
14
|
-
}
|
15
|
-
]
|
16
|
-
}
|
17
|
-
},
|
18
|
-
"statsd": {
|
19
|
-
"name": "statsd",
|
20
|
-
"connect_timeout_ms": 1000,
|
21
|
-
"type": "strict_dns",
|
22
|
-
"tls": false,
|
23
|
-
"lb_type": "round_robin",
|
24
|
-
"hosts": [
|
25
|
-
{
|
26
|
-
"url": "tcp://relay:2000"
|
27
|
-
}
|
28
|
-
]
|
29
|
-
},
|
30
|
-
"listener": {
|
31
|
-
"address": "tcp://0.0.0.0:9211",
|
32
|
-
"access_log_path": "/dev/stdout"
|
33
|
-
},
|
34
|
-
"admin": {
|
35
|
-
"address": "tcp://0.0.0.0:9901",
|
36
|
-
"access_log_path": "/dev/stdout"
|
37
|
-
}
|
38
|
-
}
|