kubernetes-deploy 0.30.0 → 0.31.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +15 -0
  4. data/CONTRIBUTING.md +2 -2
  5. data/README.md +1 -1
  6. data/dev.yml +1 -1
  7. data/dev/flamegraph-from-tests +1 -1
  8. data/exe/kubernetes-deploy +11 -9
  9. data/exe/kubernetes-render +9 -7
  10. data/exe/kubernetes-restart +3 -3
  11. data/exe/kubernetes-run +1 -1
  12. data/kubernetes-deploy.gemspec +3 -3
  13. data/lib/krane.rb +5 -3
  14. data/lib/{kubernetes-deploy → krane}/bindings_parser.rb +1 -1
  15. data/lib/krane/cli/deploy_command.rb +14 -11
  16. data/lib/krane/cli/global_deploy_command.rb +47 -0
  17. data/lib/krane/cli/krane.rb +12 -3
  18. data/lib/krane/cli/render_command.rb +11 -9
  19. data/lib/krane/cli/restart_command.rb +4 -4
  20. data/lib/krane/cli/run_command.rb +3 -3
  21. data/lib/krane/cli/version_command.rb +1 -1
  22. data/lib/krane/cluster_resource_discovery.rb +102 -0
  23. data/lib/{kubernetes-deploy → krane}/common.rb +8 -9
  24. data/lib/krane/concerns/template_reporting.rb +29 -0
  25. data/lib/{kubernetes-deploy → krane}/concurrency.rb +1 -1
  26. data/lib/{kubernetes-deploy → krane}/container_logs.rb +1 -1
  27. data/lib/{kubernetes-deploy → krane}/deferred_summary_logging.rb +2 -2
  28. data/lib/{kubernetes-deploy → krane}/delayed_exceptions.rb +0 -0
  29. data/lib/krane/deploy_task.rb +2 -2
  30. data/lib/{kubernetes-deploy → krane}/deploy_task_config_validator.rb +1 -1
  31. data/lib/krane/deprecated_deploy_task.rb +404 -0
  32. data/lib/{kubernetes-deploy → krane}/duration_parser.rb +1 -1
  33. data/lib/{kubernetes-deploy → krane}/ejson_secret_provisioner.rb +3 -3
  34. data/lib/krane/errors.rb +28 -0
  35. data/lib/{kubernetes-deploy → krane}/formatted_logger.rb +2 -2
  36. data/lib/krane/global_deploy_task.rb +210 -0
  37. data/lib/krane/global_deploy_task_config_validator.rb +12 -0
  38. data/lib/{kubernetes-deploy → krane}/kubeclient_builder.rb +11 -3
  39. data/lib/{kubernetes-deploy → krane}/kubectl.rb +2 -2
  40. data/lib/{kubernetes-deploy → krane}/kubernetes_resource.rb +54 -22
  41. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/cloudsql.rb +1 -1
  42. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/config_map.rb +1 -1
  43. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/cron_job.rb +1 -1
  44. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/custom_resource.rb +2 -2
  45. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/custom_resource_definition.rb +1 -5
  46. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/daemon_set.rb +7 -4
  47. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/deployment.rb +2 -2
  48. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/horizontal_pod_autoscaler.rb +1 -1
  49. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/ingress.rb +1 -1
  50. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/job.rb +1 -1
  51. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/network_policy.rb +1 -1
  52. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/persistent_volume_claim.rb +1 -1
  53. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/pod.rb +2 -2
  54. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/pod_disruption_budget.rb +2 -2
  55. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/pod_set_base.rb +3 -3
  56. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/pod_template.rb +1 -1
  57. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/replica_set.rb +2 -2
  58. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/resource_quota.rb +1 -1
  59. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/role.rb +1 -1
  60. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/role_binding.rb +1 -1
  61. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/secret.rb +1 -1
  62. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/service.rb +2 -2
  63. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/service_account.rb +1 -1
  64. data/lib/{kubernetes-deploy → krane}/kubernetes_resource/stateful_set.rb +2 -2
  65. data/lib/{kubernetes-deploy → krane}/label_selector.rb +1 -1
  66. data/lib/{kubernetes-deploy → krane}/oj.rb +0 -0
  67. data/lib/{kubernetes-deploy → krane}/options_helper.rb +2 -2
  68. data/lib/{kubernetes-deploy → krane}/remote_logs.rb +2 -2
  69. data/lib/krane/render_task.rb +149 -0
  70. data/lib/{kubernetes-deploy → krane}/renderer.rb +1 -1
  71. data/lib/{kubernetes-deploy → krane}/resource_cache.rb +4 -3
  72. data/lib/krane/resource_deployer.rb +265 -0
  73. data/lib/{kubernetes-deploy → krane}/resource_watcher.rb +6 -6
  74. data/lib/krane/restart_task.rb +224 -0
  75. data/lib/{kubernetes-deploy → krane}/rollout_conditions.rb +1 -1
  76. data/lib/krane/runner_task.rb +212 -0
  77. data/lib/{kubernetes-deploy → krane}/runner_task_config_validator.rb +1 -1
  78. data/lib/{kubernetes-deploy → krane}/statsd.rb +13 -27
  79. data/lib/krane/task_config.rb +19 -0
  80. data/lib/{kubernetes-deploy → krane}/task_config_validator.rb +1 -1
  81. data/lib/{kubernetes-deploy → krane}/template_sets.rb +5 -5
  82. data/lib/krane/version.rb +4 -0
  83. data/lib/kubernetes-deploy/deploy_task.rb +6 -603
  84. data/lib/kubernetes-deploy/errors.rb +1 -26
  85. data/lib/kubernetes-deploy/render_task.rb +5 -139
  86. data/lib/kubernetes-deploy/rescue_krane_exceptions.rb +18 -0
  87. data/lib/kubernetes-deploy/restart_task.rb +6 -215
  88. data/lib/kubernetes-deploy/runner_task.rb +6 -203
  89. metadata +75 -58
  90. data/lib/kubernetes-deploy/cluster_resource_discovery.rb +0 -57
  91. data/lib/kubernetes-deploy/task_config.rb +0 -16
  92. data/lib/kubernetes-deploy/version.rb +0 -4
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.30.0
4
+ version: 0.31.0
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: 2019-10-21 00:00:00.000000000 Z
12
+ date: 2019-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -85,16 +85,22 @@ dependencies:
85
85
  name: statsd-instrument
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '2.8'
91
+ - - "<"
89
92
  - !ruby/object:Gem::Version
