kubernetes-deploy 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13bfb87f3f0cd5b833cb6146f91d7ccdfcf50725
4
- data.tar.gz: 3c6cb3d5acf0c405a14759c01444e11244124509
3
+ metadata.gz: cfefc3bd897ba4b3a56a3ad94309571bb2a5ba8f
4
+ data.tar.gz: 959b6beaf80885a427c3e35b8b18ddd897784bd6
5
5
  SHA512:
6
- metadata.gz: 3d101d13086cf414cfc08989c9db9f7858dea14ab523c0424bf871a82ca98babc851ff7aea0be04db984e5aba689e5a2ecc5cc80750d2df4525573e5475f74a7
7
- data.tar.gz: f7b35147c24d8dad169c850de62fe0b8108ec538c5626741404e70bdce86860ce04c4ac332b8fc9561598eabbaa81794af64f16c9978c5ee08b4a6e1fd078d7e
6
+ metadata.gz: 867e36156d825450b7812e164d167facd2a6a4e150235eaec4bfe5ed1a8a1cb8e07a8ece2d74a5e82af240a93b833367599918104c1dffd8768e7d90c43724d9
7
+ data.tar.gz: abcc6c7d04d0cadfb4c63ffdb28ffe17adb639bdd362835a8a4c3a7badbf34b056e43ce8e31915032d925a9227e800a729493abbbd9b79882674141a978cc24d
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+ module KubernetesDeploy
3
+ class DaemonSet < KubernetesResource
4
+ TIMEOUT = 5.minutes
5
+
6
+ def sync
7
+ raw_json, _err, st = kubectl.run("get", type, @name, "--output=json")
8
+ @found = st.success?
9
+
10
+ if @found
11
+ daemonset_data = JSON.parse(raw_json)
12
+ @current_generation = daemonset_data["metadata"]["generation"]
13
+ @observed_generation = daemonset_data["status"]["observedGeneration"]
14
+ @rollout_data = daemonset_data["status"]
15
+ .slice("currentNumberScheduled", "desiredNumberScheduled", "numberReady", "numberAvailable")
16
+ @status = @rollout_data.map { |state_replicas, num| "#{num} #{state_replicas}" }.join(", ")
17
+ @pods = find_pods(daemonset_data)
18
+ else # reset
19
+ @rollout_data = { "currentNumberScheduled" => 0 }
20
+ @current_generation = 1 # to make sure the current and observed generations are different
21
+ @observed_generation = 0
22
+ @status = nil
23
+ @pods = []
24
+ end
25
+ end
26
+
27
+ def deploy_succeeded?
28
+ @rollout_data["desiredNumberScheduled"].to_i == @rollout_data["currentNumberScheduled"].to_i &&
29
+ @rollout_data["desiredNumberScheduled"].to_i == @rollout_data["numberAvailable"].to_i &&
30
+ @current_generation == @observed_generation
31
+ end
32
+
33
+ def deploy_failed?
34
+ @pods.present? && @pods.any?(&:deploy_failed?)
35
+ end
36
+
37
+ def failure_message
38
+ @pods.map(&:failure_message).compact.uniq.join("\n")
39
+ end
40
+
41
+ def timeout_message
42
+ @pods.map(&:timeout_message).compact.uniq.join("\n")
43
+ end
44
+
45
+ def deploy_timed_out?
46
+ super || @pods.present? && @pods.any?(&:deploy_timed_out?)
47
+ end
48
+
49
+ def exists?
50
+ @found
51
+ end
52
+
53
+ def fetch_events
54
+ own_events = super
55
+ return own_events unless @pods.present?
56
+ most_useful_pod = @pods.find(&:deploy_failed?) || @pods.find(&:deploy_timed_out?) || @pods.first
57
+ own_events.merge(most_useful_pod.fetch_events)
58
+ end
59
+
60
+ def fetch_logs
61
+ most_useful_pod = @pods.find(&:deploy_failed?) || @pods.find(&:deploy_timed_out?) || @pods.first
62
+ most_useful_pod.fetch_logs
63
+ end
64
+
65
+ private
66
+
67
+ def find_pods(ds_data)
68
+ label_string = ds_data["spec"]["selector"]["matchLabels"].map { |k, v| "#{k}=#{v}" }.join(",")
69
+ raw_json, _err, st = kubectl.run("get", "pods", "-a", "--output=json", "--selector=#{label_string}")
70
+ return [] unless st.success?
71
+
72
+ all_pods = JSON.parse(raw_json)["items"]
73
+ current_generation = ds_data["metadata"]["generation"]
74
+
75
+ latest_pods = all_pods.find_all do |pods|
76
+ pods["metadata"]["ownerReferences"].any? { |ref| ref["uid"] == ds_data["metadata"]["uid"] } &&
77
+ pods["metadata"]["labels"]["pod-template-generation"].to_i == current_generation.to_i
78
+ end
79
+ return unless latest_pods.present?
80
+
81
+ latest_pods.each_with_object([]) do |pod_data, relevant_pods|
82
+ pod = Pod.new(
83
+ namespace: namespace,
84
+ context: context,
85
+ definition: pod_data,
86
+ logger: @logger,
87
+ parent: "#{@name.capitalize} daemon set",
88
+ deploy_started: @deploy_started
89
+ )
90
+ pod.sync(pod_data)
91
+ relevant_pods << pod
92
+ end
93
+ end
94
+ end
95
+ end
@@ -20,6 +20,7 @@ require 'kubernetes-deploy/kubernetes_resource'
20
20
  pod_disruption_budget
21
21
  replica_set
22
22
  service_account
23
+ daemon_set
23
24
  ).each do |subresource|
24
25
  require "kubernetes-deploy/kubernetes_resource/#{subresource}"
25
26
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module KubernetesDeploy
3
- VERSION = "0.10.0"
3
+ VERSION = "0.10.1"
4
4
  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.10.0
4
+ version: 0.10.1
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-07-25 00:00:00.000000000 Z
12
+ date: 2017-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -213,6 +213,7 @@ files:
213
213
  - lib/kubernetes-deploy/kubernetes_resource/bugsnag.rb
214
214
  - lib/kubernetes-deploy/kubernetes_resource/cloudsql.rb
215
215
  - lib/kubernetes-deploy/kubernetes_resource/config_map.rb
216
+ - lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb
216
217
  - lib/kubernetes-deploy/kubernetes_resource/deployment.rb
217
218
  - lib/kubernetes-deploy/kubernetes_resource/ingress.rb
218
219
  - lib/kubernetes-deploy/kubernetes_resource/persistent_volume_claim.rb