kontena-plugin-azure 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +9 -0
- data/.gitmodules +0 -0
- data/.rspec +2 -0
- data/.travis.yml +16 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +191 -0
- data/README.md +16 -0
- data/kontena-plugin-azure.gemspec +24 -0
- data/lib/kontena/machine/azure.rb +6 -0
- data/lib/kontena/machine/azure/cloudinit.yml +65 -0
- data/lib/kontena/machine/azure/cloudinit_master.yml +108 -0
- data/lib/kontena/machine/azure/logger.rb +27 -0
- data/lib/kontena/machine/azure/master_provisioner.rb +128 -0
- data/lib/kontena/machine/azure/node_destroyer.rb +53 -0
- data/lib/kontena/machine/azure/node_provisioner.rb +132 -0
- data/lib/kontena/plugin/azure.rb +7 -0
- data/lib/kontena/plugin/azure/master/create_command.rb +44 -0
- data/lib/kontena/plugin/azure/master_command.rb +9 -0
- data/lib/kontena/plugin/azure/node_command.rb +13 -0
- data/lib/kontena/plugin/azure/nodes/create_command.rb +51 -0
- data/lib/kontena/plugin/azure/nodes/restart_command.rb +31 -0
- data/lib/kontena/plugin/azure/nodes/terminate_command.rb +33 -0
- data/lib/kontena/plugin/azure_command.rb +11 -0
- data/lib/kontena_cli_plugin.rb +5 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTkwYzcyMmU1YjJhNDU3ZWQyMmMwMWE4OGZhNzcwNmM2NmFiNDhiNQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YTc4Y2Q4YmQ0NDhhYjczODUyNjllMGU2ZjQwMDIzZDU0Yzc5M2M2Yg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmE2ODEyMDk4NDQ1YzA5MTZhZGFjZDE2MzJmOTQyZjgyZDBkMWRjNDM4MGQ2
|
10
|
+
NDVhZmE3ZTJhODUzNjA4YmU2M2EwMWE5MWVkNmI4Y2M1YzVhM2RlZDUwNzU5
|
11
|
+
OWE4MmRhYTk4NzNhMDUyNWYzMDg1MDZlMGU5ZTVlZjMxYWE1MTU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODcxMTdiZDBjNjZhOTA2ZjU3NTY1YTMzYmNkYmFkNzY3YzcyYTZhMjVkZTU4
|
14
|
+
ZTI0Y2RjYWE5MGZkNTc2ZTc3NWY5MzVjNmU4N2IxNDExNmZiOTE4MTYyN2Qw
|
15
|
+
YjBmMGM3MTk2ZDVhMGVlMDcwMjM0YTZiZDczODI4ZjVhMjc2MDQ=
|
data/.gitignore
ADDED
data/.gitmodules
ADDED
File without changes
|
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0.0-p648
|
4
|
+
- 2.1.8
|
5
|
+
- 2.2.3
|
6
|
+
- 2.3.1
|
7
|
+
env:
|
8
|
+
- secure: "ZOFME6zSqgS392YnJDqq5q6bpQ6O1ZLxMyK8TNsfd9y65a/ThUyoTHXHfxq28y/kraPeM3mpV2QUS8cNP5QoQmOVl3QTJpdZBAEn6/eFy3vWKws/Mw1Vzq4cxpMeehPMqfsYgaGoCfbsGY3wCH1ZFsRIf2jKrC58bM9Tf86Vh3bwSm6XNfBPxf7wJ1PnKv1Xv9QVqwp+axXBS/a3Qpvk8Y9oPDl3FqRsLbFnFNW4Xkyme5bz6h2KEkF/AXUIO664BxnxiTD4h1gpDA9QEi64RISWt++WMEQCR4oOLqu+x5TvyMXBZA25a+Z0VtER442Gln02DkX+nnVTwen53ssNQEEtV8gtsyPoNdS7B2UfpQtAFf7YTs9noDRV22fNBUeQJsi3HsKT2qtQb36F8PAxS2oifjpMNfxf80HqqcG3AmW72lTvmGQdCus4yCYLXmQyF6QtdSk0DglVrb58LaTzE8ovQNJVFlXshOI31Zi84aOXCKexB+haaF5oOAINQXAj793AB02chgErDsIY31y6g+Nq149RalZlv1AmQDSqQ35bUrU1pugN1Zzl2jzBqElHPrbCxexk/PNoOUKf5rMy4SfqLb9QMSkfmgaV7GRH+avkE9ThzF4wi+5lqnWpuznK/2vs9wOPE9jDLWLM/LeYXGVNNlGI782OVAcV/V1i8XA="
|
9
|
+
cache: bundler
|
10
|
+
script: bundle install && bundle exec rspec spec/
|
11
|
+
deploy:
|
12
|
+
provider: rubygems
|
13
|
+
api_key: $GEM_TOKEN
|
14
|
+
gem: kontena-plugin-azure
|
15
|
+
on:
|
16
|
+
tags: true
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
Copyright 2015 Kontena, Inc.
|
180
|
+
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
182
|
+
you may not use this file except in compliance with the License.
|
183
|
+
You may obtain a copy of the License at
|
184
|
+
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
186
|
+
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
190
|
+
See the License for the specific language governing permissions and
|
191
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Kontena Azure Plugin
|
2
|
+
|
3
|
+
This plugin provides support for Azure provisioning to Kontena CLI.
|
4
|
+
|
5
|
+
|
6
|
+
## Contributing
|
7
|
+
|
8
|
+
1. Fork it ( https://github.com/kontena/kontena-plugin-azure )
|
9
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
10
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
11
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
12
|
+
5. Create a new Pull Request
|
13
|
+
|
14
|
+
## License
|
15
|
+
|
16
|
+
Kontena is licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE.txt) for full license text.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kontena/plugin/azure'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "kontena-plugin-azure"
|
8
|
+
spec.version = Kontena::Plugin::Azure::VERSION
|
9
|
+
spec.authors = ["Kontena, Inc."]
|
10
|
+
spec.email = ["info@kontena.io"]
|
11
|
+
|
12
|
+
spec.summary = "Kontena Azure plugin"
|
13
|
+
spec.description = "Kontena Microsoft Azure plugin"
|
14
|
+
spec.homepage = "https://github.com/kontena/kontena-plugin-azure"
|
15
|
+
spec.license = "Apache-2.0"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'kontena-cli', '>= 0.15.0.rc1'
|
21
|
+
spec.add_runtime_dependency 'azure', '0.7.0'
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#cloud-config
|
2
|
+
write_files:
|
3
|
+
- path: /etc/kontena-agent.env
|
4
|
+
permissions: 0600
|
5
|
+
owner: root
|
6
|
+
content: |
|
7
|
+
KONTENA_URI="<%= master_uri %>"
|
8
|
+
KONTENA_TOKEN="<%= grid_token %>"
|
9
|
+
KONTENA_PEER_INTERFACE=eth1
|
10
|
+
KONTENA_VERSION=<%= version %>
|
11
|
+
- path: /etc/systemd/system/docker.service.d/50-kontena.conf
|
12
|
+
content: |
|
13
|
+
[Service]
|
14
|
+
Environment='DOCKER_OPTS=--insecure-registry="10.81.0.0/19" --bip="172.17.43.1/16"'
|
15
|
+
Environment='DOCKER_CGROUPS=--exec-opt native.cgroupdriver=cgroupfs'
|
16
|
+
- path: /etc/sysctl.d/99-inotify.conf
|
17
|
+
owner: root
|
18
|
+
permissions: 0644
|
19
|
+
content: |
|
20
|
+
fs.inotify.max_user_instances = 8192
|
21
|
+
- path: /etc/resolv.conf
|
22
|
+
permissions: 0644
|
23
|
+
owner: root
|
24
|
+
content: |
|
25
|
+
nameserver 172.17.43.1
|
26
|
+
nameserver 8.8.8.8
|
27
|
+
nameserver 8.8.4.4
|
28
|
+
coreos:
|
29
|
+
units:
|
30
|
+
- name: 10-weave.network
|
31
|
+
runtime: false
|
32
|
+
content: |
|
33
|
+
[Match]
|
34
|
+
Type=bridge
|
35
|
+
Name=weave*
|
36
|
+
|
37
|
+
[Network]
|
38
|
+
- name: kontena-agent.service
|
39
|
+
command: start
|
40
|
+
enable: true
|
41
|
+
content: |
|
42
|
+
[Unit]
|
43
|
+
Description=kontena-agent
|
44
|
+
After=network-online.target
|
45
|
+
After=docker.service
|
46
|
+
Description=Kontena Agent
|
47
|
+
Documentation=http://www.kontena.io/
|
48
|
+
Requires=network-online.target
|
49
|
+
Requires=docker.service
|
50
|
+
|
51
|
+
[Service]
|
52
|
+
Restart=always
|
53
|
+
RestartSec=5
|
54
|
+
EnvironmentFile=/etc/kontena-agent.env
|
55
|
+
ExecStartPre=-/usr/bin/docker stop kontena-agent
|
56
|
+
ExecStartPre=-/usr/bin/docker rm kontena-agent
|
57
|
+
ExecStartPre=/usr/bin/docker pull kontena/agent:${KONTENA_VERSION}
|
58
|
+
ExecStart=/usr/bin/docker run --name kontena-agent \
|
59
|
+
-e KONTENA_URI=${KONTENA_URI} \
|
60
|
+
-e KONTENA_TOKEN=${KONTENA_TOKEN} \
|
61
|
+
-e KONTENA_PEER_INTERFACE=${KONTENA_PEER_INTERFACE} \
|
62
|
+
-v=/var/run/docker.sock:/var/run/docker.sock \
|
63
|
+
-v=/etc/kontena-agent.env:/etc/kontena.env \
|
64
|
+
--net=host \
|
65
|
+
kontena/agent:${KONTENA_VERSION}
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#cloud-config
|
2
|
+
write_files:
|
3
|
+
- path: /etc/kontena-server.env
|
4
|
+
permissions: 0600
|
5
|
+
owner: root
|
6
|
+
content: |
|
7
|
+
KONTENA_VERSION=<%= version %>
|
8
|
+
KONTENA_VAULT_KEY=<%= vault_secret %>
|
9
|
+
KONTENA_VAULT_IV=<%= vault_iv %>
|
10
|
+
<% if ssl_cert %>SSL_CERT="/etc/kontena-server.pem"
|
11
|
+
|
12
|
+
- path: /etc/kontena-server.pem
|
13
|
+
permissions: 0600
|
14
|
+
owner: root
|
15
|
+
content: | <% ssl_cert.split(/\n/).each do |row| %>
|
16
|
+
<%= row %><% end %><% end %>
|
17
|
+
- path: /opt/bin/kontena-haproxy.sh
|
18
|
+
permissions: 0755
|
19
|
+
owner: root
|
20
|
+
content: |
|
21
|
+
#!/bin/sh
|
22
|
+
if [ -n "$SSL_CERT" ]; then
|
23
|
+
SSL_CERT=$(awk 1 ORS='\\n' $SSL_CERT)
|
24
|
+
else
|
25
|
+
SSL_CERT="**None**"
|
26
|
+
fi
|
27
|
+
/usr/bin/docker run --name=kontena-server-haproxy \
|
28
|
+
--link kontena-server-api:kontena-server-api \
|
29
|
+
-e SSL_CERT="$SSL_CERT" \
|
30
|
+
-p 80:80 -p 443:443 kontena/haproxy:latest
|
31
|
+
coreos:
|
32
|
+
units:
|
33
|
+
- name: kontena-server-mongo.service
|
34
|
+
command: start
|
35
|
+
enable: true
|
36
|
+
content: |
|
37
|
+
[Unit]
|
38
|
+
Description=kontena-server-mongo
|
39
|
+
After=network-online.target
|
40
|
+
After=docker.service
|
41
|
+
Description=Kontena Server MongoDB
|
42
|
+
Documentation=http://www.mongodb.org/
|
43
|
+
Requires=network-online.target
|
44
|
+
Requires=docker.service
|
45
|
+
|
46
|
+
[Service]
|
47
|
+
Restart=always
|
48
|
+
RestartSec=5
|
49
|
+
ExecStartPre=-/usr/bin/docker pull mongo:3.0
|
50
|
+
ExecStartPre=-/usr/bin/docker create --name=kontena-server-mongo-data mongo:3.0
|
51
|
+
ExecStartPre=-/usr/bin/docker stop kontena-server-mongo
|
52
|
+
ExecStartPre=-/usr/bin/docker rm kontena-server-mongo
|
53
|
+
ExecStart=/usr/bin/docker run --name=kontena-server-mongo \
|
54
|
+
--volumes-from=kontena-server-mongo-data \
|
55
|
+
mongo:3.0 mongod --smallfiles
|
56
|
+
|
57
|
+
- name: kontena-server-api.service
|
58
|
+
command: start
|
59
|
+
enable: true
|
60
|
+
content: |
|
61
|
+
[Unit]
|
62
|
+
Description=kontena-server-api
|
63
|
+
After=network-online.target
|
64
|
+
After=docker.service
|
65
|
+
After=kontena-server-mongo.service
|
66
|
+
Description=Kontena Master
|
67
|
+
Documentation=http://www.kontena.io/
|
68
|
+
Requires=network-online.target
|
69
|
+
Requires=docker.service
|
70
|
+
Requires=kontena-server-mongo.service
|
71
|
+
|
72
|
+
[Service]
|
73
|
+
Restart=always
|
74
|
+
RestartSec=5
|
75
|
+
EnvironmentFile=/etc/kontena-server.env
|
76
|
+
EnvironmentFile=-/etc/kontena-server.custom.env
|
77
|
+
ExecStartPre=-/usr/bin/docker stop kontena-server-api
|
78
|
+
ExecStartPre=-/usr/bin/docker rm kontena-server-api
|
79
|
+
ExecStartPre=-/usr/bin/docker pull kontena/server:${KONTENA_VERSION}
|
80
|
+
ExecStart=/usr/bin/docker run --name kontena-server-api \
|
81
|
+
--link kontena-server-mongo:mongodb \
|
82
|
+
-e MONGODB_URI=mongodb://mongodb:27017/kontena_server \
|
83
|
+
-e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \
|
84
|
+
<% if auth_server %>-e AUTH_API_URL=<%= auth_server %><% end %> \
|
85
|
+
kontena/server:${KONTENA_VERSION}
|
86
|
+
|
87
|
+
- name: kontena-server-haproxy.service
|
88
|
+
command: start
|
89
|
+
enable: true
|
90
|
+
content: |
|
91
|
+
[Unit]
|
92
|
+
Description=kontena-server-haproxy
|
93
|
+
After=network-online.target
|
94
|
+
After=docker.service
|
95
|
+
Description=Kontena Server HAProxy
|
96
|
+
Documentation=http://www.kontena.io/
|
97
|
+
Requires=network-online.target
|
98
|
+
Requires=docker.service
|
99
|
+
|
100
|
+
[Service]
|
101
|
+
Restart=always
|
102
|
+
RestartSec=5
|
103
|
+
EnvironmentFile=/etc/kontena-server.env
|
104
|
+
EnvironmentFile=-/etc/kontena-server.custom.env
|
105
|
+
ExecStartPre=-/usr/bin/docker stop kontena-server-haproxy
|
106
|
+
ExecStartPre=-/usr/bin/docker rm kontena-server-haproxy
|
107
|
+
ExecStartPre=-/usr/bin/docker pull kontena/haproxy:latest
|
108
|
+
ExecStart=/opt/bin/kontena-haproxy.sh
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Kontena
|
2
|
+
module Machine
|
3
|
+
module Azure
|
4
|
+
class Logger
|
5
|
+
def info(msg)
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
def error_with_exit(msg)
|
10
|
+
puts msg.colorize(:red)
|
11
|
+
end
|
12
|
+
|
13
|
+
def warn(msg)
|
14
|
+
puts msg.colorize(:yellow)
|
15
|
+
end
|
16
|
+
|
17
|
+
def error(msg)
|
18
|
+
puts msg.colorize(:red)
|
19
|
+
end
|
20
|
+
|
21
|
+
def exception_message(msg)
|
22
|
+
puts msg.colorize(:red)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'erb'
|
3
|
+
require 'open3'
|
4
|
+
require 'shell-spinner'
|
5
|
+
|
6
|
+
module Kontena
|
7
|
+
module Machine
|
8
|
+
module Azure
|
9
|
+
class MasterProvisioner
|
10
|
+
include Kontena::Machine::RandomName
|
11
|
+
|
12
|
+
attr_reader :client, :http_client
|
13
|
+
|
14
|
+
# @param [String] subscription_id Azure subscription id
|
15
|
+
# @param [String] certificate Path to Azure management certificate
|
16
|
+
def initialize(subscription_id, certificate)
|
17
|
+
|
18
|
+
abort('Invalid management certificate') unless File.exists?(File.expand_path(certificate))
|
19
|
+
|
20
|
+
@client = ::Azure
|
21
|
+
client.management_certificate = certificate
|
22
|
+
client.subscription_id = subscription_id
|
23
|
+
client.vm_management.initialize_external_logger(Logger.new) # We don't want all the output
|
24
|
+
end
|
25
|
+
|
26
|
+
def run!(opts)
|
27
|
+
abort('Invalid ssh key') unless File.exists?(File.expand_path(opts[:ssh_key]))
|
28
|
+
if opts[:ssl_cert]
|
29
|
+
abort('Invalid ssl cert') unless File.exists?(File.expand_path(opts[:ssl_cert]))
|
30
|
+
ssl_cert = File.read(File.expand_path(opts[:ssl_cert]))
|
31
|
+
end
|
32
|
+
cloud_service_name = generate_cloud_service_name
|
33
|
+
vm_name = cloud_service_name
|
34
|
+
master_url = ''
|
35
|
+
ShellSpinner "Creating Azure Virtual Machine #{vm_name.colorize(:cyan)}" do
|
36
|
+
if opts[:virtual_network].nil?
|
37
|
+
location = opts[:location].downcase.gsub(' ', '-')
|
38
|
+
default_network_name = "kontena-#{location}"
|
39
|
+
create_virtual_network(default_network_name, opts[:location]) unless virtual_network_exist?(default_network_name)
|
40
|
+
opts[:virtual_network] = default_network_name
|
41
|
+
opts[:subnet] = 'subnet-1'
|
42
|
+
end
|
43
|
+
|
44
|
+
userdata_vars = {
|
45
|
+
ssl_cert: ssl_cert,
|
46
|
+
auth_server: opts[:auth_server],
|
47
|
+
version: opts[:version],
|
48
|
+
vault_secret: opts[:vault_secret],
|
49
|
+
vault_iv: opts[:vault_iv]
|
50
|
+
}
|
51
|
+
|
52
|
+
params = {
|
53
|
+
vm_name: vm_name,
|
54
|
+
vm_user: 'core',
|
55
|
+
location: opts[:location],
|
56
|
+
image: '2b171e93f07c4903bcad35bda10acf22__CoreOS-Stable-1010.5.0',
|
57
|
+
custom_data: Base64.encode64(user_data(userdata_vars)),
|
58
|
+
ssh_key: opts[:ssh_key]
|
59
|
+
}
|
60
|
+
|
61
|
+
options = {
|
62
|
+
cloud_service_name: cloud_service_name,
|
63
|
+
deployment_name: vm_name,
|
64
|
+
virtual_network_name: opts[:virtual_network],
|
65
|
+
subnet_name: opts[:subnet],
|
66
|
+
tcp_endpoints: '80,443',
|
67
|
+
private_key_file: File.expand_path(opts[:ssh_key]),
|
68
|
+
ssh_port: 22,
|
69
|
+
vm_size: opts[:size],
|
70
|
+
}
|
71
|
+
|
72
|
+
|
73
|
+
virtual_machine = client.vm_management.create_virtual_machine(params,options)
|
74
|
+
|
75
|
+
if opts[:ssl_cert]
|
76
|
+
master_url = "https://#{virtual_machine.ipaddress}"
|
77
|
+
else
|
78
|
+
master_url = "http://#{virtual_machine.ipaddress}"
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
Excon.defaults[:ssl_verify_peer] = false
|
83
|
+
@http_client = Excon.new("#{master_url}", :connect_timeout => 10)
|
84
|
+
|
85
|
+
ShellSpinner "Waiting for #{vm_name.colorize(:cyan)} to start" do
|
86
|
+
sleep 5 until master_running?
|
87
|
+
end
|
88
|
+
|
89
|
+
puts "Kontena Master is now running at #{master_url}"
|
90
|
+
puts "Use #{"kontena login #{master_url}".colorize(:light_black)} to complete Kontena Master setup"
|
91
|
+
end
|
92
|
+
|
93
|
+
def erb(template, vars)
|
94
|
+
ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
|
95
|
+
end
|
96
|
+
|
97
|
+
def user_data(vars)
|
98
|
+
cloudinit_template = File.join(__dir__ , '/cloudinit_master.yml')
|
99
|
+
erb(File.read(cloudinit_template), vars)
|
100
|
+
end
|
101
|
+
|
102
|
+
def master_running?
|
103
|
+
http_client.get(path: '/').status == 200
|
104
|
+
rescue
|
105
|
+
false
|
106
|
+
end
|
107
|
+
|
108
|
+
def generate_cloud_service_name
|
109
|
+
"kontena-master-#{generate_name}-#{rand(1..99)}"
|
110
|
+
end
|
111
|
+
|
112
|
+
def cloud_service(name)
|
113
|
+
client.cloud_service_management.get_cloud_service(name)
|
114
|
+
end
|
115
|
+
|
116
|
+
def virtual_network_exist?(name)
|
117
|
+
client.network_management.list_virtual_networks.find{|n| n.name == name}
|
118
|
+
end
|
119
|
+
|
120
|
+
def create_virtual_network(name, location)
|
121
|
+
address_space = ['10.0.0.0/20']
|
122
|
+
options = {subnet: [{:name => 'subnet-1', :ip_address=>'10.0.0.0', :cidr=>23}]}
|
123
|
+
client.network_management.set_network_configuration(name, location, address_space, options)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'shell-spinner'
|
2
|
+
require 'azure/virtual_machine_image_management/virtual_machine_image_management_service'
|
3
|
+
|
4
|
+
module Kontena
|
5
|
+
module Machine
|
6
|
+
module Azure
|
7
|
+
class NodeDestroyer
|
8
|
+
|
9
|
+
attr_reader :client, :api_client
|
10
|
+
|
11
|
+
# @param [Kontena::Client] api_client Kontena api client
|
12
|
+
# @param [String] subscription_id Azure subscription id
|
13
|
+
# @param [String] certificate Path to Azure management certificate
|
14
|
+
def initialize(api_client, subscription_id, certificate)
|
15
|
+
@api_client = api_client
|
16
|
+
abort('Invalid management certificate') unless File.exists?(File.expand_path(certificate))
|
17
|
+
|
18
|
+
@client = ::Azure
|
19
|
+
client.management_certificate = certificate
|
20
|
+
client.subscription_id = subscription_id
|
21
|
+
client.vm_management.initialize_external_logger(Logger.new) # We don't want all the output
|
22
|
+
end
|
23
|
+
|
24
|
+
def run!(grid, name)
|
25
|
+
ShellSpinner "Terminating Azure Virtual Machine #{name.colorize(:cyan)} " do
|
26
|
+
vm = client.vm_management.get_virtual_machine(name, cloud_service_name(name, grid['name']))
|
27
|
+
if vm
|
28
|
+
out = StringIO.new
|
29
|
+
$stdout = out # to avoid debug data (https://github.com/Azure/azure-sdk-for-ruby/issues/200)
|
30
|
+
client.vm_management.delete_virtual_machine(name, cloud_service_name(name, grid['name']))
|
31
|
+
storage_account = client.storage_management.list_storage_accounts.find{|a| a.label == cloud_service_name(name, grid['name'])}
|
32
|
+
client.storage_management.delete_storage_account(storage_account.name) if storage_account
|
33
|
+
$stdout = STDOUT
|
34
|
+
else
|
35
|
+
abort "\nCannot find Virtual Machine #{name.colorize(:cyan)} in Azure"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
node = api_client.get("grids/#{grid['id']}/nodes")['nodes'].find{|n| n['name'] == name}
|
40
|
+
if node
|
41
|
+
ShellSpinner "Removing node #{name.colorize(:cyan)} from grid #{grid['name'].colorize(:cyan)} " do
|
42
|
+
api_client.delete("grids/#{grid['id']}/nodes/#{name}")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def cloud_service_name(vm_name, grid)
|
48
|
+
"kontena-#{grid}-#{vm_name}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'erb'
|
3
|
+
require 'open3'
|
4
|
+
require 'base64'
|
5
|
+
require 'shell-spinner'
|
6
|
+
|
7
|
+
module Kontena
|
8
|
+
module Machine
|
9
|
+
module Azure
|
10
|
+
class NodeProvisioner
|
11
|
+
include Kontena::Machine::RandomName
|
12
|
+
|
13
|
+
attr_reader :client, :api_client
|
14
|
+
|
15
|
+
# @param [Kontena::Client] api_client Kontena api client
|
16
|
+
# @param [String] subscription_id Azure subscription id
|
17
|
+
# @param [String] certificate Path to Azure management certificate
|
18
|
+
def initialize(api_client, subscription_id, certificate)
|
19
|
+
@api_client = api_client
|
20
|
+
abort('Invalid management certificate') unless File.exists?(File.expand_path(certificate))
|
21
|
+
|
22
|
+
@client = ::Azure
|
23
|
+
client.management_certificate = File.expand_path(certificate)
|
24
|
+
client.subscription_id = subscription_id
|
25
|
+
client.vm_management.initialize_external_logger(Logger.new) # We don't want all the output
|
26
|
+
end
|
27
|
+
|
28
|
+
def run!(opts)
|
29
|
+
abort('Invalid ssh key') unless File.exists?(File.expand_path(opts[:ssh_key]))
|
30
|
+
node = nil
|
31
|
+
vm_name = opts[:name] || generate_name
|
32
|
+
cloud_service_name = generate_cloud_service_name(vm_name, opts[:grid])
|
33
|
+
|
34
|
+
ShellSpinner "Creating Azure Virtual Machine #{vm_name.colorize(:cyan)}" do
|
35
|
+
if opts[:virtual_network].nil?
|
36
|
+
location = opts[:location].downcase.gsub(' ', '-')
|
37
|
+
default_network_name = "kontena-#{location}"
|
38
|
+
create_virtual_network(default_network_name, opts[:location]) unless virtual_network_exist?(default_network_name)
|
39
|
+
opts[:virtual_network] = default_network_name
|
40
|
+
opts[:subnet] = 'subnet-1'
|
41
|
+
end
|
42
|
+
|
43
|
+
userdata_vars = {
|
44
|
+
version: opts[:version],
|
45
|
+
master_uri: opts[:master_uri],
|
46
|
+
grid_token: opts[:grid_token],
|
47
|
+
}
|
48
|
+
|
49
|
+
params = {
|
50
|
+
vm_name: vm_name,
|
51
|
+
vm_user: 'core',
|
52
|
+
location: opts[:location],
|
53
|
+
image: '2b171e93f07c4903bcad35bda10acf22__CoreOS-Stable-1010.5.0',
|
54
|
+
custom_data: Base64.encode64(user_data(userdata_vars)),
|
55
|
+
ssh_key: File.expand_path(opts[:ssh_key])
|
56
|
+
}
|
57
|
+
options = {
|
58
|
+
cloud_service_name: cloud_service_name,
|
59
|
+
deployment_name: vm_name,
|
60
|
+
virtual_network_name: opts[:virtual_network],
|
61
|
+
subnet_name: opts[:subnet],
|
62
|
+
tcp_endpoints: '80',
|
63
|
+
private_key_file: opts[:ssh_key],
|
64
|
+
ssh_port: 22,
|
65
|
+
vm_size: opts[:size],
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
client.vm_management.create_virtual_machine(params,options)
|
70
|
+
end
|
71
|
+
ShellSpinner "Waiting for node #{vm_name.colorize(:cyan)} join to grid #{opts[:grid].colorize(:cyan)} " do
|
72
|
+
sleep 2 until node = vm_exists_in_grid?(opts[:grid], vm_name)
|
73
|
+
end
|
74
|
+
if node
|
75
|
+
labels = [
|
76
|
+
"region=#{cloud_service(cloud_service_name).location}",
|
77
|
+
"az=#{cloud_service(cloud_service_name).location}",
|
78
|
+
"provider=azure"
|
79
|
+
]
|
80
|
+
set_labels(node, labels)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def user_data(vars)
|
85
|
+
cloudinit_template = File.join(__dir__ , '/cloudinit.yml')
|
86
|
+
erb(File.read(cloudinit_template), vars)
|
87
|
+
end
|
88
|
+
|
89
|
+
def generate_name
|
90
|
+
"#{super}-#{rand(1..99)}"
|
91
|
+
end
|
92
|
+
|
93
|
+
def generate_cloud_service_name(name, grid)
|
94
|
+
"kontena-#{grid}-#{name}"
|
95
|
+
end
|
96
|
+
|
97
|
+
def vm_exists_in_grid?(grid, name)
|
98
|
+
api_client.get("grids/#{grid}/nodes")['nodes'].find{|n| n['name'] == name}
|
99
|
+
end
|
100
|
+
|
101
|
+
def erb(template, vars)
|
102
|
+
ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
|
103
|
+
end
|
104
|
+
|
105
|
+
def cloud_service_exist?(name)
|
106
|
+
cloud_service(name)
|
107
|
+
end
|
108
|
+
|
109
|
+
def cloud_service(name)
|
110
|
+
client.cloud_service_management.get_cloud_service(name)
|
111
|
+
end
|
112
|
+
|
113
|
+
def virtual_network_exist?(name)
|
114
|
+
client.network_management.list_virtual_networks.find{|n| n.name == name}
|
115
|
+
end
|
116
|
+
|
117
|
+
def create_virtual_network(name, location)
|
118
|
+
address_space = ['10.0.0.0/20']
|
119
|
+
options = {subnet: [{:name => 'subnet-1', :ip_address=>'10.0.0.0', :cidr=>23}]}
|
120
|
+
client.network_management.set_network_configuration(name, location, address_space, options)
|
121
|
+
end
|
122
|
+
|
123
|
+
def set_labels(node, labels)
|
124
|
+
data = {}
|
125
|
+
data[:labels] = labels
|
126
|
+
api_client.put("nodes/#{node['id']}", data, {}, {'Kontena-Grid-Token' => node['grid']['token']})
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
module Kontena::Plugin::Azure::Master
|
4
|
+
class CreateCommand < Kontena::Command
|
5
|
+
include Kontena::Cli::Common
|
6
|
+
|
7
|
+
option "--subscription-id", "SUBSCRIPTION ID", "Azure subscription id", required: true
|
8
|
+
option "--subscription-cert", "CERTIFICATE", "Path to Azure management certificate", attribute_name: :certificate, required: true
|
9
|
+
option "--size", "SIZE", "SIZE", default: 'Small'
|
10
|
+
option "--network", "NETWORK", "Virtual Network name"
|
11
|
+
option "--subnet", "SUBNET", "Subnet name"
|
12
|
+
option "--ssh-key", "SSH KEY", "SSH private key file", required: true
|
13
|
+
option "--location", "LOCATION", "Location", default: 'West Europe'
|
14
|
+
option "--ssl-cert", "SSL CERT", "SSL certificate file"
|
15
|
+
option "--vault-secret", "VAULT_SECRET", "Secret key for Vault"
|
16
|
+
option "--vault-iv", "VAULT_IV", "Initialization vector for Vault"
|
17
|
+
option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url"
|
18
|
+
option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
|
19
|
+
|
20
|
+
def execute
|
21
|
+
require 'kontena/machine/azure'
|
22
|
+
provisioner = provisioner(subscription_id, certificate)
|
23
|
+
provisioner.run!(
|
24
|
+
ssh_key: ssh_key,
|
25
|
+
ssl_cert: ssl_cert,
|
26
|
+
size: size,
|
27
|
+
virtual_network: network,
|
28
|
+
subnet: subnet,
|
29
|
+
location: location,
|
30
|
+
auth_server: auth_provider_url,
|
31
|
+
version: version,
|
32
|
+
vault_secret: vault_secret || SecureRandom.hex(24),
|
33
|
+
vault_iv: vault_iv || SecureRandom.hex(24)
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
# @param [String] subscription_id
|
38
|
+
# @param [String] certificate
|
39
|
+
# @return [Kontena::Machine::Azure::MasterProvisioner]
|
40
|
+
def provisioner(subscription_id, certificate)
|
41
|
+
Kontena::Machine::Azure::MasterProvisioner.new
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'nodes/create_command'
|
2
|
+
require_relative 'nodes/restart_command'
|
3
|
+
require_relative 'nodes/terminate_command'
|
4
|
+
|
5
|
+
class Kontena::Plugin::Azure::NodeCommand < Kontena::Command
|
6
|
+
|
7
|
+
subcommand "create", "Create a new node to Azure", Kontena::Plugin::Azure::Nodes::CreateCommand
|
8
|
+
subcommand "restart", "Restart Azure node", Kontena::Plugin::Azure::Nodes::RestartCommand
|
9
|
+
subcommand "terminate", "Terminate Azure node", Kontena::Plugin::Azure::Nodes::TerminateCommand
|
10
|
+
|
11
|
+
def execute
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Kontena::Plugin::Azure::Nodes
|
2
|
+
class CreateCommand < Kontena::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
include Kontena::Cli::GridOptions
|
5
|
+
|
6
|
+
option "--subscription-id", "SUBSCRIPTION ID", "Azure subscription id", required: true
|
7
|
+
option "--subscription-cert", "CERTIFICATE", "Path to Azure management certificate", attribute_name: :certificate, required: true
|
8
|
+
option "--size", "SIZE", "SIZE", default: 'Small'
|
9
|
+
option "--network", "NETWORK", "Virtual Network name"
|
10
|
+
option "--subnet", "SUBNET", "Subnet name"
|
11
|
+
option "--ssh-key", "SSH KEY", "SSH private key file", required: true
|
12
|
+
option "--location", "LOCATION", "Location", default: 'West Europe'
|
13
|
+
option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
|
14
|
+
|
15
|
+
parameter "[NAME]", "Node name"
|
16
|
+
|
17
|
+
def execute
|
18
|
+
require_api_url
|
19
|
+
require_current_grid
|
20
|
+
|
21
|
+
require 'kontena/machine/azure'
|
22
|
+
grid = fetch_grid
|
23
|
+
provisioner = provisioner(client(require_token), subscription_id, certificate)
|
24
|
+
provisioner.run!(
|
25
|
+
master_uri: api_url,
|
26
|
+
grid_token: grid['token'],
|
27
|
+
grid: current_grid,
|
28
|
+
ssh_key: ssh_key,
|
29
|
+
name: name,
|
30
|
+
size: size,
|
31
|
+
virtual_network: network,
|
32
|
+
subnet: subnet,
|
33
|
+
location: location,
|
34
|
+
version: version
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
# @param [Kontena::Client] client
|
39
|
+
# @param [String] subscription_id
|
40
|
+
# @param [String] certificate
|
41
|
+
# @return [Kontena::Machine::Azure::NodeProvisioner]
|
42
|
+
def provisioner(client, subscription_id, certificate)
|
43
|
+
Kontena::Machine::Azure::NodeProvisioner.new
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [Hash]
|
47
|
+
def fetch_grid
|
48
|
+
client(require_token).get("grids/#{current_grid}")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Kontena::Plugin::Azure::Nodes
|
2
|
+
class RestartCommand < Kontena::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
include Kontena::Cli::GridOptions
|
5
|
+
|
6
|
+
parameter "NAME", "Node name"
|
7
|
+
option "--subscription-id", "SUBSCRIPTION ID", "Azure subscription id", required: true
|
8
|
+
option "--subscription-cert", "CERTIFICATE", "Path to Azure management certificate", attribute_name: :certificate, required: true
|
9
|
+
|
10
|
+
def execute
|
11
|
+
require_api_url
|
12
|
+
require_current_grid
|
13
|
+
|
14
|
+
require 'kontena/machine/azure'
|
15
|
+
|
16
|
+
client = ::Azure
|
17
|
+
client.management_certificate = certificate
|
18
|
+
client.subscription_id = subscription_id
|
19
|
+
|
20
|
+
client.vm_management.initialize_external_logger(Kontena::Machine::Azure::Logger.new) # We don't want all the output
|
21
|
+
ShellSpinner "Restarting Azure VM #{name.colorize(:cyan)} " do
|
22
|
+
vm = client.vm_management.get_virtual_machine(name, "kontena-#{current_grid}-#{name}")
|
23
|
+
if vm
|
24
|
+
client.vm_management.restart_virtual_machine(name, "kontena-#{current_grid}-#{name}")
|
25
|
+
else
|
26
|
+
abort "\nCannot find Virtual Machine #{name.colorize(:cyan)} in Azure"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Kontena::Plugin::Azure::Nodes
|
2
|
+
class TerminateCommand < Kontena::Command
|
3
|
+
include Kontena::Cli::Common
|
4
|
+
include Kontena::Cli::GridOptions
|
5
|
+
|
6
|
+
parameter "NAME", "Node name"
|
7
|
+
option "--subscription-id", "SUBSCRIPTION ID", "Azure subscription id", required: true
|
8
|
+
option "--subscription-cert", "CERTIFICATE", "Path to Azure management certificate", attribute_name: :certificate, required: true
|
9
|
+
|
10
|
+
def execute
|
11
|
+
require_api_url
|
12
|
+
require_current_grid
|
13
|
+
|
14
|
+
require 'kontena/machine/azure'
|
15
|
+
|
16
|
+
grid = fetch_grid
|
17
|
+
destroyer = destroyer(client(require_token), subscription_id, certificate)
|
18
|
+
destroyer.run!(grid, name)
|
19
|
+
end
|
20
|
+
|
21
|
+
def fetch_grid
|
22
|
+
client(require_token).get("grids/#{current_grid}")
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param [Kontena::Client] client
|
26
|
+
# @param [String] subscription_id
|
27
|
+
# @param [String] certificate
|
28
|
+
# @return [Kontena::Machine::Azure::NodeDestroyer]
|
29
|
+
def destroyer(client, subscription_id, certificate)
|
30
|
+
Kontena::Machine::Azure::NodeDestroyer.new(client, subscription_id, certificate)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative 'azure/master_command'
|
2
|
+
require_relative 'azure/node_command'
|
3
|
+
|
4
|
+
class Kontena::Plugin::AzureCommand < Kontena::Command
|
5
|
+
|
6
|
+
subcommand 'master', 'Azure master related commands', Kontena::Plugin::Azure::MasterCommand
|
7
|
+
subcommand 'node', 'Azure node related commands', Kontena::Plugin::Azure::NodeCommand
|
8
|
+
|
9
|
+
def execute
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kontena-plugin-azure
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kontena, Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: kontena-cli
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.15.0.rc1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.15.0.rc1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: azure
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.11'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: Kontena Microsoft Azure plugin
|
70
|
+
email:
|
71
|
+
- info@kontena.io
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .gitmodules
|
78
|
+
- .rspec
|
79
|
+
- .travis.yml
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- kontena-plugin-azure.gemspec
|
84
|
+
- lib/kontena/machine/azure.rb
|
85
|
+
- lib/kontena/machine/azure/cloudinit.yml
|
86
|
+
- lib/kontena/machine/azure/cloudinit_master.yml
|
87
|
+
- lib/kontena/machine/azure/logger.rb
|
88
|
+
- lib/kontena/machine/azure/master_provisioner.rb
|
89
|
+
- lib/kontena/machine/azure/node_destroyer.rb
|
90
|
+
- lib/kontena/machine/azure/node_provisioner.rb
|
91
|
+
- lib/kontena/plugin/azure.rb
|
92
|
+
- lib/kontena/plugin/azure/master/create_command.rb
|
93
|
+
- lib/kontena/plugin/azure/master_command.rb
|
94
|
+
- lib/kontena/plugin/azure/node_command.rb
|
95
|
+
- lib/kontena/plugin/azure/nodes/create_command.rb
|
96
|
+
- lib/kontena/plugin/azure/nodes/restart_command.rb
|
97
|
+
- lib/kontena/plugin/azure/nodes/terminate_command.rb
|
98
|
+
- lib/kontena/plugin/azure_command.rb
|
99
|
+
- lib/kontena_cli_plugin.rb
|
100
|
+
homepage: https://github.com/kontena/kontena-plugin-azure
|
101
|
+
licenses:
|
102
|
+
- Apache-2.0
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.4.5
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Kontena Azure plugin
|
124
|
+
test_files: []
|