90
- version: 2.3.2
93
+ version: '3.1'
91
94
  type: :runtime
92
95
  prerelease: false
93
96
  version_requirements: !ruby/object:Gem::Requirement
94
97
  requirements:
95
- - - "~>"
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '2.8'
101
+ - - "<"
96
102
  - !ruby/object:Gem::Version
97
- version: 2.3.2
103
+ version: '3.1'
98
104
  - !ruby/object:Gem::Dependency
99
105
  name: oj
100
106
  requirement: !ruby/object:Gem::Requirement
@@ -273,71 +279,82 @@ files:
273
279
  - exe/kubernetes-run
274
280
  - kubernetes-deploy.gemspec
275
281
  - lib/krane.rb
282
+ - lib/krane/bindings_parser.rb
276
283
  - lib/krane/cli/deploy_command.rb
284
+ - lib/krane/cli/global_deploy_command.rb
277
285
  - lib/krane/cli/krane.rb
278
286
  - lib/krane/cli/render_command.rb
279
287
  - lib/krane/cli/restart_command.rb
280
288
  - lib/krane/cli/run_command.rb
281
289
  - lib/krane/cli/version_command.rb
290
+ - lib/krane/cluster_resource_discovery.rb
291
+ - lib/krane/common.rb
292
+ - lib/krane/concerns/template_reporting.rb
293
+ - lib/krane/concurrency.rb
294
+ - lib/krane/container_logs.rb
295
+ - lib/krane/deferred_summary_logging.rb
296
+ - lib/krane/delayed_exceptions.rb
282
297
  - lib/krane/deploy_task.rb
