consul_bridge 0.1.4 → 0.1.5
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/.dockerignore +3 -0
- data/Dockerfile +20 -10
- data/Dockerfile.release +8 -9
- data/LICENSE +201 -0
- data/README.md +16 -9
- data/build_dev.sh +39 -0
- data/consul_bridge.gemspec +2 -0
- data/lib/consul_bridge/bootstrap_consul.rb +16 -10
- data/lib/consul_bridge/bootstrap_consul_actor.rb +3 -1
- data/lib/consul_bridge/detect_consul.rb +6 -5
- data/lib/consul_bridge/download_masters.rb +21 -12
- data/lib/consul_bridge/get_private_ip.rb +5 -5
- data/lib/consul_bridge/join_consul.rb +16 -10
- data/lib/consul_bridge/monitor_docker_events.rb +15 -9
- data/lib/consul_bridge/monitor_docker_events_actor.rb +3 -1
- data/lib/consul_bridge/run_bridge.rb +28 -11
- data/lib/consul_bridge/version.rb +1 -1
- data/scripts/docker-entrypoint.sh +18 -0
- data/scripts/fetch-bundler-data.sh +16 -0
- metadata +36 -5
- data/docker-entrypoint.sh +0 -12
- data/lib/consul_bridge/base.rb +0 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: de3103de52dcb69d51926ebc07534b5424e24e18
|
|
4
|
+
data.tar.gz: 0cfcc4ae5f166d3770ef6219b772d92362112ca7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a021ecbad6f0a07642c8e1597020a1d78a0acae2cfa2d50caf5ba974c456135c1f2e99873e831554872bb92fd714542543e7ba4317c1b13667651282afabbf7
|
|
7
|
+
data.tar.gz: 9016100027daafe73ee55463e6f4225ed868bfa0d145865d2d7bd5c28c250a2686726d63ebef6abc22d68263250d3e945977d583a16843d0facbe56124adac4d
|
data/.dockerignore
ADDED
data/Dockerfile
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
FROM outstand/ruby-base:2.
|
|
1
|
+
FROM outstand/ruby-base:2.3.1-alpine
|
|
2
2
|
MAINTAINER Ryan Schlesinger <ryan@outstand.com>
|
|
3
3
|
|
|
4
|
-
RUN addgroup bridge && \
|
|
4
|
+
RUN addgroup -S bridge && \
|
|
5
|
+
adduser -S -G bridge bridge && \
|
|
5
6
|
addgroup -g 1101 docker && \
|
|
6
|
-
|
|
7
|
+
addgroup bridge docker
|
|
7
8
|
|
|
8
|
-
RUN apk --no-cache add build-base
|
|
9
|
+
RUN apk --no-cache add build-base openssh
|
|
10
|
+
|
|
11
|
+
ENV USE_BUNDLE_EXEC true
|
|
12
|
+
|
|
13
|
+
WORKDIR /consul_bridge
|
|
14
|
+
COPY Gemfile consul_bridge.gemspec /consul_bridge/
|
|
15
|
+
COPY lib/consul_bridge/version.rb /consul_bridge/lib/consul_bridge/
|
|
16
|
+
COPY scripts/fetch-bundler-data.sh /consul_bridge/scripts/fetch-bundler-data.sh
|
|
17
|
+
|
|
18
|
+
ARG bundler_data_host
|
|
19
|
+
RUN /consul_bridge/scripts/fetch-bundler-data.sh ${bundler_data_host} && \
|
|
20
|
+
bundle install && \
|
|
21
|
+
git config --global push.default simple
|
|
9
22
|
COPY . /consul_bridge/
|
|
10
|
-
RUN
|
|
11
|
-
&& bundle config build.nokogiri --use-system-libraries \
|
|
12
|
-
&& bundle install \
|
|
13
|
-
&& bundle exec rake install
|
|
23
|
+
RUN ln -s /consul_bridge/exe/consul_bridge /usr/local/bin/consul_bridge
|
|
14
24
|
|
|
15
|
-
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
|
25
|
+
COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh
|
|
16
26
|
|
|
17
27
|
ENV DUMB_INIT_SETSID 0
|
|
18
28
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
|
19
|
-
CMD ["
|
|
29
|
+
CMD ["help"]
|
data/Dockerfile.release
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
FROM outstand/ruby-base:2.
|
|
1
|
+
FROM outstand/ruby-base:2.3.1-alpine
|
|
2
2
|
MAINTAINER Ryan Schlesinger <ryan@outstand.com>
|
|
3
3
|
|
|
4
|
-
RUN addgroup bridge && \
|
|
4
|
+
RUN addgroup -S bridge && \
|
|
5
|
+
adduser -S -G bridge bridge && \
|
|
5
6
|
addgroup -g 1101 docker && \
|
|
6
|
-
|
|
7
|
+
addgroup bridge docker
|
|
7
8
|
|
|
8
|
-
ENV CONSUL_BRIDGE_VERSION=0.1.
|
|
9
|
+
ENV CONSUL_BRIDGE_VERSION=0.1.5
|
|
9
10
|
|
|
10
|
-
RUN apk --no-cache add
|
|
11
|
-
&& apk --no-cache add --virtual build-dependencies build-base libxml2-dev libxslt-dev \
|
|
12
|
-
&& gem install nokogiri -- --use-system-libraries \
|
|
11
|
+
RUN apk --no-cache add --virtual build-dependencies build-base \
|
|
13
12
|
&& gem install consul_bridge -v ${CONSUL_BRIDGE_VERSION} \
|
|
14
13
|
&& apk del build-dependencies
|
|
15
14
|
|
|
16
|
-
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
|
15
|
+
COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh
|
|
17
16
|
|
|
18
17
|
ENV DUMB_INIT_SETSID 0
|
|
19
18
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
|
20
|
-
CMD ["
|
|
19
|
+
CMD ["help"]
|
data/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
data/README.md
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/consul_bridge`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
-
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
|
1
|
+
# Consul Bridge
|
|
6
2
|
|
|
7
3
|
## Installation
|
|
8
4
|
|
|
@@ -22,15 +18,26 @@ Or install it yourself as:
|
|
|
22
18
|
|
|
23
19
|
## Usage
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
Master nodes:
|
|
22
|
+
`docker run -d --net=host outstand/consul_bridge start -b <heartbeat bucket> -n <consul container name> -a`
|
|
23
|
+
|
|
24
|
+
Client nodes:
|
|
25
|
+
`docker run -d --net=host outstand/consul_bridge start -b <heartbeat bucket> -n <consul container name>`
|
|
26
26
|
|
|
27
27
|
## Development
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
- `docker volume create --name consul_bridge_fog`
|
|
30
|
+
- `./build_dev.sh`
|
|
31
|
+
- `docker run -it --rm --net=host -v $(pwd):/consul_bridge -v consul_bridge_fog:/fog -e FOG_LOCAL=true outstand/consul_bridge:dev start -b bucket -n backup`
|
|
30
32
|
|
|
31
|
-
To
|
|
33
|
+
To release a new version:
|
|
34
|
+
- Update the version number in `version.rb` and `Dockerfile.release` and commit the result.
|
|
35
|
+
- `./build_dev.sh`
|
|
36
|
+
- `docker run -it --rm -v ~/.gitconfig:/root/.gitconfig -v ~/.gitconfig.user:/root/.gitconfig.user -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -v ~/.gem:/root/.gem outstand/consul_bridge:dev rake release`
|
|
37
|
+
- `docker build -t outstand/consul_bridge:VERSION -f Dockerfile.release .`
|
|
38
|
+
- `docker push outstand/consul_bridge:VERSION`
|
|
32
39
|
|
|
33
40
|
## Contributing
|
|
34
41
|
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/outstand/consul_bridge.
|
|
36
43
|
|
data/build_dev.sh
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e -x
|
|
3
|
+
|
|
4
|
+
build_image=outstand/consul_bridge:dev
|
|
5
|
+
dockerfile=Dockerfile
|
|
6
|
+
bundler_data_dir=tmp
|
|
7
|
+
|
|
8
|
+
bundler_data_container=''
|
|
9
|
+
tar_container=''
|
|
10
|
+
|
|
11
|
+
function cleanup {
|
|
12
|
+
if [ -n "$bundler_data_container" ]; then
|
|
13
|
+
docker stop bundler-data
|
|
14
|
+
docker rm -fv bundler-data
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
if [ -n "$tar_container" ]; then
|
|
18
|
+
docker rm -fv ${tar_container}
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
rm -f ${bundler_data_dir}/cidfile
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
trap cleanup EXIT
|
|
25
|
+
|
|
26
|
+
build_args=''
|
|
27
|
+
mkdir -p ${bundler_data_dir}
|
|
28
|
+
|
|
29
|
+
if [ -f $(pwd)/${bundler_data_dir}/bundler-data.tar.gz ]; then
|
|
30
|
+
docker run --name bundler-data -v $(pwd)/${bundler_data_dir}/bundler-data.tar.gz:/usr/share/nginx/html/bundler-data.tar.gz:ro -d nginx:stable-alpine
|
|
31
|
+
bundler_data_container=bundler-data
|
|
32
|
+
build_args="--build-arg bundler_data_host=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' bundler-data)"
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
docker build -t ${build_image} -f ${dockerfile} ${build_args} .
|
|
36
|
+
|
|
37
|
+
docker run -t --cidfile=${bundler_data_dir}/cidfile -w /usr/local/bundle ${build_image} tar -zcf /tmp/bundler-data.tar.gz .
|
|
38
|
+
tar_container=$(cat ${bundler_data_dir}/cidfile)
|
|
39
|
+
docker cp ${tar_container}:/tmp/bundler-data.tar.gz ${bundler_data_dir}/bundler-data.tar.gz
|
data/consul_bridge.gemspec
CHANGED
|
@@ -24,7 +24,9 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
spec.add_runtime_dependency 'docker-api', '~> 1.28'
|
|
25
25
|
spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
|
|
26
26
|
spec.add_runtime_dependency 'concurrent-ruby-edge', '~> 0.2'
|
|
27
|
+
spec.add_runtime_dependency 'metaractor', '~> 0.5'
|
|
27
28
|
|
|
28
29
|
spec.add_development_dependency "bundler", "~> 1.11"
|
|
29
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
|
31
|
+
spec.add_development_dependency "fog-local", "~> 0.3"
|
|
30
32
|
end
|
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'metaractor'
|
|
2
2
|
require 'consul_bridge/detect_consul'
|
|
3
3
|
require 'consul_bridge/download_masters'
|
|
4
4
|
require 'consul_bridge/join_consul'
|
|
5
5
|
|
|
6
6
|
module ConsulBridge
|
|
7
|
-
class BootstrapConsul
|
|
8
|
-
|
|
7
|
+
class BootstrapConsul
|
|
8
|
+
include Metaractor
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
self.bucket = bucket
|
|
12
|
-
self.join_all = join_all
|
|
13
|
-
end
|
|
10
|
+
required :bucket, :join_all
|
|
14
11
|
|
|
15
12
|
def call
|
|
16
|
-
while !DetectConsul.call
|
|
13
|
+
while !DetectConsul.call!.running
|
|
17
14
|
puts 'Local consul agent not detected, sleeping for 5 seconds'
|
|
18
15
|
sleep 5
|
|
19
16
|
end
|
|
20
17
|
|
|
21
18
|
puts '==> Bootstrapping consul'
|
|
22
|
-
master_ips = DownloadMasters.call(bucket:
|
|
23
|
-
JoinConsul.call(master_ips: master_ips, join_all:
|
|
19
|
+
master_ips = DownloadMasters.call!(bucket: bucket).master_ips
|
|
20
|
+
JoinConsul.call!(master_ips: master_ips, join_all: join_all)
|
|
24
21
|
puts '==> Done.'
|
|
25
22
|
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
def bucket
|
|
26
|
+
context.bucket
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def join_all
|
|
30
|
+
context.join_all
|
|
31
|
+
end
|
|
26
32
|
end
|
|
27
33
|
end
|
|
@@ -12,11 +12,13 @@ module ConsulBridge
|
|
|
12
12
|
def on_message(message)
|
|
13
13
|
if message == :bootstrap
|
|
14
14
|
begin
|
|
15
|
-
BootstrapConsul.call(bucket: @bucket, join_all: @join_all)
|
|
15
|
+
BootstrapConsul.call!(bucket: @bucket, join_all: @join_all)
|
|
16
16
|
rescue => e
|
|
17
17
|
puts "Warning: #{e.message}; retrying in 5 seconds"
|
|
18
18
|
Concurrent::ScheduledTask.execute(5){ tell :bootstrap }
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
nil
|
|
20
22
|
else
|
|
21
23
|
pass
|
|
22
24
|
end
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'metaractor'
|
|
2
2
|
require 'excon'
|
|
3
3
|
|
|
4
4
|
module ConsulBridge
|
|
5
|
-
class DetectConsul
|
|
5
|
+
class DetectConsul
|
|
6
|
+
include Metaractor
|
|
7
|
+
|
|
6
8
|
URL = 'http://127.0.0.1:8500/v1/agent/self'.freeze
|
|
7
9
|
|
|
8
10
|
def call
|
|
@@ -19,9 +21,8 @@ module ConsulBridge
|
|
|
19
21
|
rescue Excon::Errors::SocketError, Excon::Errors::HTTPStatusError
|
|
20
22
|
running = false
|
|
21
23
|
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
24
|
+
|
|
25
|
+
context.running = running
|
|
25
26
|
end
|
|
26
27
|
end
|
|
27
28
|
end
|
|
@@ -1,30 +1,39 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'metaractor'
|
|
2
2
|
require 'fog/aws'
|
|
3
|
+
require 'fog/local' if ENV['FOG_LOCAL']
|
|
3
4
|
|
|
4
5
|
module ConsulBridge
|
|
5
|
-
class DownloadMasters
|
|
6
|
-
|
|
6
|
+
class DownloadMasters
|
|
7
|
+
include Metaractor
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
self.bucket = bucket
|
|
10
|
-
end
|
|
9
|
+
required :bucket
|
|
11
10
|
|
|
12
11
|
def call
|
|
13
|
-
puts "Downloading master ips from bucket #{
|
|
12
|
+
puts "Downloading master ips from bucket #{bucket_name}"
|
|
14
13
|
|
|
15
14
|
master_ips = []
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
bucket = nil
|
|
17
|
+
if ENV['FOG_LOCAL']
|
|
18
|
+
puts 'Using fog local storage'
|
|
19
|
+
storage = Fog::Storage.new provider: 'Local', local_root: '/fog'
|
|
20
|
+
bucket = storage.directories.create(key: bucket_name)
|
|
21
|
+
else
|
|
22
|
+
storage = Fog::Storage.new provider: 'AWS', use_iam_profile: true
|
|
23
|
+
bucket = storage.directories.get(bucket_name)
|
|
24
|
+
end
|
|
25
|
+
|
|
19
26
|
bucket.files.each do |file|
|
|
20
27
|
master_ips << [file.last_modified, file.key]
|
|
21
28
|
end
|
|
22
29
|
master_ips = master_ips.sort.reverse.collect { |file| file[1] }
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
master_ips: master_ips
|
|
26
|
-
)
|
|
31
|
+
context.master_ips = master_ips
|
|
27
32
|
end
|
|
28
33
|
|
|
34
|
+
private
|
|
35
|
+
def bucket_name
|
|
36
|
+
context.bucket
|
|
37
|
+
end
|
|
29
38
|
end
|
|
30
39
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'metaractor'
|
|
2
2
|
require 'excon'
|
|
3
3
|
|
|
4
4
|
module ConsulBridge
|
|
5
|
-
class GetPrivateIP
|
|
5
|
+
class GetPrivateIP
|
|
6
|
+
include Metaractor
|
|
7
|
+
|
|
6
8
|
URL = 'http://169.254.169.254/latest/meta-data/local-ipv4'.freeze
|
|
7
9
|
|
|
8
10
|
def call
|
|
9
11
|
response = Excon.get(URL, expects: [200], connect_timeout: 10, read_timeout: 10, write_timeout: 10, tcp_nodelay: true)
|
|
10
|
-
|
|
11
|
-
private_ip: response.body
|
|
12
|
-
)
|
|
12
|
+
context.private_ip = response.body
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'metaractor'
|
|
2
2
|
require 'consul_bridge/get_private_ip'
|
|
3
3
|
require 'excon'
|
|
4
4
|
|
|
5
5
|
module ConsulBridge
|
|
6
|
-
class JoinConsul
|
|
7
|
-
|
|
6
|
+
class JoinConsul
|
|
7
|
+
include Metaractor
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
required :master_ips, :join_all
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
self.master_ips = master_ips
|
|
13
|
-
self.join_all = join_all
|
|
14
|
-
end
|
|
11
|
+
JOIN_URL = 'http://127.0.0.1:8500/v1/agent/join'.freeze
|
|
15
12
|
|
|
16
13
|
def call
|
|
17
|
-
private_ip = GetPrivateIP.call
|
|
14
|
+
private_ip = GetPrivateIP.call!.private_ip
|
|
18
15
|
puts "Detected private ip: #{private_ip}"
|
|
19
16
|
puts "Starting join with [#{master_ips.join(', ')}]"
|
|
20
17
|
|
|
@@ -33,7 +30,7 @@ module ConsulBridge
|
|
|
33
30
|
)
|
|
34
31
|
puts "Joined #{ip}"
|
|
35
32
|
joined += 1
|
|
36
|
-
break unless
|
|
33
|
+
break unless join_all
|
|
37
34
|
rescue Excon::Errors::HTTPStatusError, Excon::Errors::SocketError
|
|
38
35
|
next
|
|
39
36
|
end
|
|
@@ -46,5 +43,14 @@ module ConsulBridge
|
|
|
46
43
|
end
|
|
47
44
|
end
|
|
48
45
|
|
|
46
|
+
private
|
|
47
|
+
def master_ips
|
|
48
|
+
context.master_ips
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def join_all
|
|
52
|
+
context.join_all
|
|
53
|
+
end
|
|
54
|
+
|
|
49
55
|
end
|
|
50
56
|
end
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'metaractor'
|
|
2
2
|
require 'docker-api'
|
|
3
3
|
|
|
4
4
|
module ConsulBridge
|
|
5
|
-
class MonitorDockerEvents
|
|
6
|
-
|
|
5
|
+
class MonitorDockerEvents
|
|
6
|
+
include Metaractor
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
self.container_name = container_name
|
|
10
|
-
self.handler = handler
|
|
11
|
-
end
|
|
8
|
+
required :container_name, :handler
|
|
12
9
|
|
|
13
10
|
def call
|
|
14
11
|
begin
|
|
15
|
-
filters = {type: [:container], event: [:start], container: [
|
|
12
|
+
filters = {type: [:container], event: [:start], container: [container_name]}.to_json
|
|
16
13
|
Docker::Event.stream(filters: filters) do |event|
|
|
17
|
-
|
|
14
|
+
handler.call(event)
|
|
18
15
|
end
|
|
19
16
|
rescue Docker::Error::TimeoutError
|
|
20
17
|
retry
|
|
@@ -27,5 +24,14 @@ module ConsulBridge
|
|
|
27
24
|
end
|
|
28
25
|
end
|
|
29
26
|
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
def container_name
|
|
30
|
+
context.container_name
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def handler
|
|
34
|
+
context.handler
|
|
35
|
+
end
|
|
30
36
|
end
|
|
31
37
|
end
|
|
@@ -14,7 +14,7 @@ module ConsulBridge
|
|
|
14
14
|
def on_message(message)
|
|
15
15
|
if message == :monitor
|
|
16
16
|
begin
|
|
17
|
-
MonitorDockerEvents.call(
|
|
17
|
+
MonitorDockerEvents.call!(
|
|
18
18
|
container_name: @container_name,
|
|
19
19
|
handler: ->(event){ @bootstrap_actor << :bootstrap }
|
|
20
20
|
)
|
|
@@ -24,6 +24,8 @@ module ConsulBridge
|
|
|
24
24
|
Concurrent::ScheduledTask.execute(30){ tell :monitor }
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
|
+
|
|
28
|
+
nil
|
|
27
29
|
else
|
|
28
30
|
pass
|
|
29
31
|
end
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'metaractor'
|
|
2
2
|
require 'consul_bridge/bootstrap_consul_actor'
|
|
3
3
|
require 'consul_bridge/monitor_docker_events_actor'
|
|
4
4
|
require 'concurrent'
|
|
5
5
|
|
|
6
6
|
module ConsulBridge
|
|
7
|
-
class RunBridge
|
|
8
|
-
|
|
7
|
+
class RunBridge
|
|
8
|
+
include Metaractor
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
required :bucket, :container_name, :join_all, :verbose
|
|
11
|
+
|
|
12
|
+
before do
|
|
13
|
+
context.join_all ||= false
|
|
14
|
+
context.verbose ||= false
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def call
|
|
18
|
-
Concurrent.use_stdlib_logger(Logger::DEBUG) if
|
|
18
|
+
Concurrent.use_stdlib_logger(Logger::DEBUG) if verbose
|
|
19
19
|
|
|
20
20
|
self_read, self_write = IO.pipe
|
|
21
21
|
%w(INT TERM).each do |sig|
|
|
@@ -31,8 +31,8 @@ module ConsulBridge
|
|
|
31
31
|
begin
|
|
32
32
|
bootstrap_actor = BootstrapConsulActor.spawn(
|
|
33
33
|
:bootstrap_consul,
|
|
34
|
-
bucket:
|
|
35
|
-
join_all:
|
|
34
|
+
bucket: bucket,
|
|
35
|
+
join_all: join_all
|
|
36
36
|
)
|
|
37
37
|
bootstrap_actor << :bootstrap
|
|
38
38
|
|
|
@@ -54,6 +54,7 @@ module ConsulBridge
|
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
private
|
|
57
58
|
def handle_signal(sig)
|
|
58
59
|
case sig
|
|
59
60
|
when 'INT'
|
|
@@ -62,5 +63,21 @@ module ConsulBridge
|
|
|
62
63
|
raise Interrupt
|
|
63
64
|
end
|
|
64
65
|
end
|
|
66
|
+
|
|
67
|
+
def bucket
|
|
68
|
+
context.bucket
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def container_name
|
|
72
|
+
context.container_name
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def join_all
|
|
76
|
+
context.join_all
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def verbose
|
|
80
|
+
context.verbose
|
|
81
|
+
end
|
|
65
82
|
end
|
|
66
83
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/bin/dumb-init /bin/sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
if [ -n "$USE_BUNDLE_EXEC" ]; then
|
|
5
|
+
BINARY="bundle exec consul_bridge"
|
|
6
|
+
else
|
|
7
|
+
BINARY=consul_bridge
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
if ${BINARY} help "$1" 2>&1 | grep -q "consul_bridge $1"; then
|
|
11
|
+
set -- ${BINARY} "$@"
|
|
12
|
+
|
|
13
|
+
if [ -n "$FOG_LOCAL" ]; then
|
|
14
|
+
chown -R bridge:bridge /fog
|
|
15
|
+
fi
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
exec "$@"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -x
|
|
3
|
+
|
|
4
|
+
if [ -z "$1" ]; then
|
|
5
|
+
echo 'Missing argument: bundler data host'
|
|
6
|
+
exit 0
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
wget -T 2 -O /tmp/bundler-data.tar.gz http://${1}/bundler-data.tar.gz
|
|
10
|
+
if [ $? -ne 0 ]; then
|
|
11
|
+
echo 'Unable to fetch bundler data.'
|
|
12
|
+
else
|
|
13
|
+
cd /usr/local/bundle && \
|
|
14
|
+
tar -zxf /tmp/bundler-data.tar.gz && \
|
|
15
|
+
rm /tmp/bundler-data.tar.gz
|
|
16
|
+
fi
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: consul_bridge
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Schlesinger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-04
|
|
11
|
+
date: 2016-07-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -108,6 +108,20 @@ dependencies:
|
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0.2'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: metaractor
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0.5'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0.5'
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
126
|
name: bundler
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -136,6 +150,20 @@ dependencies:
|
|
|
136
150
|
- - "~>"
|
|
137
151
|
- !ruby/object:Gem::Version
|
|
138
152
|
version: '10.0'
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: fog-local
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - "~>"
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '0.3'
|
|
160
|
+
type: :development
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - "~>"
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: '0.3'
|
|
139
167
|
description:
|
|
140
168
|
email:
|
|
141
169
|
- ryan@outstand.com
|
|
@@ -144,19 +172,20 @@ executables:
|
|
|
144
172
|
extensions: []
|
|
145
173
|
extra_rdoc_files: []
|
|
146
174
|
files:
|
|
175
|
+
- ".dockerignore"
|
|
147
176
|
- ".gitignore"
|
|
148
177
|
- Dockerfile
|
|
149
178
|
- Dockerfile.release
|
|
150
179
|
- Gemfile
|
|
180
|
+
- LICENSE
|
|
151
181
|
- README.md
|
|
152
182
|
- Rakefile
|
|
153
183
|
- bin/console
|
|
154
184
|
- bin/setup
|
|
185
|
+
- build_dev.sh
|
|
155
186
|
- consul_bridge.gemspec
|
|
156
|
-
- docker-entrypoint.sh
|
|
157
187
|
- exe/consul_bridge
|
|
158
188
|
- lib/consul_bridge.rb
|
|
159
|
-
- lib/consul_bridge/base.rb
|
|
160
189
|
- lib/consul_bridge/bootstrap_consul.rb
|
|
161
190
|
- lib/consul_bridge/bootstrap_consul_actor.rb
|
|
162
191
|
- lib/consul_bridge/cli.rb
|
|
@@ -168,6 +197,8 @@ files:
|
|
|
168
197
|
- lib/consul_bridge/monitor_docker_events_actor.rb
|
|
169
198
|
- lib/consul_bridge/run_bridge.rb
|
|
170
199
|
- lib/consul_bridge/version.rb
|
|
200
|
+
- scripts/docker-entrypoint.sh
|
|
201
|
+
- scripts/fetch-bundler-data.sh
|
|
171
202
|
homepage: https://github.com/outstand/consul_bridge
|
|
172
203
|
licenses: []
|
|
173
204
|
metadata: {}
|
|
@@ -187,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
187
218
|
version: '0'
|
|
188
219
|
requirements: []
|
|
189
220
|
rubyforge_project:
|
|
190
|
-
rubygems_version: 2.4
|
|
221
|
+
rubygems_version: 2.6.4
|
|
191
222
|
signing_key:
|
|
192
223
|
specification_version: 4
|
|
193
224
|
summary: Discover consul master nodes and join local agent
|
data/docker-entrypoint.sh
DELETED