consul-templaterb 1.26.1 → 1.26.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Dockerfile +1 -1
- data/lib/consul/async/version.rb +1 -1
- data/samples/consul-ui/README.md +19 -0
- data/samples/find_nodes_in_catalog_but_not_in_members.json.erb +28 -0
- data/samples/metrics.erb +14 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc35b5803af2e05001323f77e18be90ec85baa05dd621030a83127cf1b5fd9f1
|
4
|
+
data.tar.gz: f7d3e25054dcd6c1b022e5c4bf58ea902c5c95676aafa936512659eaec3de9a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1e053e41716e64177917ef8a3ef1360ba82995758bb7dacfafd3bc7fb7a8f5774f107c62cbb7c4340189ea59cab15db936fc27854f6fab1ba487466ad0add3f
|
7
|
+
data.tar.gz: 95c0584f456239478395ceb0d2678e2ec1c7165f2148371f272ab23780148ed6498f419bc8104933d14cd155fcf20403c2b66521e604a3d2f4232bb8373f69c2
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
## (UNRELEASED)
|
4
4
|
|
5
|
+
NEW FEATURES:
|
6
|
+
|
7
|
+
## 1.26.2 (April 15, 2020)
|
8
|
+
|
9
|
+
BUGFIX:
|
10
|
+
|
11
|
+
* Fixed broken Dockerfile (was missing the new `decorator.js.erb` file). Fixes #61 (Thanks to @ simongareste)
|
12
|
+
|
13
|
+
NEW FEATURES:
|
14
|
+
|
15
|
+
* Added `consul_members_count` metric in [samples/metrics.erb](samples/metrics.erb)
|
16
|
+
|
5
17
|
## 1.26.1 (March 27, 2020)
|
6
18
|
|
7
19
|
BUGFIX:
|
data/Dockerfile
CHANGED
@@ -12,4 +12,4 @@ ENV LANG C.UTF-8
|
|
12
12
|
ENV CONSUL_HTTP_ADDR http://consul-relay.service.consul.preprod.crto.in:8500
|
13
13
|
|
14
14
|
ENTRYPOINT ["/usr/local/bin/bundle", "exec", "consul-templaterb"]
|
15
|
-
CMD ["--template", "samples/consul-ui/consul-keys-ui.html.erb", "--template", "samples/consul-ui/consul-nodes-ui.html.erb", "--template", "samples/consul-ui/consul-services-ui.html.erb", "--template", "samples/consul-ui/consul-timeline-ui.html.erb", "--template", "samples/consul-ui/consul_keys.json.erb", "--template", "samples/consul-ui/consul_nodes.json.erb", "--template", "samples/consul-ui/consul_services.json.erb", "--template", "samples/consul-ui/timeline.json.erb", "--template", "samples/consul-ui/consul-services-ui.html.erb:samples/consul-ui/index.html:touch samples/consul-ui/ready", "--sig-reload=NONE", "--exec=nginx -c /usr/src/app/docker-nginx-conf/nginx.conf"]
|
15
|
+
CMD ["--template", "samples/consul-ui/consul-keys-ui.html.erb", "--template", "samples/consul-ui/decorators.js.erb", "--template", "samples/consul-ui/consul-nodes-ui.html.erb", "--template", "samples/consul-ui/consul-services-ui.html.erb", "--template", "samples/consul-ui/consul-timeline-ui.html.erb", "--template", "samples/consul-ui/consul_keys.json.erb", "--template", "samples/consul-ui/consul_nodes.json.erb", "--template", "samples/consul-ui/consul_services.json.erb", "--template", "samples/consul-ui/timeline.json.erb", "--template", "samples/consul-ui/consul-services-ui.html.erb:samples/consul-ui/index.html:touch samples/consul-ui/ready", "--sig-reload=NONE", "--exec=nginx -c /usr/src/app/docker-nginx-conf/nginx.conf"]
|
data/lib/consul/async/version.rb
CHANGED
data/samples/consul-ui/README.md
CHANGED
@@ -50,6 +50,25 @@ The content is statically created, so you can serve it using any HTTP server ver
|
|
50
50
|
For development, you might use `python -m SimpleHTTPServer` in order to server the result
|
51
51
|
on your browser.
|
52
52
|
|
53
|
+
### Running it in production
|
54
|
+
|
55
|
+
Whatever your solution, be sure to have a index.html, so read next below on
|
56
|
+
how generating an index.html.
|
57
|
+
|
58
|
+
#### Running with web server
|
59
|
+
|
60
|
+
You can run it with your favoite web server, at Criteo we run it with nginx
|
61
|
+
which handles nicely cache and offer good performance.
|
62
|
+
|
63
|
+
In that case, consul-templaterb can start nginx with `--exec` or you can run it
|
64
|
+
as a daemon, in which case, consul-templaterb only generate the files.
|
65
|
+
|
66
|
+
#### Run it in Consul
|
67
|
+
|
68
|
+
You can run consul with `-ui-dir=/path/to/directory/of/consul-ui`, in such case
|
69
|
+
reaching consul on poort 8500 will redirect to the /ui/ path, displaying the UI
|
70
|
+
of your choice on http://consul-agent.example.org:8500/ui/.
|
71
|
+
|
53
72
|
### Generating index.html
|
54
73
|
|
55
74
|
By default, the command `consul-templaterb -c http://localhost:8500 samples/consul-ui/*.erb``
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%=
|
2
|
+
all_catalog = nodes.map{ |n| [n['Node'], n] }.to_h
|
3
|
+
all_members = agent_members.sort{ |a,b| a['Name'] <=> b['Name'] }
|
4
|
+
members_by_state = {}
|
5
|
+
all_members.each do |m|
|
6
|
+
state = m.status
|
7
|
+
members = members_by_state[state] || 0
|
8
|
+
members_by_state[state] = members + 1
|
9
|
+
end
|
10
|
+
# Find all virtual nodes (eg: k8s-sync)
|
11
|
+
catalog_external_sources = nodes.select{|n| (n['Meta']||{})['external-source'] }.map{|n| n['Node']}
|
12
|
+
in_catalog_but_not_in_members = all_catalog.keys - all_members.map{ |m| m['Name'] }
|
13
|
+
not_virtual_not_in_members = in_catalog_but_not_in_members - catalog_external_sources
|
14
|
+
JSON.pretty_generate(
|
15
|
+
{
|
16
|
+
'stats' => {
|
17
|
+
'catalog' => all_catalog.count,
|
18
|
+
'catalog_virtual' => in_catalog_but_not_in_members.count,
|
19
|
+
'members' => all_members.count,
|
20
|
+
'members_by_state': members_by_state,
|
21
|
+
'catalog_external_sources' => catalog_external_sources,
|
22
|
+
},
|
23
|
+
'errors': {
|
24
|
+
'in_catalog_but_not_in_members' => in_catalog_but_not_in_members,
|
25
|
+
'not_virtual_not_in_members' => not_virtual_not_in_members,
|
26
|
+
}
|
27
|
+
})
|
28
|
+
%>
|
data/samples/metrics.erb
CHANGED
@@ -21,6 +21,20 @@
|
|
21
21
|
all_stats = {}
|
22
22
|
service_count = 0
|
23
23
|
|
24
|
+
statuses = agent_members().map {|m| m.status}.reduce({}) do |sum, s|
|
25
|
+
v = sum[s] || 0
|
26
|
+
sum[s] = v + 1
|
27
|
+
sum
|
28
|
+
end
|
29
|
+
%>
|
30
|
+
# HELP consul_members_count A gauge of number of serf members with their count and their status('alive', 'leaving', 'left', 'failed')
|
31
|
+
# TYPE consul_members_count gauge
|
32
|
+
<%
|
33
|
+
statuses.each do |k, v|
|
34
|
+
%>
|
35
|
+
consul_members_count{serf="lan",status="<%= k %>"} <%= v %><%
|
36
|
+
end
|
37
|
+
|
24
38
|
services(tag: service_tag_filter).each do |service_name, tags|
|
25
39
|
if !services_blacklist.any? {|r| r.match(service_name)} && (instance_must_tag.nil? || tags.include?(instance_must_tag))
|
26
40
|
service_count += 1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consul-templaterb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.26.
|
4
|
+
version: 1.26.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SRE Core Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-http-request
|
@@ -230,6 +230,7 @@ files:
|
|
230
230
|
- samples/debug/compare_connect_services.txt.erb
|
231
231
|
- samples/demos/compute_pricing.txt.erb
|
232
232
|
- samples/find_all_invalid_dns_labels.json.erb
|
233
|
+
- samples/find_nodes_in_catalog_but_not_in_members.json.erb
|
233
234
|
- samples/ha_proxy.cfg.erb
|
234
235
|
- samples/haproxy_dns.cfg.erb
|
235
236
|
- samples/hosts.erb
|