298
+ - lib/krane/deploy_task_config_validator.rb
299
+ - lib/krane/deprecated_deploy_task.rb
300
+ - lib/krane/duration_parser.rb
301
+ - lib/krane/ejson_secret_provisioner.rb
302
+ - lib/krane/errors.rb
303
+ - lib/krane/formatted_logger.rb
304
+ - lib/krane/global_deploy_task.rb
305
+ - lib/krane/global_deploy_task_config_validator.rb
306
+ - lib/krane/kubeclient_builder.rb
307
+ - lib/krane/kubectl.rb
308
+ - lib/krane/kubernetes_resource.rb
309
+ - lib/krane/kubernetes_resource/cloudsql.rb
310
+ - lib/krane/kubernetes_resource/config_map.rb
311
+ - lib/krane/kubernetes_resource/cron_job.rb
312
+ - lib/krane/kubernetes_resource/custom_resource.rb
313
+ - lib/krane/kubernetes_resource/custom_resource_definition.rb
314
+ - lib/krane/kubernetes_resource/daemon_set.rb
315
+ - lib/krane/kubernetes_resource/deployment.rb
316
+ - lib/krane/kubernetes_resource/horizontal_pod_autoscaler.rb
317
+ - lib/krane/kubernetes_resource/ingress.rb
318
+ - lib/krane/kubernetes_resource/job.rb
319
+ - lib/krane/kubernetes_resource/network_policy.rb
320
+ - lib/krane/kubernetes_resource/persistent_volume_claim.rb
321
+ - lib/krane/kubernetes_resource/pod.rb
322
+ - lib/krane/kubernetes_resource/pod_disruption_budget.rb
323
+ - lib/krane/kubernetes_resource/pod_set_base.rb
324
+ - lib/krane/kubernetes_resource/pod_template.rb
325
+ - lib/krane/kubernetes_resource/replica_set.rb
326
+ - lib/krane/kubernetes_resource/resource_quota.rb
327
+ - lib/krane/kubernetes_resource/role.rb
328
+ - lib/krane/kubernetes_resource/role_binding.rb
329
+ - lib/krane/kubernetes_resource/secret.rb
330
+ - lib/krane/kubernetes_resource/service.rb
331
+ - lib/krane/kubernetes_resource/service_account.rb
332
+ - lib/krane/kubernetes_resource/stateful_set.rb
333
+ - lib/krane/label_selector.rb
334
+ - lib/krane/oj.rb
335
+ - lib/krane/options_helper.rb
336
+ - lib/krane/remote_logs.rb
337
+ - lib/krane/render_task.rb
338
+ - lib/krane/renderer.rb
339
+ - lib/krane/resource_cache.rb
340
+ - lib/krane/resource_deployer.rb
341
+ - lib/krane/resource_watcher.rb
342
+ - lib/krane/restart_task.rb
343
+ - lib/krane/rollout_conditions.rb
344
+ - lib/krane/runner_task.rb
345
+ - lib/krane/runner_task_config_validator.rb
346
+ - lib/krane/statsd.rb
347
+ - lib/krane/task_config.rb
348
+ - lib/krane/task_config_validator.rb
349
+ - lib/krane/template_sets.rb
350
+ - lib/krane/version.rb
283
351
  - lib/kubernetes-deploy.rb
284
- - lib/kubernetes-deploy/bindings_parser.rb
285
- - lib/kubernetes-deploy/cluster_resource_discovery.rb
286
- - lib/kubernetes-deploy/common.rb
287
- - lib/kubernetes-deploy/concurrency.rb
288
- - lib/kubernetes-deploy/container_logs.rb
289
- - lib/kubernetes-deploy/deferred_summary_logging.rb
290
- - lib/kubernetes-deploy/delayed_exceptions.rb
291
352
  - lib/kubernetes-deploy/deploy_task.rb
292
- - lib/kubernetes-deploy/deploy_task_config_validator.rb
293
- - lib/kubernetes-deploy/duration_parser.rb
294
- - lib/kubernetes-deploy/ejson_secret_provisioner.rb
295
353
  - lib/kubernetes-deploy/errors.rb
296
- - lib/kubernetes-deploy/formatted_logger.rb
297
- - lib/kubernetes-deploy/kubeclient_builder.rb
298
- - lib/kubernetes-deploy/kubectl.rb
299
- - lib/kubernetes-deploy/kubernetes_resource.rb
300
- - lib/kubernetes-deploy/kubernetes_resource/cloudsql.rb
301
- - lib/kubernetes-deploy/kubernetes_resource/config_map.rb
302
- - lib/kubernetes-deploy/kubernetes_resource/cron_job.rb
303
- - lib/kubernetes-deploy/kubernetes_resource/custom_resource.rb
304
- - lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb
305
- - lib/kubernetes-deploy/kubernetes_resource/daemon_set.rb
306
- - lib/kubernetes-deploy/kubernetes_resource/deployment.rb
307
- - lib/kubernetes-deploy/kubernetes_resource/horizontal_pod_autoscaler.rb
308
- - lib/kubernetes-deploy/kubernetes_resource/ingress.rb
309
- - lib/kubernetes-deploy/kubernetes_resource/job.rb
310
- - lib/kubernetes-deploy/kubernetes_resource/network_policy.rb
311
- - lib/kubernetes-deploy/kubernetes_resource/persistent_volume_claim.rb
312
- - lib/kubernetes-deploy/kubernetes_resource/pod.rb
313
- - lib/kubernetes-deploy/kubernetes_resource/pod_disruption_budget.rb
314
- - lib/kubernetes-deploy/kubernetes_resource/pod_set_base.rb
315
- - lib/kubernetes-deploy/kubernetes_resource/pod_template.rb
316
- - lib/kubernetes-deploy/kubernetes_resource/replica_set.rb
317
- - lib/kubernetes-deploy/kubernetes_resource/resource_quota.rb
318
- - lib/kubernetes-deploy/kubernetes_resource/role.rb
319
- - lib/kubernetes-deploy/kubernetes_resource/role_binding.rb
320
- - lib/kubernetes-deploy/kubernetes_resource/secret.rb
321
- - lib/kubernetes-deploy/kubernetes_resource/service.rb
322
- - lib/kubernetes-deploy/kubernetes_resource/service_account.rb
323
- - lib/kubernetes-deploy/kubernetes_resource/stateful_set.rb
324
- - lib/kubernetes-deploy/label_selector.rb
325
- - lib/kubernetes-deploy/oj.rb
326
- - lib/kubernetes-deploy/options_helper.rb
327
- - lib/kubernetes-deploy/remote_logs.rb
328
354
  - lib/kubernetes-deploy/render_task.rb
