kubernetes-deploy 0.6.5 → 0.6.6
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/kubeclient_builder.rb +8 -0
- data/lib/kubernetes-deploy/kubernetes_resource.rb +7 -0
- data/lib/kubernetes-deploy/kubernetes_resource/cloudsql.rb +1 -1
- data/lib/kubernetes-deploy/kubernetes_resource/pod_disruption_budget.rb +33 -0
- data/lib/kubernetes-deploy/restart_task.rb +1 -0
- data/lib/kubernetes-deploy/runner.rb +27 -10
- 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: 845bf8bd854e94df070d5637d37a8678f9a92411
|
4
|
+
data.tar.gz: 32a57ce86b607e98133ec04875d88f4ffa37495c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a6b635d9554e3737a5330fe4df509ec6ca5f5b1a0a3abac8016a199b084620d36ac47116e7863c9b8ebbda3e5a6a264b4b24da6262e772ee0250e2d98e48ea4
|
7
|
+
data.tar.gz: c479251f382257c6be386422f13d87ab4252f4adaa91b5d1600aa9df30b0d8687b9bb0612642275d2dc4860fc15871bb3afdad8f59e6311e1e120b3d9da11c7a
|
@@ -28,6 +28,14 @@ module KubernetesDeploy
|
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
31
|
+
def build_policy_v1beta1_kubeclient(context)
|
32
|
+
_build_kubeclient(
|
33
|
+
api_version: "v1beta1",
|
34
|
+
context: context,
|
35
|
+
endpoint_path: "/apis/policy/"
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
31
39
|
def _build_kubeclient(api_version:, context:, endpoint_path: nil)
|
32
40
|
config = GoogleFriendlyConfig.read(ENV.fetch("KUBECONFIG"))
|
33
41
|
unless config.contexts.include?(context)
|
@@ -36,6 +36,7 @@ module KubernetesDeploy
|
|
36
36
|
when 'persistentvolumeclaim' then PersistentVolumeClaim.new(name, namespace, context, file)
|
37
37
|
when 'service' then Service.new(name, namespace, context, file)
|
38
38
|
when 'podtemplate' then PodTemplate.new(name, namespace, context, file)
|
39
|
+
when 'poddisruptionbudget' then PodDisruptionBudget.new(name, namespace, context, file)
|
39
40
|
else self.new(name, namespace, context, file).tap { |r| r.type = type }
|
40
41
|
end
|
41
42
|
end
|
@@ -99,6 +100,12 @@ module KubernetesDeploy
|
|
99
100
|
false
|
100
101
|
end
|
101
102
|
|
103
|
+
# Expected values: :apply, :replace, :replace_force
|
104
|
+
def deploy_method
|
105
|
+
# TPRs must use update for now: https://github.com/kubernetes/kubernetes/issues/39906
|
106
|
+
tpr? ? :replace : :apply
|
107
|
+
end
|
108
|
+
|
102
109
|
def status_data
|
103
110
|
{
|
104
111
|
group: group_name,
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module KubernetesDeploy
|
3
|
+
class PodDisruptionBudget < KubernetesResource
|
4
|
+
TIMEOUT = 10.seconds
|
5
|
+
|
6
|
+
def initialize(name, namespace, context, file)
|
7
|
+
@name = name
|
8
|
+
@namespace = namespace
|
9
|
+
@context = context
|
10
|
+
@file = file
|
11
|
+
end
|
12
|
+
|
13
|
+
def sync
|
14
|
+
_, _err, st = run_kubectl("get", type, @name)
|
15
|
+
@found = st.success?
|
16
|
+
@status = @found ? "Available" : "Unknown"
|
17
|
+
log_status
|
18
|
+
end
|
19
|
+
|
20
|
+
def deploy_succeeded?
|
21
|
+
exists?
|
22
|
+
end
|
23
|
+
|
24
|
+
def deploy_method
|
25
|
+
# Required until https://github.com/kubernetes/kubernetes/issues/45398 changes
|
26
|
+
:replace_force
|
27
|
+
end
|
28
|
+
|
29
|
+
def exists?
|
30
|
+
@found
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -31,6 +31,7 @@ module KubernetesDeploy
|
|
31
31
|
@logger = logger
|
32
32
|
@kubeclient = build_v1_kubeclient(context)
|
33
33
|
@v1beta1_kubeclient = build_v1beta1_kubeclient(context)
|
34
|
+
@policy_v1beta1_kubeclient = build_policy_v1beta1_kubeclient(context)
|
34
35
|
end
|
35
36
|
|
36
37
|
def perform(deployments_names = nil)
|
@@ -17,6 +17,7 @@ require 'kubernetes-deploy/kubernetes_resource'
|
|
17
17
|
service
|
18
18
|
pod_template
|
19
19
|
bugsnag
|
20
|
+
pod_disruption_budget
|
20
21
|
).each do |subresource|
|
21
22
|
require "kubernetes-deploy/kubernetes_resource/#{subresource}"
|
22
23
|
end
|
@@ -295,25 +296,41 @@ MSG
|
|
295
296
|
KubernetesDeploy.logger.info("All required parameters and files are present")
|
296
297
|
end
|
297
298
|
|
298
|
-
def
|
299
|
-
|
299
|
+
def deploy_resources(resources, prune: false)
|
300
|
+
KubernetesDeploy.logger.info("Deploying resources:")
|
301
|
+
|
302
|
+
# Apply can be done in one large batch, the rest have to be done individually
|
303
|
+
applyables, individuals = resources.partition { |r| r.deploy_method == :apply }
|
304
|
+
|
305
|
+
individuals.each do |r|
|
300
306
|
KubernetesDeploy.logger.info("- #{r.id}")
|
301
307
|
r.deploy_started = Time.now.utc
|
302
|
-
|
308
|
+
case r.deploy_method
|
309
|
+
when :replace
|
310
|
+
_, _, st = run_kubectl("replace", "-f", r.file.path)
|
311
|
+
when :replace_force
|
312
|
+
_, _, st = run_kubectl("replace", "--force", "-f", r.file.path)
|
313
|
+
else
|
314
|
+
# Fail Fast! This is a programmer mistake.
|
315
|
+
raise ArgumentError, "Unexpected deploy method! (#{r.deploy_method.inspect})"
|
316
|
+
end
|
303
317
|
|
304
318
|
unless st.success?
|
305
319
|
# it doesn't exist so we can't replace it
|
306
|
-
run_kubectl("create", "-f", r.file.path)
|
320
|
+
_, err, st = run_kubectl("create", "-f", r.file.path)
|
321
|
+
unless st.success?
|
322
|
+
raise FatalDeploymentError, <<-MSG.strip_heredoc
|
323
|
+
Failed to replace or create resource: #{r.id}
|
324
|
+
#{err}
|
325
|
+
MSG
|
326
|
+
end
|
307
327
|
end
|
308
328
|
end
|
309
|
-
end
|
310
329
|
|
311
|
-
|
312
|
-
|
330
|
+
apply_all(applyables, prune)
|
331
|
+
end
|
313
332
|
|
314
|
-
|
315
|
-
tprs, resources = resources.partition(&:tpr?)
|
316
|
-
update_tprs(tprs)
|
333
|
+
def apply_all(resources, prune)
|
317
334
|
return unless resources.present?
|
318
335
|
|
319
336
|
command = ["apply"]
|
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.6.
|
4
|
+
version: 0.6.6
|
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-05-
|
13
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- lib/kubernetes-deploy/kubernetes_resource/ingress.rb
|
189
189
|
- lib/kubernetes-deploy/kubernetes_resource/persistent_volume_claim.rb
|
190
190
|
- lib/kubernetes-deploy/kubernetes_resource/pod.rb
|
191
|
+
- lib/kubernetes-deploy/kubernetes_resource/pod_disruption_budget.rb
|
191
192
|
- lib/kubernetes-deploy/kubernetes_resource/pod_template.rb
|
192
193
|
- lib/kubernetes-deploy/kubernetes_resource/redis.rb
|
193
194
|
- lib/kubernetes-deploy/kubernetes_resource/service.rb
|