kubernetes-deploy 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +5 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/bin/ci +1 -20
- data/exe/kubernetes-deploy +4 -2
- data/lib/kubernetes-deploy.rb +23 -22
- data/lib/kubernetes-deploy/kubernetes_resource/deployment.rb +1 -1
- data/lib/kubernetes-deploy/kubernetes_resource/pod.rb +1 -1
- data/lib/kubernetes-deploy/kubernetes_resource/service.rb +1 -1
- data/lib/kubernetes-deploy/runner.rb +26 -1
- 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: 37ace35e766d0e991bf224d97c99cbadfde2c623
|
4
|
+
data.tar.gz: 3f10fd5a9471ca53135b5f817c2e949091171294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 491a65c67cfbe03eb70996bc3a5d27ac19767f654e896e522f1719930b5df628ec2d498e9a7e30e1b0244df14bac7036bdcc7986c0f256bd1ca2f6f9fc028607
|
7
|
+
data.tar.gz: d952118387e0bee804983b5a7e686a16c603f3b3c98ec69a187aa9d0d79f072117429f558d18ca283c77cabe004d1c40f1f8928a6426f593fcb1fa7a0e199e4e
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Kubernetes::Deploy
|
2
2
|
|
3
|
-
[![Build status](https://badge.buildkite.com/0f2d4956d49fbc795f9c17b0a741a6aa9ea532738e5f872ac8.svg)](https://buildkite.com/shopify/kubernetes-deploy-gem)
|
3
|
+
[![Build status](https://badge.buildkite.com/0f2d4956d49fbc795f9c17b0a741a6aa9ea532738e5f872ac8.svg?branch=master)](https://buildkite.com/shopify/kubernetes-deploy-gem)
|
4
4
|
|
5
5
|
Deploy script used to manage a Kubernetes application's namespace with [Shipit](https://github.com/Shopify/shipit-engine).
|
6
6
|
|
data/bin/ci
CHANGED
@@ -1,32 +1,13 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
set -eox pipefail
|
3
3
|
|
4
|
-
MINIKUBE_VER=0.16.0
|
5
4
|
KUBERNETES_VER=1.5.2
|
6
|
-
DOCKER_MACHINE_KVM_VER=0.7.0
|
7
5
|
|
8
6
|
echo "--- Installing dependencies"
|
9
|
-
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v$MINIKUBE_VER/minikube-linux-amd64
|
10
|
-
chmod +x minikube
|
11
|
-
sudo mv minikube /usr/local/bin/
|
12
|
-
|
13
|
-
# minikube requires kubectl
|
14
|
-
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v$KUBERNETES_VER/bin/linux/amd64/kubectl
|
15
|
-
chmod +x kubectl
|
16
|
-
sudo mv kubectl /usr/local/bin/
|
17
|
-
|
18
|
-
# KVM support for minikube
|
19
|
-
curl -Lo docker-machine-driver-kvm https://github.com/dhiltgen/docker-machine-kvm/releases/download/v$DOCKER_MACHINE_KVM_VER/docker-machine-driver-kvm
|
20
|
-
chmod +x docker-machine-driver-kvm
|
21
|
-
sudo mv docker-machine-driver-kvm /usr/local/bin/
|
22
|
-
|
23
|
-
minikube config set vm-driver kvm
|
24
|
-
|
25
|
-
gem install bundler --no-ri --no-rdoc
|
26
7
|
bundle install --jobs 4
|
27
8
|
|
28
9
|
echo "--- Starting minikube"
|
29
|
-
minikube start --cpus 2 --memory 2048 --disk-size=2gb --kubernetes-version=$KUBERNETES_VER
|
10
|
+
minikube start --cpus 2 --memory 2048 --disk-size=2gb --kubernetes-version=$KUBERNETES_VER --logtostderr
|
30
11
|
|
31
12
|
echo "--- Running tests"
|
32
13
|
bundle exec rake test
|
data/exe/kubernetes-deploy
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'kubernetes-deploy'
|
4
5
|
|
@@ -13,11 +14,12 @@ ARGV.options do |opts|
|
|
13
14
|
end
|
14
15
|
|
15
16
|
if !template_dir && ENV.key?("ENVIRONMENT")
|
16
|
-
template_dir = "config/deploy/#{ENV[
|
17
|
+
template_dir = "config/deploy/#{ENV['ENVIRONMENT']}"
|
17
18
|
end
|
18
19
|
|
19
20
|
if !template_dir || template_dir.empty?
|
20
|
-
puts "Template directory is unknown.
|
21
|
+
puts "Template directory is unknown. " \
|
22
|
+
"Either specify --template-dir argument or set $ENVIRONMENT to use config/deploy/$ENVIRONMENT as a default path."
|
21
23
|
exit 1
|
22
24
|
end
|
23
25
|
|
data/lib/kubernetes-deploy.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'active_support/core_ext/object/blank'
|
2
3
|
require 'active_support/core_ext/hash/slice'
|
3
4
|
require 'active_support/core_ext/numeric/time'
|
@@ -9,35 +10,35 @@ require 'kubernetes-deploy/runner'
|
|
9
10
|
module KubernetesDeploy
|
10
11
|
class FatalDeploymentError < StandardError; end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
13
|
+
class << self
|
14
|
+
attr_writer :logger
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
def logger
|
17
|
+
@logger ||= begin
|
18
|
+
l = Logger.new($stderr)
|
19
|
+
l.level = level_from_env
|
20
|
+
l.formatter = proc do |severity, _datetime, _progname, msg|
|
21
|
+
case severity
|
22
|
+
when "FATAL", "ERROR" then "\033[0;31m[#{severity}]\t#{msg}\x1b[0m\n" # red
|
23
|
+
when "WARN" then "\033[0;33m[#{severity}]\t#{msg}\x1b[0m\n" # yellow
|
24
|
+
when "INFO" then "\033[0;36m#{msg}\x1b[0m\n" # blue
|
25
|
+
else "[#{severity}]\t#{msg}\n"
|
26
|
+
end
|
26
27
|
end
|
28
|
+
l
|
27
29
|
end
|
28
|
-
l
|
29
30
|
end
|
30
|
-
end
|
31
31
|
|
32
|
-
|
32
|
+
private
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
def level_from_env
|
35
|
+
return Logger::DEBUG if ENV["DEBUG"]
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
if ENV["LEVEL"]
|
38
|
+
Logger.const_get(ENV["LEVEL"].upcase)
|
39
|
+
else
|
40
|
+
Logger::INFO
|
41
|
+
end
|
41
42
|
end
|
42
43
|
end
|
43
44
|
end
|
@@ -112,6 +112,24 @@ MSG
|
|
112
112
|
|
113
113
|
private
|
114
114
|
|
115
|
+
# Inspect the file referenced in the kubectl stderr
|
116
|
+
# to make it easier for developer to understand what's going on
|
117
|
+
def inspect_kubectl_out_for_files(stderr)
|
118
|
+
# Output example:
|
119
|
+
# error: unable to decode "/tmp/path/to/file": [pos 96]: json: expect char '"' but got char '{'
|
120
|
+
match = stderr.match(/error: unable to decode "(?<path>\S+)":/)
|
121
|
+
return unless match
|
122
|
+
|
123
|
+
path = match[:path]
|
124
|
+
if path.present? && File.file?(path)
|
125
|
+
suspicious_file = File.read(path)
|
126
|
+
KubernetesDeploy.logger.warn("Inspecting the file mentioned in the error message (#{path})")
|
127
|
+
KubernetesDeploy.logger.warn(suspicious_file)
|
128
|
+
else
|
129
|
+
KubernetesDeploy.logger.warn("Detected a file (#{path.inspect}) referenced in the kubectl stderr but was unable to inspect it")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
115
133
|
def predeploy_priority_resources(resource_list)
|
116
134
|
PREDEPLOY_SEQUENCE.each do |resource_type|
|
117
135
|
matching_resources = resource_list.select { |r| r.type == resource_type }
|
@@ -269,7 +287,14 @@ MSG
|
|
269
287
|
PRUNE_WHITELIST.each { |type| command.push("--prune-whitelist=#{type}") }
|
270
288
|
end
|
271
289
|
|
272
|
-
run_kubectl(*command)
|
290
|
+
_, err, st = run_kubectl(*command)
|
291
|
+
unless st.success?
|
292
|
+
inspect_kubectl_out_for_files(err)
|
293
|
+
raise FatalDeploymentError, <<-MSG
|
294
|
+
"The following command failed: #{Shellwords.join(command)}"
|
295
|
+
#{err}
|
296
|
+
MSG
|
297
|
+
end
|
273
298
|
end
|
274
299
|
|
275
300
|
def confirm_context_exists
|
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.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kir Shatrov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-03-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -77,6 +77,7 @@ extensions: []
|
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
79
|
- ".gitignore"
|
80
|
+
- ".rubocop.yml"
|
80
81
|
- Gemfile
|
81
82
|
- LICENSE.txt
|
82
83
|
- README.md
|