kuby-kube-db 0.4.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2dd2cf5893ff6fd1f960b91010be789aacff74d31f16c2f314c021397e74e220
4
- data.tar.gz: 27f99dc8487fd3eaf43c448c57241194d8a33519f9cee7b319bcc5ee55476bca
3
+ metadata.gz: f9bc44f5af670d509ac4334e4f249ebef97023d1669cc3619739fc7f0dc3e942
4
+ data.tar.gz: 26f4e0e3f30038e49e321a78bbbb6fc57256f4bd175bf59e56586eee369c21c0
5
5
  SHA512:
6
- metadata.gz: 03fcc9e1b282a6ca02c8f982cadab5c81e3baeb9b22aa643e44eb1e8e61a1c7dd3e4f26c258b867a73fca8ab076f34f655d49045ab4535547c4fd2c3cb02ebdf
7
- data.tar.gz: 4325077c7d3525b95dce13911a8b3af0ac5848217e77935aef9ab9c8b9638d856b2242f63d6e4d7ff80e1eacf8cf0d381e94d9d08bc2316991d21e6e4cc27aee
6
+ metadata.gz: bd5ce930b3d5eca591e5e29429410401999d75b1774bd0e14a37bc2e26124a2b0f10d1d4ec57d49c5970cbad8fd93ae11d846eecf4175265b26a9248e7920075
7
+ data.tar.gz: cb41b9ae28bb08e256ee2f4dc08e7b48cea147f4916cda75a8325c53373dfdb1274491f5cdd7891f5ca430dbb8ac187362992c0f56bb9a5b5488f49f4ed9c92d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 0.7.0
2
+ * Upgrade to Helm 3.6 via helm-rb.
3
+ * Check operator replica set more effectively by using match labels during lookup.
4
+
5
+ ## 0.6.2
6
+ * Fix bad constant references
7
+
8
+ ## 0.6.1
9
+ * Pass keyword arguments correctly to helm-cli (#1, @rept)
10
+
11
+ ## 0.6.0
12
+ * Wait for API resources to become available.
13
+ - Krane queries k8s for API resources which causes kubectl to exit with a non-zero status code if KubeDB's operator isn't finished spinning up.
14
+
15
+ ## 0.5.0
16
+ * Conform to new plugin architecture.
17
+ * Accept `environment` instead of `definition` instances.
18
+
1
19
  ## 0.4.0
2
20
  * Downgrade to kubedb 0.12.0, the latest stable release.
3
21
  - For some reason, the API spec for 0.13.0.rc-0 was removed from the apimachinery repo.
data/kuby-kube-db.gemspec CHANGED
@@ -12,7 +12,8 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.platform = Gem::Platform::RUBY
14
14
 
15
- s.add_dependency 'helm-cli', '~> 0.2'
15
+ s.add_dependency 'helm-cli', '~> 0.3'
16
+ s.add_dependency 'helm-rb', '~> 0.2'
16
17
  s.add_dependency 'kube-dsl', '~> 0.3'
17
18
 
18
19
  s.require_path = 'lib'
@@ -6,8 +6,9 @@ module Kuby
6
6
  module KubeDB
7
7
  class KubeDBError < StandardError; end
8
8
  class OperatorDeployError < KubeDBError; end
9
+ class APIResourcesError < KubeDBError; end
9
10
 
10
- class Plugin < ::Kuby::Kubernetes::Plugin
11
+ class Plugin < ::Kuby::Plugin
11
12
  NAMESPACE = 'kube-system'.freeze
12
13
  REPO_NAME = 'appscode'.freeze
13
14
  REPO_URL = 'https://charts.appscode.com/stable/'.freeze
@@ -16,8 +17,8 @@ module Kuby
16
17
  CATALOG_RELEASE_NAME = 'kubedb-catalog'.freeze
17
18
  OPERATOR_CHART_NAME = 'appscode/kubedb'.freeze
18
19
  CATALOG_CHART_NAME = 'appscode/kubedb-catalog'.freeze
19
- OPERATOR_WAIT_INTERVAL = 5 # seconds
20
- OPERATOR_WAIT_MAX = 60 # seconds
20
+ WAIT_INTERVAL = 5 # seconds
21
+ WAIT_MAX = 120 # seconds
21
22
 
22
23
  OPERATOR_PARAMS = {
23
24
  'apiserver.enableValidatingWebhook' => 'true',
@@ -26,60 +27,71 @@ module Kuby
26
27
 
27
28
  OPERATOR_PARAMS.freeze
28
29
 
30
+ REPLICA_SET_MATCH_LABELS = {
31
+ 'release' => OPERATOR_RELEASE_NAME,
32
+ 'app' => 'kubedb'
33
+ }
34
+
35
+ REPLICA_SET_MATCH_LABELS.freeze
36
+
29
37
  def setup
30
- Kuby.logger.info('Setting up kubedb')
38
+ Kuby.logger.info('Setting up KubeDB')
31
39
 
32
- Kuby.logger.info('Fetching Helm chart')
40
+ Kuby.logger.info('Fetching KubeDB Helm chart')
33
41
  helm_cli.add_repo(REPO_NAME, REPO_URL)
34
42
  helm_cli.update_repos
35
43
 
36
- Kuby.logger.info('Deploying kubedb operator')
44
+ Kuby.logger.info('Deploying KubeDB operator')
37
45
  operator_deployed? ? upgrade_operator : install_operator
38
46
 
39
47
  wait_for_operator do
40
- Kuby.logger.info('Waiting for kubedb operator deployment')
48
+ Kuby.logger.info('Waiting for KubeDB operator deployment')
49
+ end
50
+
51
+ wait_for_api_resources do
52
+ Kuby.logger.info('Waiting for API resources to become available')
41
53
  end
42
54
 
43
55
  Kuby.logger.info('Deploying kubedb catalog')
44
56
  catalog_deployed? ? upgrade_catalog : install_catalog
45
57
 
46
- Kuby.logger.info('Kubedb setup finished')
58
+ Kuby.logger.info('KubeDB setup finished')
47
59
  end
48
60
 
49
61
  private
50
62
 
51
63
  def install_operator
52
- helm_cli.install_chart(OPERATOR_CHART_NAME, {
64
+ helm_cli.install_chart(OPERATOR_CHART_NAME,
53
65
  release: OPERATOR_RELEASE_NAME,
54
66
  version: Kuby::KubeDB::KUBEDB_VERSION,
55
67
  namespace: NAMESPACE,
56
68
  params: OPERATOR_PARAMS
57
- })
69
+ )
58
70
  end
59
71
 
60
72
  def upgrade_operator
61
- helm_cli.upgrade_chart(OPERATOR_CHART_NAME, {
73
+ helm_cli.upgrade_chart(OPERATOR_CHART_NAME,
62
74
  release: OPERATOR_RELEASE_NAME,
63
75
  version: Kuby::KubeDB::KUBEDB_VERSION,
64
76
  namespace: NAMESPACE,
65
77
  params: OPERATOR_PARAMS
66
- })
78
+ )
67
79
  end
68
80
 
69
81
  def install_catalog
70
- helm_cli.install_chart(CATALOG_CHART_NAME, {
82
+ helm_cli.install_chart(CATALOG_CHART_NAME,
71
83
  release: CATALOG_RELEASE_NAME,
72
84
  version: Kuby::KubeDB::KUBEDB_VERSION,
73
85
  namespace: NAMESPACE
74
- })
86
+ )
75
87
  end
76
88
 
77
89
  def upgrade_catalog
78
- helm_cli.upgrade_chart(CATALOG_CHART_NAME, {
90
+ helm_cli.upgrade_chart(CATALOG_CHART_NAME,
79
91
  release: CATALOG_RELEASE_NAME,
80
92
  version: Kuby::KubeDB::KUBEDB_VERSION,
81
93
  namespace: NAMESPACE
82
- })
94
+ )
83
95
  end
84
96
 
85
97
  def wait_for_operator
@@ -88,15 +100,35 @@ module Kuby
88
100
  loop do
89
101
  break if operator_ready?
90
102
 
91
- if time_elapsed >= OPERATOR_WAIT_MAX
103
+ if time_elapsed >= WAIT_MAX
92
104
  raise OperatorDeployError, 'timeout waiting for operator to start. '\
93
105
  "Waited #{time_elapsed}s."
94
106
  end
95
107
 
96
108
  yield
97
109
 
98
- sleep OPERATOR_WAIT_INTERVAL
99
- time_elapsed += OPERATOR_WAIT_INTERVAL
110
+ sleep WAIT_INTERVAL
111
+ time_elapsed += WAIT_INTERVAL
112
+ end
113
+ end
114
+
115
+ def wait_for_api_resources
116
+ time_elapsed = 0
117
+
118
+ loop do
119
+ begin
120
+ if time_elapsed >= WAIT_MAX
121
+ raise APIResourcesError, 'timeout waiting for API resources to '\
122
+ "become available. Waited #{time_elapsed}s."
123
+ end
124
+
125
+ kubernetes_cli.api_resources
126
+ break
127
+ rescue KubernetesCLI::KubernetesError
128
+ yield
129
+ sleep WAIT_INTERVAL
130
+ time_elapsed += WAIT_INTERVAL
131
+ end
100
132
  end
101
133
  end
102
134
 
@@ -142,20 +174,19 @@ module Kuby
142
174
  kubernetes_cli.get_object(
143
175
  'Deployment', NAMESPACE, OPERATOR_DEPLOYMENT_NAME
144
176
  )
145
- rescue ::Kuby::Kubernetes::GetResourceError
177
+ rescue ::KubernetesCLI::GetResourceError
146
178
  nil
147
179
  end
148
180
 
149
181
  def find_operator_rs(depl)
150
- match_labels = depl.dig('metadata', 'labels')
151
- all_rs_data = kubernetes_cli.get_objects('ReplicaSet', NAMESPACE, match_labels)
182
+ all_rs_data = kubernetes_cli.get_objects('ReplicaSet', NAMESPACE, REPLICA_SET_MATCH_LABELS)
152
183
  current_revision = depl.dig('metadata', 'annotations', 'deployment.kubernetes.io/revision')
153
184
 
154
185
  all_rs_data.find do |rs|
155
186
  rs.dig('metadata', 'ownerReferences').any? { |ref| ref['uid'] == depl.dig('metadata', 'uid') } &&
156
187
  rs.dig('metadata', 'annotations', 'deployment.kubernetes.io/revision') == current_revision
157
188
  end
158
- rescue ::Kuby::Kubernetes::GetResourceError
189
+ rescue ::KubernetesCLI::GetResourceError
159
190
  nil
160
191
  end
161
192
 
@@ -168,7 +199,7 @@ module Kuby
168
199
  end
169
200
 
170
201
  def helm_cli
171
- @helm_cli ||= HelmCLI.new(provider.kubeconfig_path)
202
+ provider.helm_cli
172
203
  end
173
204
 
174
205
  def kubernetes_cli
@@ -176,7 +207,7 @@ module Kuby
176
207
  end
177
208
 
178
209
  def provider
179
- definition.kubernetes.provider
210
+ environment.kubernetes.provider
180
211
  end
181
212
  end
182
213
  end
@@ -1,6 +1,6 @@
1
1
  module Kuby
2
2
  module KubeDB
3
- VERSION = '0.4.0'.freeze
3
+ VERSION = '0.7.0'.freeze
4
4
  KUBEDB_VERSION = '0.12.0'.freeze
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,17 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuby-kube-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-18 00:00:00.000000000 Z
11
+ date: 2021-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: helm-cli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: helm-rb
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
@@ -235,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
249
  - !ruby/object:Gem::Version
236
250
  version: '0'
237
251
  requirements: []
238
- rubygems_version: 3.1.4
252
+ rubygems_version: 3.2.3
239
253
  signing_key:
240
254
  specification_version: 4
241
255
  summary: KubeDB plugin for Kuby.