dapp 0.13.0 → 0.13.1
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/config/en/net_status.yml +1 -1
- data/lib/dapp.rb +2 -1
- data/lib/dapp/kube/cli/command/kube/deploy.rb +7 -2
- data/lib/dapp/kube/cli/command/kube/dismiss.rb +1 -1
- data/lib/dapp/kube/cli/command/kube/secret_file_encrypt.rb +1 -1
- data/lib/dapp/kube/{kubernetes.rb → client.rb} +65 -15
- data/lib/dapp/kube/client/error.rb +21 -0
- data/lib/dapp/kube/dapp/command/common.rb +1 -1
- data/lib/dapp/kube/dapp/command/deploy.rb +10 -4
- data/lib/dapp/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed07e4ba41f680a79acc2f27a826dec12bf5ba77
|
4
|
+
data.tar.gz: 981b7d0951b7361e9b20ab6469e7d797cabf0de3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 058341b114a2978ca617951f957500227ae76ef4f074c23f6a68e3c9845880ff9778dc435fdd7256fa0b8ba18893bc41748179573498f111869ffe9de8cb3517
|
7
|
+
data.tar.gz: 2251d7ce20c67b6103821aa808da48fde2de2d8a850591155a4eff6bf19288f27bc39636f218d4a096a556b9dd33befd22c75239dbf79997dffffc20c6946507
|
data/config/en/net_status.yml
CHANGED
@@ -112,4 +112,4 @@ en:
|
|
112
112
|
bootstrap_image_not_found: "Bootstrap failed because `%{reason}`: `%{message}`"
|
113
113
|
kubernetes:
|
114
114
|
kube_config_not_found: "Kube config `%{path}` not found!"
|
115
|
-
kube_server_connection_refused: "Kube server `%{url}` connection refused
|
115
|
+
kube_server_connection_refused: "Kube server `%{url}` connection refused: %{error}"
|
data/lib/dapp.rb
CHANGED
@@ -99,7 +99,8 @@ require 'dapp/deployment/dapp/dappfile'
|
|
99
99
|
require 'dapp/deployment/dapp/dapp'
|
100
100
|
require 'dapp/deployment/secret'
|
101
101
|
require 'dapp/kube'
|
102
|
-
require 'dapp/kube/
|
102
|
+
require 'dapp/kube/client'
|
103
|
+
require 'dapp/kube/client/error'
|
103
104
|
require 'dapp/kube/cli/command/base'
|
104
105
|
require 'dapp/kube/cli/command/kube'
|
105
106
|
require 'dapp/kube/cli/command/kube/deploy'
|
@@ -10,7 +10,7 @@ Options:
|
|
10
10
|
BANNER
|
11
11
|
option :namespace,
|
12
12
|
long: '--namespace NAME',
|
13
|
-
|
13
|
+
default: nil
|
14
14
|
|
15
15
|
option :image_version,
|
16
16
|
long: '--image-version IMAGE_VERSION',
|
@@ -20,10 +20,15 @@ BANNER
|
|
20
20
|
long: '--tmp-dir-prefix PREFIX',
|
21
21
|
description: 'Tmp directory prefix (/tmp by default). Used for build process service directories.'
|
22
22
|
|
23
|
+
option :helm_set_options,
|
24
|
+
long: '--set STRING_ARRAY',
|
25
|
+
default: [],
|
26
|
+
proc: proc { |v| composite_options(:helm_set) << v }
|
27
|
+
|
23
28
|
def run(argv = ARGV)
|
24
29
|
self.class.parse_options(self, argv)
|
25
30
|
repo = self.class.required_argument(self, 'repo')
|
26
|
-
::Dapp::Dapp.new(options: cli_options(
|
31
|
+
::Dapp::Dapp.new(options: cli_options(repo: repo)).public_send(run_method)
|
27
32
|
end
|
28
33
|
end
|
29
34
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Dapp
|
2
2
|
module Kube
|
3
|
-
class
|
3
|
+
class Client
|
4
4
|
def initialize(namespace: nil)
|
5
5
|
@namespace = namespace
|
6
6
|
@query_parameters = {}
|
7
7
|
end
|
8
8
|
|
9
9
|
def namespace
|
10
|
-
@namespace || '
|
10
|
+
@namespace || kube_context_config['context']['namespace']
|
11
11
|
end
|
12
12
|
|
13
13
|
# Чтобы не перегружать методы явной передачей namespace.
|
@@ -147,34 +147,84 @@ module Dapp
|
|
147
147
|
|
148
148
|
def with_connection(excon_parameters: {}, &blk)
|
149
149
|
old_ssl_ca_file = Excon.defaults[:ssl_ca_file]
|
150
|
+
old_ssl_cert_store = Excon.defaults[:ssl_cert_store]
|
150
151
|
old_middlewares = Excon.defaults[:middlewares].dup
|
151
152
|
|
152
153
|
begin
|
153
|
-
|
154
|
+
ssl_cert_store = OpenSSL::X509::Store.new
|
155
|
+
if ssl_ca_file = kube_config.fetch('clusters', [{}]).first.fetch('cluster', {}).fetch('certificate-authority', nil)
|
156
|
+
ssl_cert_store.add_file ssl_ca_file
|
157
|
+
elsif ssl_ca_data = kube_config.fetch('clusters', [{}]).first.fetch('cluster', {}).fetch('certificate-authority-data', nil)
|
158
|
+
ssl_cert_store.add_cert OpenSSL::X509::Certificate.new(Base64.decode64(ssl_ca_data))
|
159
|
+
end
|
160
|
+
|
161
|
+
Excon.defaults[:ssl_ca_file] = nil
|
162
|
+
Excon.defaults[:ssl_cert_store] = ssl_cert_store
|
154
163
|
Excon.defaults[:middlewares] << Excon::Middleware::RedirectFollower
|
155
164
|
|
156
|
-
|
165
|
+
connection = begin
|
166
|
+
Excon.new(kube_cluster_config['cluster']['server'], **kube_server_options(excon_parameters)).tap(&:get)
|
167
|
+
rescue Excon::Error::Socket => err
|
168
|
+
raise Error::ConnectionRefused,
|
169
|
+
code: :kube_server_connection_refused,
|
170
|
+
data: { kube_cluster_config: kube_cluster_config, kube_user_config: kube_user_config, error: err.message }
|
171
|
+
end
|
172
|
+
|
173
|
+
return yield connection
|
157
174
|
ensure
|
158
175
|
Excon.defaults[:ssl_ca_file] = old_ssl_ca_file
|
176
|
+
Excon.defaults[:ssl_cert_store] = old_ssl_cert_store
|
159
177
|
Excon.defaults[:middlewares] = old_middlewares
|
160
178
|
end
|
161
179
|
end
|
162
180
|
|
163
|
-
def
|
164
|
-
|
165
|
-
kube_config.fetch('
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
181
|
+
def kube_server_options(excon_parameters = {})
|
182
|
+
{}.tap do |opts|
|
183
|
+
client_cert = kube_config.fetch('users', [{}]).first.fetch('user', {}).fetch('client-certificate', nil)
|
184
|
+
opts[:client_cert] = client_cert if client_cert
|
185
|
+
|
186
|
+
client_cert_data = kube_config.fetch('users', [{}]).first.fetch('user', {}).fetch('client-certificate-data', nil)
|
187
|
+
opts[:client_cert_data] = Base64.decode64(client_cert_data) if client_cert_data
|
188
|
+
|
189
|
+
client_key = kube_config.fetch('users', [{}]).first.fetch('user', {}).fetch('client-key', nil)
|
190
|
+
opts[:client_key] = client_key if client_key
|
191
|
+
|
192
|
+
client_key_data = kube_config.fetch('users', [{}]).first.fetch('user', {}).fetch('client-key-data', nil)
|
193
|
+
opts[:client_key_data] = Base64.decode64(client_key_data) if client_key_data
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def kube_user_config
|
198
|
+
@kube_user_config ||= begin
|
199
|
+
kube_config.fetch('users', []).find {|user| user['name'] == kube_context_config['context']['user']} || begin
|
200
|
+
raise Error::BadConfig, code: :kube_user_not_found, data: {context: kube_context_config}
|
171
201
|
end
|
172
202
|
end
|
173
203
|
end
|
174
204
|
|
175
|
-
def
|
176
|
-
|
177
|
-
|
205
|
+
def kube_cluster_config
|
206
|
+
@kube_cluster_config ||= begin
|
207
|
+
kube_config.fetch('clusters', []).find {|cluster| cluster['name'] == kube_context_config['context']['cluster']} || begin
|
208
|
+
raise Error::BadConfig, code: :kube_cluster_not_found, data: {context: kube_context_config}
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def kube_context_config
|
214
|
+
@kube_context_config ||= begin
|
215
|
+
kube_config.fetch('contexts', []).find {|context| context['name'] == kube_context_name} || begin
|
216
|
+
raise Error::BadConfig, code: :kube_context_not_found, data: {context_name: kube_context_name}
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def kube_context_name
|
222
|
+
@kube_context_name ||= kube_config['current-context'] || begin
|
223
|
+
if context = kube_config.fetch('contexts', []).first
|
224
|
+
warn "[WARN] .kube/config current-context is not set, using context '#{context['name']}'"
|
225
|
+
context['name']
|
226
|
+
end
|
227
|
+
end
|
178
228
|
end
|
179
229
|
|
180
230
|
def kube_config
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Dapp
|
2
|
+
module Kube
|
3
|
+
module Client::Error
|
4
|
+
class Base < ::Dapp::Deployment::Error::Kubernetes
|
5
|
+
def initialize(**net_status)
|
6
|
+
super(**net_status, context: :kubernetes)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class NotFound < Base
|
11
|
+
def initialize(**net_status)
|
12
|
+
super({code: :not_found}.merge(net_status))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Timeout < Base; end
|
17
|
+
class ConnectionRefused < Base; end
|
18
|
+
class BadConfig < Base; end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -27,7 +27,7 @@ module Dapp
|
|
27
27
|
options << "--set global.dapp.repo=#{repo}"
|
28
28
|
options << "--set global.dapp.image_version=#{image_version}"
|
29
29
|
options << "--set global.namespace=#{kube_namespace}"
|
30
|
-
options
|
30
|
+
options.concat(self.options[:helm_set_options].map { |opt| "--set #{opt}" })
|
31
31
|
end
|
32
32
|
|
33
33
|
kube_flush_hooks_jobs(additional_values, set_options)
|
@@ -86,19 +86,25 @@ module Dapp
|
|
86
86
|
cont = <<-EOF
|
87
87
|
{{/* vim: set filetype=mustache: */}}
|
88
88
|
|
89
|
+
{{- define "dimg" -}}
|
90
|
+
{{- $name := index . 0 -}}
|
91
|
+
{{- $context := index . 1 -}}
|
92
|
+
{{- printf "%s:%s-%s" $context.Values.global.dapp.repo $name $context.Values.global.dapp.image_version -}}
|
93
|
+
{{- end -}}
|
94
|
+
|
89
95
|
{{- define "dapp_secret_file" -}}
|
90
96
|
{{- $relative_file_path := index . 0 -}}
|
91
97
|
{{- $context := index . 1 -}}
|
92
98
|
{{- $context.Files.Get (print "#{secret_directory}/" $relative_file_path) -}}
|
93
99
|
{{- end -}}
|
94
100
|
EOF
|
95
|
-
kube_tmp_chart_path('templates/
|
101
|
+
kube_tmp_chart_path('templates/_dapp_helpers.tpl').write(cont)
|
96
102
|
end
|
97
103
|
|
98
104
|
def kube_flush_hooks_jobs(additional_values, set_options)
|
99
105
|
return if (config_jobs_names = kube_helm_hooks_jobs_to_delete(additional_values, set_options).keys).empty?
|
100
|
-
|
101
|
-
log_process("Delete hooks job `#{
|
106
|
+
config_jobs_names.select { |name| kube_job_list.include? name }.each do |name|
|
107
|
+
log_process("Delete hooks job `#{name}` for release #{kube_release_name} ", short: true) { kube_delete_job!(name) }
|
102
108
|
end
|
103
109
|
end
|
104
110
|
|
data/lib/dapp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Stolyarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -625,6 +625,8 @@ files:
|
|
625
625
|
- lib/dapp/kube/cli/command/kube/secret_file_encrypt.rb
|
626
626
|
- lib/dapp/kube/cli/command/kube/secret_generate.rb
|
627
627
|
- lib/dapp/kube/cli/command/kube/secret_key_generate.rb
|
628
|
+
- lib/dapp/kube/client.rb
|
629
|
+
- lib/dapp/kube/client/error.rb
|
628
630
|
- lib/dapp/kube/dapp/command/common.rb
|
629
631
|
- lib/dapp/kube/dapp/command/deploy.rb
|
630
632
|
- lib/dapp/kube/dapp/command/dismiss.rb
|
@@ -634,7 +636,6 @@ files:
|
|
634
636
|
- lib/dapp/kube/dapp/dapp.rb
|
635
637
|
- lib/dapp/kube/error/base.rb
|
636
638
|
- lib/dapp/kube/error/command.rb
|
637
|
-
- lib/dapp/kube/kubernetes.rb
|
638
639
|
- lib/dapp/kube/secret.rb
|
639
640
|
- lib/dapp/prctl.rb
|
640
641
|
- lib/dapp/version.rb
|