kubernetes-deploy 0.12.8 → 0.12.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +5 -4
- data/lib/kubernetes-deploy/kubectl.rb +3 -1
- data/lib/kubernetes-deploy/runner.rb +30 -3
- data/lib/kubernetes-deploy/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d865102d9b707cc6ef67eba2609c3eaaa94903a
|
4
|
+
data.tar.gz: 6e6f5ec188571c42c5dfd2672f62ccf922eabfb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e250b6c3f66bd986fa7f2a11cd5779aa96ff05ce4ddb386d21521aa3e14748135894cb6be004e71205fcc28017c5690d452ba72c6b9d4a0cea7c601104a07bb4
|
7
|
+
data.tar.gz: e0797decff33ef2c7c4d311d85a5b4a78dd5fcb53ae10c9a76ead741b6a89e1b12fb4db1304fb1ad781255cb63ac92d9c9356d563da2b3daad9f18ec89d726ea
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -287,10 +287,11 @@ To make StatsD log what it would have emitted, run a test with `STATSD_DEV=1`.
|
|
287
287
|
|
288
288
|
## Releasing a new version (Shopify employees)
|
289
289
|
|
290
|
-
1.
|
291
|
-
2.
|
292
|
-
3.
|
293
|
-
4.
|
290
|
+
1. Make sure all merged PRs are reflected in the changelog before creating the commit for the new version.
|
291
|
+
2. Update the version number in `version.rb` and commit that change with message "Version x.y.z". Don't push yet or you'll confuse Shipit.
|
292
|
+
3. Tag the version with `git tag vx.y.z -a -m "Version x.y.z"`
|
293
|
+
4. Push both your bump commit and its tag simultaneously with `git push origin master --follow-tags` (note that you can set `git config --global push.followTags true` to turn this flag on by default)
|
294
|
+
5. Use the [Shipit Stack](https://shipit.shopify.io/shopify/kubernetes-deploy/rubygems) to build the `.gem` file and upload to [rubygems.org](https://rubygems.org/gems/kubernetes-deploy).
|
294
295
|
|
295
296
|
If you push your commit and the tag separately, Shipit usually fails with `You need to create the v0.7.9 tag first.`. To make it find your tag, go to `Settings` > `Resynchronize this stack` > `Clear git cache`.
|
296
297
|
|
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
module KubernetesDeploy
|
4
4
|
class Kubectl
|
5
|
-
def initialize(namespace:, context:, logger:, log_failure_by_default:)
|
5
|
+
def initialize(namespace:, context:, logger:, log_failure_by_default:, default_timeout: '30s')
|
6
6
|
@namespace = namespace
|
7
7
|
@context = context
|
8
8
|
@logger = logger
|
9
9
|
@log_failure_by_default = log_failure_by_default
|
10
|
+
@default_timeout = default_timeout
|
10
11
|
|
11
12
|
raise ArgumentError, "namespace is required" if namespace.blank?
|
12
13
|
raise ArgumentError, "context is required" if context.blank?
|
@@ -18,6 +19,7 @@ module KubernetesDeploy
|
|
18
19
|
args = args.unshift("kubectl")
|
19
20
|
args.push("--namespace=#{@namespace}") if use_namespace
|
20
21
|
args.push("--context=#{@context}") if use_context
|
22
|
+
args.push("--request-timeout=#{@default_timeout}") if @default_timeout
|
21
23
|
|
22
24
|
@logger.debug Shellwords.join(args)
|
23
25
|
out, err, st = Open3.capture3(*args)
|
@@ -72,12 +72,15 @@ module KubernetesDeploy
|
|
72
72
|
autoscaling/v1/HorizontalPodAutoscaler
|
73
73
|
).freeze
|
74
74
|
|
75
|
-
|
75
|
+
NOT_FOUND_ERROR = 'NotFound'
|
76
|
+
|
77
|
+
def initialize(namespace:, context:, current_sha:, template_dir:, logger:, kubectl_instance: nil, bindings: {})
|
76
78
|
@namespace = namespace
|
77
79
|
@context = context
|
78
80
|
@current_sha = current_sha
|
79
81
|
@template_dir = File.expand_path(template_dir)
|
80
82
|
@logger = logger
|
83
|
+
@kubectl = kubectl_instance
|
81
84
|
@bindings = bindings
|
82
85
|
# Max length of podname is only 63chars so try to save some room by truncating sha to 8 chars
|
83
86
|
@id = current_sha[0...8] + "-#{SecureRandom.hex(4)}" if current_sha
|
@@ -401,12 +404,27 @@ module KubernetesDeploy
|
|
401
404
|
elsif !available_contexts.include?(@context)
|
402
405
|
raise FatalDeploymentError, "Context #{@context} is not available. Valid contexts: #{available_contexts}"
|
403
406
|
end
|
407
|
+
confirm_cluster_reachable
|
404
408
|
@logger.info("Context #{@context} found")
|
405
409
|
end
|
406
410
|
|
411
|
+
def confirm_cluster_reachable
|
412
|
+
success = false
|
413
|
+
with_retries(2) do
|
414
|
+
_, _, st = kubectl.run("version", use_namespace: false, log_failure: true)
|
415
|
+
success = st.success?
|
416
|
+
end
|
417
|
+
|
418
|
+
raise FatalDeploymentError, "Failed to reach server for #{@context}" unless success
|
419
|
+
end
|
420
|
+
|
407
421
|
def confirm_namespace_exists
|
408
|
-
|
409
|
-
|
422
|
+
st, err = nil
|
423
|
+
with_retries(2) do
|
424
|
+
_, err, st = kubectl.run("get", "namespace", @namespace, use_namespace: false, log_failure: true)
|
425
|
+
st.success? || err.include?(NOT_FOUND_ERROR)
|
426
|
+
end
|
427
|
+
raise FatalDeploymentError, "Failed to find namespace. #{err}" unless st.success?
|
410
428
|
@logger.info("Namespace #{@namespace} found")
|
411
429
|
end
|
412
430
|
|
@@ -417,5 +435,14 @@ module KubernetesDeploy
|
|
417
435
|
def statsd_tags
|
418
436
|
%W(namespace:#{@namespace} sha:#{@current_sha} context:#{@context})
|
419
437
|
end
|
438
|
+
|
439
|
+
def with_retries(limit)
|
440
|
+
retried = 0
|
441
|
+
while retried <= limit
|
442
|
+
success = yield
|
443
|
+
break if success
|
444
|
+
retried += 1
|
445
|
+
end
|
446
|
+
end
|
420
447
|
end
|
421
448
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubernetes-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katrina Verey
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-10-
|
12
|
+
date: 2017-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- ".buildkite/pipeline.yml"
|
193
193
|
- ".gitignore"
|
194
194
|
- ".rubocop.yml"
|
195
|
+
- CHANGELOG.md
|
195
196
|
- Gemfile
|
196
197
|
- LICENSE.txt
|
197
198
|
- NO-BINAUTH
|