kubernetes-deploy 0.11.2 → 0.12.0
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/lib/kubernetes-deploy/kubernetes_resource.rb +1 -6
- data/lib/kubernetes-deploy/kubernetes_resource/bugsnag.rb +0 -4
- data/lib/kubernetes-deploy/kubernetes_resource/cloudsql.rb +0 -4
- data/lib/kubernetes-deploy/kubernetes_resource/pod.rb +26 -12
- data/lib/kubernetes-deploy/kubernetes_resource/redis.rb +0 -4
- data/lib/kubernetes-deploy/runner.rb +5 -23
- data/lib/kubernetes-deploy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ce203eba2242a33d7bdf6d5e6ed33dce0de85c2
|
4
|
+
data.tar.gz: 5d8ead3d6d9ca37ee9edc6701e98a2acdedffd31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c81aaf0f6442b0dac0f2ce67c175eefe120574347eb470979f5f2d75c678e422cc92dd5959160a61e8069f9758a4919830ff5db4c5137911dd72df83b456181a
|
7
|
+
data.tar.gz: dd78a292e16ae848bda6ed798c39eac63aa71395a1c5e447297d8f33262e3db47377a15537559b56fa3c2a3f5541607bb85c3987cf92366069b9b9a0974461f8
|
@@ -115,14 +115,9 @@ module KubernetesDeploy
|
|
115
115
|
!deploy_succeeded? && !deploy_failed? && (Time.now.utc - @deploy_started > timeout)
|
116
116
|
end
|
117
117
|
|
118
|
-
def tpr?
|
119
|
-
false
|
120
|
-
end
|
121
|
-
|
122
118
|
# Expected values: :apply, :replace, :replace_force
|
123
119
|
def deploy_method
|
124
|
-
|
125
|
-
tpr? ? :replace : :apply
|
120
|
+
:apply
|
126
121
|
end
|
127
122
|
|
128
123
|
def debug_message
|
@@ -55,15 +55,10 @@ module KubernetesDeploy
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def timeout_message
|
58
|
-
return
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
next if c.init_container? || c.ready?
|
63
|
-
yellow_name = ColorizedString.new(c.name).yellow
|
64
|
-
pieces << "> #{yellow_name} must respond with a good status code at '#{c.probe_location}'"
|
65
|
-
end
|
66
|
-
pieces.join("\n") + "\n"
|
58
|
+
return STANDARD_TIMEOUT_MESSAGE unless readiness_probe_failure?
|
59
|
+
probe_failure_msgs = @containers.map(&:readiness_fail_reason).compact
|
60
|
+
header = "The following containers have not passed their readiness probes on at least one pod:\n"
|
61
|
+
header + probe_failure_msgs.join("\n") + "\n"
|
67
62
|
end
|
68
63
|
|
69
64
|
def failure_message
|
@@ -104,6 +99,12 @@ module KubernetesDeploy
|
|
104
99
|
|
105
100
|
private
|
106
101
|
|
102
|
+
def readiness_probe_failure?
|
103
|
+
return false if @ready || unmanaged?
|
104
|
+
return false if @phase != "Running"
|
105
|
+
@containers.any?(&:readiness_fail_reason)
|
106
|
+
end
|
107
|
+
|
107
108
|
def ready?(status_data)
|
108
109
|
ready_condition = status_data.fetch("conditions", []).find { |condition| condition["type"] == "Ready" }
|
109
110
|
ready_condition.present? && (ready_condition["status"] == "True")
|
@@ -162,13 +163,14 @@ module KubernetesDeploy
|
|
162
163
|
end
|
163
164
|
|
164
165
|
class Container
|
165
|
-
attr_reader :name
|
166
|
+
attr_reader :name
|
166
167
|
|
167
168
|
def initialize(definition, init_container: false)
|
168
169
|
@init_container = init_container
|
169
170
|
@name = definition["name"]
|
170
171
|
@image = definition["image"]
|
171
|
-
@
|
172
|
+
@http_probe_location = definition.dig("readinessProbe", "httpGet", "path")
|
173
|
+
@exec_probe_command = definition.dig("readinessProbe", "exec", "command")
|
172
174
|
@status = {}
|
173
175
|
end
|
174
176
|
|
@@ -198,8 +200,20 @@ module KubernetesDeploy
|
|
198
200
|
end
|
199
201
|
end
|
200
202
|
|
203
|
+
def readiness_fail_reason
|
204
|
+
return if ready? || init_container?
|
205
|
+
return unless (@http_probe_location || @exec_probe_command).present?
|
206
|
+
|
207
|
+
yellow_name = ColorizedString.new(name).yellow
|
208
|
+
if @http_probe_location
|
209
|
+
"> #{yellow_name} must respond with a good status code at '#{@http_probe_location}'"
|
210
|
+
elsif @exec_probe_command
|
211
|
+
"> #{yellow_name} must exit 0 from the following command: '#{@exec_probe_command.join(' ')}'"
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
201
215
|
def ready?
|
202
|
-
@status['ready'] ==
|
216
|
+
@status['ready'] == true
|
203
217
|
end
|
204
218
|
|
205
219
|
def init_container?
|
@@ -47,7 +47,7 @@ module KubernetesDeploy
|
|
47
47
|
kube-public
|
48
48
|
)
|
49
49
|
|
50
|
-
# Things removed from default prune whitelist:
|
50
|
+
# Things removed from default prune whitelist at https://github.com/kubernetes/kubernetes/blob/0dff56b4d88ec7551084bf89028dbeebf569620e/pkg/kubectl/cmd/apply.go#L411:
|
51
51
|
# core/v1/Namespace -- not namespaced
|
52
52
|
# core/v1/PersistentVolume -- not namespaced
|
53
53
|
# core/v1/Endpoints -- managed by services
|
@@ -55,20 +55,19 @@ module KubernetesDeploy
|
|
55
55
|
# core/v1/ReplicationController -- superseded by deployments/replicasets
|
56
56
|
# extensions/v1beta1/ReplicaSet -- managed by deployments
|
57
57
|
# core/v1/Secret -- should not committed / managed by shipit
|
58
|
-
|
58
|
+
PRUNE_WHITELIST = %w(
|
59
59
|
core/v1/ConfigMap
|
60
60
|
core/v1/Pod
|
61
61
|
core/v1/Service
|
62
62
|
batch/v1/Job
|
63
63
|
extensions/v1beta1/DaemonSet
|
64
64
|
extensions/v1beta1/Deployment
|
65
|
+
apps/v1beta1/Deployment
|
65
66
|
extensions/v1beta1/Ingress
|
66
67
|
apps/v1beta1/StatefulSet
|
68
|
+
autoscaling/v1/HorizontalPodAutoscaler
|
67
69
|
).freeze
|
68
70
|
|
69
|
-
PRUNE_WHITELIST_V_1_5 = %w(extensions/v1beta1/HorizontalPodAutoscaler).freeze
|
70
|
-
PRUNE_WHITELIST_V_1_6 = %w(autoscaling/v1/HorizontalPodAutoscaler).freeze
|
71
|
-
|
72
71
|
def initialize(namespace:, context:, current_sha:, template_dir:, logger:, bindings: {})
|
73
72
|
@namespace = namespace
|
74
73
|
@context = context
|
@@ -170,23 +169,6 @@ module KubernetesDeploy
|
|
170
169
|
end
|
171
170
|
end
|
172
171
|
|
173
|
-
def versioned_prune_whitelist
|
174
|
-
if server_major_version == "1.5"
|
175
|
-
BASE_PRUNE_WHITELIST + PRUNE_WHITELIST_V_1_5
|
176
|
-
else
|
177
|
-
BASE_PRUNE_WHITELIST + PRUNE_WHITELIST_V_1_6
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
def server_major_version
|
182
|
-
@server_major_version ||= begin
|
183
|
-
out, _, _ = kubectl.run('version', '--short')
|
184
|
-
matchdata = /Server Version: v(?<version>\d\.\d)/.match(out)
|
185
|
-
raise "Could not determine server version" unless matchdata[:version]
|
186
|
-
matchdata[:version]
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
172
|
# Inspect the file referenced in the kubectl stderr
|
191
173
|
# to make it easier for developer to understand what's going on
|
192
174
|
def find_bad_files_from_kubectl_output(stderr)
|
@@ -398,7 +380,7 @@ module KubernetesDeploy
|
|
398
380
|
|
399
381
|
if prune
|
400
382
|
command.push("--prune", "--all")
|
401
|
-
|
383
|
+
PRUNE_WHITELIST.each { |type| command.push("--prune-whitelist=#{type}") }
|
402
384
|
end
|
403
385
|
|
404
386
|
out, err, st = kubectl.run(*command, log_failure: false)
|