kubernetes-deploy 0.15.1 → 0.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -0
- data/lib/kubernetes-deploy.rb +1 -0
- data/lib/kubernetes-deploy/deploy_task.rb +3 -0
- data/lib/kubernetes-deploy/errors.rb +7 -0
- data/lib/kubernetes-deploy/kubernetes_resource.rb +11 -3
- data/lib/kubernetes-deploy/kubernetes_resource/deployment.rb +14 -10
- data/lib/kubernetes-deploy/restart_task.rb +8 -1
- data/lib/kubernetes-deploy/runner_task.rb +7 -2
- data/lib/kubernetes-deploy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c48f0cc4be05113a752768e19118a03d26c3505a
|
4
|
+
data.tar.gz: 2d51f6e48f927cbbf44a277e600bd728f09a1025
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d87392236bf5d4ceea11ad27ede7248abc611869b983f4eff8ecf8c43c4d09dc6164f36c5ce1ef7efa6022eaddee3791898e2f4b09e113ea63dc9c89b47ccd8a
|
7
|
+
data.tar.gz: f31edab5e0c2afd6e89cc81df85dba6e271040ffb932a83e79117da109b7353b95e17dbfe36c158d6a37ea42bc245a13af7eda92c3cd882c1766bc32c9619950
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
### 0.15.2
|
2
|
+
*Enhancements*
|
3
|
+
- Print warnings if kubernetes server version is not supported ([#237](https://github.com/Shopify/kubernetes-deploy/pull/237)).
|
4
|
+
- Possible via env var to disable fetching logs and/or events on deployment failure ([#239](https://github.com/Shopify/kubernetes-deploy/pull/239)).
|
5
|
+
- The `kubernetes-deploy.shopify.io/required-rollout` annotation now takes a percent (e.g. 90%) ([#240](https://github.com/Shopify/kubernetes-deploy/pull/240)).
|
6
|
+
|
1
7
|
### 0.15.1
|
2
8
|
*Enhancements*
|
3
9
|
- Fetch debug events and logs for failed resources in parallel ([#238](https://github.com/Shopify/kubernetes-deploy/pull/238))
|
data/README.md
CHANGED
@@ -134,6 +134,8 @@ before the deployment is considered successful.
|
|
134
134
|
In other words, the number of new pods that must be ready is equal to `spec.replicas` - `strategy.RollingUpdate.maxUnavailable`
|
135
135
|
(converted from percentages by rounding up, if applicable). This option is only valid for deployments
|
136
136
|
that use the `RollingUpdate` strategy.
|
137
|
+
- Percent (e.g. 90%): The deploy is successful when the number of new pods that are ready is equal to
|
138
|
+
`spec.replicas` * Percent.
|
137
139
|
|
138
140
|
|
139
141
|
### Running tasks at the beginning of a deploy
|
data/lib/kubernetes-deploy.rb
CHANGED
@@ -441,6 +441,9 @@ module KubernetesDeploy
|
|
441
441
|
end
|
442
442
|
end
|
443
443
|
raise FatalDeploymentError, "Failed to reach server for #{@context}" unless success
|
444
|
+
if kubectl.server_version < Gem::Version.new(MIN_KUBE_VERSION)
|
445
|
+
@logger.warn(KubernetesDeploy::Errors.server_version_warning(server_version))
|
446
|
+
end
|
444
447
|
end
|
445
448
|
|
446
449
|
def confirm_namespace_exists
|
@@ -8,4 +8,11 @@ module KubernetesDeploy
|
|
8
8
|
super("Namespace `#{name}` not found in context `#{context}`")
|
9
9
|
end
|
10
10
|
end
|
11
|
+
module Errors
|
12
|
+
extend self
|
13
|
+
def server_version_warning(server_version)
|
14
|
+
"Minimum cluster version requirement of #{MIN_KUBE_VERSION} not met. "\
|
15
|
+
"Using #{server_version} could result in unexpected behavior as it is no longer tested against"
|
16
|
+
end
|
17
|
+
end
|
11
18
|
end
|
@@ -12,6 +12,10 @@ module KubernetesDeploy
|
|
12
12
|
TIMEOUT = 5.minutes
|
13
13
|
LOG_LINE_COUNT = 250
|
14
14
|
|
15
|
+
DISABLE_FETCHING_LOG_INFO = 'DISABLE_FETCHING_LOG_INFO'
|
16
|
+
DISABLE_FETCHING_EVENT_INFO = 'DISABLE_FETCHING_EVENT_INFO'
|
17
|
+
DISABLED_LOG_INFO_MESSAGE = "collection is disabled by the #{DISABLE_FETCHING_LOG_INFO} env var."
|
18
|
+
DISABLED_EVENT_INFO_MESSAGE = "collection is disabled by the #{DISABLE_FETCHING_EVENT_INFO} env var."
|
15
19
|
DEBUG_RESOURCE_NOT_FOUND_MESSAGE = "None found. Please check your usual logging service (e.g. Splunk)."
|
16
20
|
UNUSUAL_FAILURE_MESSAGE = <<~MSG
|
17
21
|
It is very unusual for this resource type to fail to deploy. Please try the deploy again.
|
@@ -141,8 +145,8 @@ module KubernetesDeploy
|
|
141
145
|
end
|
142
146
|
|
143
147
|
def sync_debug_info
|
144
|
-
@events = fetch_events
|
145
|
-
@logs = fetch_logs if supports_logs?
|
148
|
+
@events = fetch_events unless ENV[DISABLE_FETCHING_EVENT_INFO]
|
149
|
+
@logs = fetch_logs if supports_logs? && !ENV[DISABLE_FETCHING_EVENT_INFO]
|
146
150
|
@debug_info_synced = true
|
147
151
|
end
|
148
152
|
|
@@ -169,12 +173,16 @@ module KubernetesDeploy
|
|
169
173
|
@events.each do |identifier, event_hashes|
|
170
174
|
event_hashes.each { |event| helpful_info << " [#{identifier}]\t#{event}" }
|
171
175
|
end
|
176
|
+
elsif ENV[DISABLE_FETCHING_EVENT_INFO]
|
177
|
+
helpful_info << " - Events: #{DISABLED_EVENT_INFO_MESSAGE}"
|
172
178
|
else
|
173
179
|
helpful_info << " - Events: #{DEBUG_RESOURCE_NOT_FOUND_MESSAGE}"
|
174
180
|
end
|
175
181
|
|
176
182
|
if supports_logs?
|
177
|
-
if
|
183
|
+
if ENV[DISABLE_FETCHING_LOG_INFO]
|
184
|
+
helpful_info << " - Logs: #{DISABLED_LOG_INFO_MESSAGE}"
|
185
|
+
elsif @logs.blank? || @logs.values.all?(&:blank?)
|
178
186
|
helpful_info << " - Logs: #{DEBUG_RESOURCE_NOT_FOUND_MESSAGE}"
|
179
187
|
else
|
180
188
|
sorted_logs = @logs.sort_by { |_, log_lines| log_lines.length }
|
@@ -48,15 +48,14 @@ module KubernetesDeploy
|
|
48
48
|
def deploy_succeeded?
|
49
49
|
return false unless @latest_rs.present?
|
50
50
|
|
51
|
-
|
52
|
-
when 'full'
|
51
|
+
if required_rollout == 'full'
|
53
52
|
@latest_rs.deploy_succeeded? &&
|
54
53
|
@latest_rs.desired_replicas == @desired_replicas && # latest RS fully scaled up
|
55
54
|
@rollout_data["updatedReplicas"].to_i == @desired_replicas &&
|
56
55
|
@rollout_data["updatedReplicas"].to_i == @rollout_data["availableReplicas"].to_i
|
57
|
-
|
56
|
+
elsif required_rollout == 'none'
|
58
57
|
true
|
59
|
-
|
58
|
+
elsif required_rollout == 'maxUnavailable' || percent?(required_rollout)
|
60
59
|
minimum_needed = min_available_replicas
|
61
60
|
|
62
61
|
@latest_rs.desired_replicas >= minimum_needed &&
|
@@ -102,7 +101,7 @@ module KubernetesDeploy
|
|
102
101
|
def validate_definition
|
103
102
|
super
|
104
103
|
|
105
|
-
unless REQUIRED_ROLLOUT_TYPES.include?(required_rollout)
|
104
|
+
unless REQUIRED_ROLLOUT_TYPES.include?(required_rollout) || percent?(required_rollout)
|
106
105
|
@validation_errors << rollout_annotation_err_msg
|
107
106
|
end
|
108
107
|
|
@@ -168,16 +167,21 @@ module KubernetesDeploy
|
|
168
167
|
end
|
169
168
|
|
170
169
|
def min_available_replicas
|
171
|
-
|
172
|
-
|
170
|
+
max_unavailable = percent?(required_rollout) ? "#{100 - required_rollout.to_i}%" : @max_unavailable
|
171
|
+
|
172
|
+
if max_unavailable =~ /%/
|
173
|
+
(@desired_replicas * (100 - max_unavailable.to_i) / 100.0).ceil
|
173
174
|
else
|
174
|
-
@desired_replicas -
|
175
|
+
@desired_replicas - max_unavailable.to_i
|
175
176
|
end
|
176
177
|
end
|
177
178
|
|
178
179
|
def required_rollout
|
179
|
-
@definition.dig('metadata', 'annotations', REQUIRED_ROLLOUT_ANNOTATION).presence ||
|
180
|
-
|
180
|
+
@definition.dig('metadata', 'annotations', REQUIRED_ROLLOUT_ANNOTATION).presence || DEFAULT_REQUIRED_ROLLOUT
|
181
|
+
end
|
182
|
+
|
183
|
+
def percent?(value)
|
184
|
+
value =~ /\d+%/
|
181
185
|
end
|
182
186
|
end
|
183
187
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'kubernetes-deploy/kubeclient_builder'
|
3
3
|
require 'kubernetes-deploy/resource_watcher'
|
4
|
+
require 'kubernetes-deploy/kubectl'
|
4
5
|
|
5
6
|
module KubernetesDeploy
|
6
7
|
class RestartTask
|
@@ -32,7 +33,9 @@ module KubernetesDeploy
|
|
32
33
|
@logger.phase_heading("Initializing restart")
|
33
34
|
verify_namespace
|
34
35
|
deployments = identify_target_deployments(deployments_names)
|
35
|
-
|
36
|
+
if kubectl.server_version < Gem::Version.new(MIN_KUBE_VERSION)
|
37
|
+
@logger.warn(KubernetesDeploy::Errors.server_version_warning(kubectl.server_version))
|
38
|
+
end
|
36
39
|
@logger.phase_heading("Triggering restart by touching ENV[RESTARTED_AT]")
|
37
40
|
patch_kubeclient_deployments(deployments)
|
38
41
|
|
@@ -153,6 +156,10 @@ module KubernetesDeploy
|
|
153
156
|
@kubeclient ||= build_v1_kubeclient(@context)
|
154
157
|
end
|
155
158
|
|
159
|
+
def kubectl
|
160
|
+
@kubectl ||= Kubectl.new(namespace: @namespace, context: @context, logger: @logger, log_failure_by_default: true)
|
161
|
+
end
|
162
|
+
|
156
163
|
def v1beta1_kubeclient
|
157
164
|
@v1beta1_kubeclient ||= build_v1beta1_kubeclient(@context)
|
158
165
|
end
|
@@ -34,7 +34,9 @@ module KubernetesDeploy
|
|
34
34
|
@logger.reset
|
35
35
|
@logger.phase_heading("Validating configuration")
|
36
36
|
validate_configuration(task_template, args)
|
37
|
-
|
37
|
+
if kubectl.server_version < Gem::Version.new(MIN_KUBE_VERSION)
|
38
|
+
@logger.warn(KubernetesDeploy::Errors.server_version_warning(kubectl.server_version))
|
39
|
+
end
|
38
40
|
@logger.phase_heading("Fetching task template")
|
39
41
|
raw_template = get_template(task_template)
|
40
42
|
|
@@ -127,7 +129,6 @@ module KubernetesDeploy
|
|
127
129
|
f.write recursive_to_h(pod).to_json
|
128
130
|
f.close
|
129
131
|
|
130
|
-
kubectl = Kubectl.new(namespace: @namespace, context: @context, logger: @logger, log_failure_by_default: true)
|
131
132
|
_out, err, status = kubectl.run("apply", "--dry-run", "-f", f.path)
|
132
133
|
|
133
134
|
unless status.success?
|
@@ -135,6 +136,10 @@ module KubernetesDeploy
|
|
135
136
|
end
|
136
137
|
end
|
137
138
|
|
139
|
+
def kubectl
|
140
|
+
@kubectl ||= Kubectl.new(namespace: @namespace, context: @context, logger: @logger, log_failure_by_default: true)
|
141
|
+
end
|
142
|
+
|
138
143
|
def recursive_to_h(struct)
|
139
144
|
if struct.is_a?(Array)
|
140
145
|
return struct.map { |v| v.is_a?(OpenStruct) || v.is_a?(Array) || v.is_a?(Hash) ? recursive_to_h(v) : v }
|
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.15.
|
4
|
+
version: 0.15.2
|
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: 2018-01-
|
12
|
+
date: 2018-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|