329
- - lib/kubernetes-deploy/renderer.rb
330
- - lib/kubernetes-deploy/resource_cache.rb
331
- - lib/kubernetes-deploy/resource_watcher.rb
355
+ - lib/kubernetes-deploy/rescue_krane_exceptions.rb
332
356
  - lib/kubernetes-deploy/restart_task.rb
333
- - lib/kubernetes-deploy/rollout_conditions.rb
334
357
  - lib/kubernetes-deploy/runner_task.rb
335
- - lib/kubernetes-deploy/runner_task_config_validator.rb
336
- - lib/kubernetes-deploy/statsd.rb
337
- - lib/kubernetes-deploy/task_config.rb
338
- - lib/kubernetes-deploy/task_config_validator.rb
339
- - lib/kubernetes-deploy/template_sets.rb
340
- - lib/kubernetes-deploy/version.rb
341
358
  - pull_request_template.md
342
359
  - screenshots/deploy-demo.gif
343
360
  - screenshots/migrate-logs.png
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module KubernetesDeploy
4
- class ClusterResourceDiscovery
5
- delegate :namespace, :context, :logger, to: :@task_config
6
-
7
- def initialize(task_config:, namespace_tags: [])
8
- @task_config = task_config
9
- @namespace_tags = namespace_tags
10
- end
11
-
12
- def crds
13
- @crds ||= fetch_crds.map do |cr_def|
14
- CustomResourceDefinition.new(namespace: namespace, context: context, logger: logger,
15
- definition: cr_def, statsd_tags: @namespace_tags)
16
- end
17
- end
18
-
19
- def global_resource_kinds
20
- @globals ||= fetch_globals.map { |g| g["kind"] }
21
- end
22
-
23
- private
24
-
25
- def fetch_globals
26
- raw, _, st = kubectl.run("api-resources", "--namespaced=false", output: "wide", attempts: 5)
27
- if st.success?
28
- rows = raw.split("\n")
29
- header = rows[0]
30
- resources = rows[1..-1]
31
- full_width_field_names = header.downcase.scan(/[a-z]+[\W]*/)
32
- cursor = 0
33
- fields = full_width_field_names.each_with_object({}) do |name, hash|
34
- start = cursor
35
- cursor = start + name.length
36
- hash[name.strip] = [start, cursor - 1]
37
- end
38
- resources.map { |r| fields.map { |k, (s, e)| [k.strip, r[s..e].strip] }.to_h }
39
- else
40
- []
41
- end
42
- end
43
-
44
- def fetch_crds
45
- raw_json, _, st = kubectl.run("get", "CustomResourceDefinition", output: "json", attempts: 5)
46
- if st.success?
47
- JSON.parse(raw_json)["items"]
48
- else
49
- []
50
- end
51
- end
52
-
53
- def kubectl
54
- @kubectl ||= Kubectl.new(task_config: @task_config, log_failure_by_default: true)
55
- end
56
- end
57
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
- module KubernetesDeploy
3
- class TaskConfig
4
- attr_reader :context, :namespace
5
-
6
- def initialize(context, namespace, logger = nil)
7
- @context = context
8
- @namespace = namespace
9
- @logger = logger
10
- end
11
-
12
- def logger
13
- @logger ||= KubernetesDeploy::FormattedLogger.build(@namespace, @context)
14
- end
15
- end
16
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
- module KubernetesDeploy
3
- VERSION = "0.30.0"
4
- end