krane 3.6.1 → 3.7.0

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
  SHA256:
3
- metadata.gz: d78cc316978de660c325dc26a7e6857b4b0c622537558929a769c282007203ce
4
- data.tar.gz: a8ff6c78f240824244b77ada8f4e835576cd42a97955c4113edb8369feedc086
3
+ metadata.gz: 0bb4b346e9146186c9e1549f71708707568aa9872a2b7e0e1a0e6fd01e9f4d52
4
+ data.tar.gz: fb3662468c546ba6717cfd9de125cd4d6ef2caa2269404a618c2152770fc0d3d
5
5
  SHA512:
6
- metadata.gz: cea17bc39a0fafc26dc2fd0a0de0c5091e4efdd444548559516136d7cde0b10003b30ce924b65859e89e711f7379d64815e89e98b8bfbf55c82b98ec2c8883ca
7
- data.tar.gz: d4d3a0aade84bc17a7add8f11bb436820ad0f6f36202a9bf96b9ca80847291c885d6f249a77ea002efa6b9a4e80bd14b8797247eefb82e8a6d7a528e5db95a91
6
+ metadata.gz: 7a4e23ab9d917f223c6e294a61b26d17791c3554257bbc81a95e5372f1d90af727a13b3bf470008be750fafbb7dbef322486289a2b247e9e60881eff2f4bad15
7
+ data.tar.gz: b73325f5894e1a9ed67e75d1dc1759ceea4afe58aad5be81f27905bd3d0a10ff38012494c26cf68b06c338cd24367bb8e6d472e7b394aed3f3e0f3dd1ff56546
@@ -18,6 +18,7 @@ jobs:
18
18
  - "3.0.4"
19
19
  - "2.7.6"
20
20
  kubernetes_version:
21
+ - "1.31.2"
21
22
  - "1.30.0"
22
23
  - "1.29.4"
23
24
  - "1.28.0"
@@ -29,6 +30,8 @@ jobs:
29
30
  - "serial_integration_test"
30
31
  - "integration_test"
31
32
  include:
33
+ - kubernetes_version: "1.31.2"
34
+ kind_image: "kindest/node:v1.31.2@sha256:18fbefc20a7113353c7b75b5c869d7145a6abd6269154825872dc59c1329912e"
32
35
  - kubernetes_version: "1.30.0"
33
36
  kind_image: "kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1eaba9702bef25227a794b52890dd8bcd692e"
34
37
  - kubernetes_version: "1.29.4"
data/CHANGELOG.md CHANGED
@@ -1,10 +1,22 @@
1
1
  ## next
2
2
 
3
+ ## 3.7.0
4
+
5
+ - Annotate individual resources with `last-applied-configuration` when using `krane deploy` with `--annotate-individuals`. Previously, eligible resources that were made with `create` or `replace` were applied along with the rest of the resources. However, this causes issues when a mutating admission controller modifies otherwise immutable fields.
6
+
7
+ ## 3.6.3
8
+
9
+ - Test against k8s 1.31
10
+
11
+ ## 3.6.2
12
+
13
+ - Pinning `stats-instrument` to < 3.9 to avoid breaking changes.
14
+
3
15
  ## 3.6.1
4
16
 
5
17
  *Features*
6
18
 
7
- - Enable the option to bypass endpoint validation for a service by using the annotation `krane.shopify.io/skip-endpoint-validation: true`.
19
+ - Enable the option to bypass endpoint validation for a service by using the annotation `krane.shopify.io/skip-endpoint-validation: true`.
8
20
 
9
21
  ## 3.6.0
10
22
 
data/README.md CHANGED
@@ -97,6 +97,7 @@ Krane provides support for official upstream supported versions [Kubernetes](htt
97
97
  | 1.28 | Yes | -- |
98
98
  | 1.29 | Yes | -- |
99
99
  | 1.30 | Yes | -- |
100
+ | 1.31 | Yes | -- |
100
101
 
101
102
  ## Installation
102
103
 
data/dev.yml CHANGED
@@ -6,10 +6,18 @@ up:
6
6
  - podman
7
7
  - kind:
8
8
  name: krane
9
- image: kindest/node:v1.28.0@sha256:dad5a6238c5e41d7cac405fae3b5eda2ad1de6f1190fa8bfc64ff5bb86173213
9
+ image: kindest/node:v1.31.2@sha256:18fbefc20a7113353c7b75b5c869d7145a6abd6269154825872dc59c1329912e
10
10
  commands:
11
11
  test:
12
- run: bin/test
12
+ run: bin/test unit_test && bin/test cli_test && bin/test serial_integration_test && bin/test integration_test
13
+ test-unit:
14
+ run: bin/test unit_test
15
+ test-cli:
16
+ run: bin/test cli_test
17
+ test-serial_integration:
18
+ run: bin/test serial_integration_test,
19
+ test-integration:
20
+ run: bin/test integration_test
13
21
  tophat:
14
22
  run: PRINT_LOGS=1 bundle exec ruby -I test test/integration/krane_deploy_test.rb -n/${1}/
15
23
  desc: Tophat a change by running a test scenario with logging output enabled.
data/krane.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency("googleauth", "~> 1.2")
32
32
  spec.add_dependency("ejson", "~> 1.0")
33
33
  spec.add_dependency("colorize", "~> 0.8")
34
- spec.add_dependency("statsd-instrument", ['>= 2.8', "< 4"])
34
+ spec.add_dependency("statsd-instrument", ['>= 2.8', "< 3.9"])
35
35
  spec.add_dependency("multi_json")
36
36
  spec.add_dependency("concurrent-ruby", "~> 1.1")
37
37
  spec.add_dependency("jsonpath", "~> 1.0")
@@ -22,7 +22,7 @@ module Krane
22
22
 
23
23
  def deploy!(resources, verify_result, prune)
24
24
  if verify_result
25
- deploy_all_resources(resources, prune: prune, verify: true)
25
+ deploy_all_resources(resources, prune: prune, verify: true, annotate_individuals: true)
26
26
  failed_resources = resources.reject(&:deploy_succeeded?)
27
27
  success = failed_resources.empty?
28
28
  if !success && failed_resources.all?(&:deploy_timed_out?)
@@ -30,7 +30,7 @@ module Krane
30
30
  end
31
31
  raise FatalDeploymentError unless success
32
32
  else
33
- deploy_all_resources(resources, prune: prune, verify: false)
33
+ deploy_all_resources(resources, prune: prune, verify: false, annotate_individuals: true)
34
34
  logger.summary.add_action("deployed #{resources.length} #{'resource'.pluralize(resources.length)}")
35
35
  warning = <<~MSG
36
36
  Deploy result verification is disabled for this deploy.
@@ -73,12 +73,13 @@ module Krane
73
73
 
74
74
  private
75
75
 
76
- def deploy_all_resources(resources, prune: false, verify:, record_summary: true)
77
- deploy_resources(resources, prune: prune, verify: verify, record_summary: record_summary)
76
+ def deploy_all_resources(resources, prune: false, verify:, record_summary: true, annotate_individuals: false)
77
+ deploy_resources(resources, prune: prune, verify: verify, record_summary: record_summary,
78
+ annotate_individuals: annotate_individuals)
78
79
  end
79
80
  measure_method(:deploy_all_resources, 'normal_resources.duration')
80
81
 
81
- def deploy_resources(resources, prune: false, verify:, record_summary: true)
82
+ def deploy_resources(resources, prune: false, verify:, record_summary: true, annotate_individuals: false)
82
83
  return if resources.empty?
83
84
  deploy_started_at = Time.now.utc
84
85
 
@@ -96,7 +97,6 @@ module Krane
96
97
  applyables, individuals = resources.partition { |r| r.deploy_method == :apply }
97
98
  # Prunable resources should also applied so that they can be pruned
98
99
  pruneable_types = @prune_allowlist.map { |t| t.split("/").last }
99
- applyables += individuals.select { |r| pruneable_types.include?(r.type) && !r.deploy_method_override }
100
100
 
101
101
  individuals.each do |individual_resource|
102
102
  individual_resource.deploy_started_at = Time.now.utc
@@ -122,6 +122,11 @@ module Krane
122
122
 
123
123
  apply_all(applyables, prune)
124
124
 
125
+ if annotate_individuals
126
+ to_annotate = individuals.select { |r| pruneable_types.include?(r.type) && !r.deploy_method_override }
127
+ update_last_applied_annotations(to_annotate)
128
+ end
129
+
125
130
  if verify
126
131
  watcher = Krane::ResourceWatcher.new(resources: resources, deploy_started_at: deploy_started_at,
127
132
  timeout: @global_timeout, task_config: @task_config, sha: @current_sha)
@@ -252,6 +257,19 @@ module Krane
252
257
  [err, status]
253
258
  end
254
259
 
260
+ def update_last_applied_annotations(resources)
261
+ resources.each do |resource|
262
+ err, status = set_last_applied_annotation(resource)
263
+ raise FatalDeploymentError, "Failed to set last applied annotation: #{err}" unless status.success?
264
+ end
265
+ end
266
+
267
+ def set_last_applied_annotation(resource)
268
+ _, err, status = kubectl.run("apply", "set-last-applied", "--create-annotation", "-f", resource.file_path, log_failure: false,
269
+ output_is_sensitive: resource.sensitive_template_content?, use_namespace: !resource.global?)
270
+ [err, status]
271
+ end
272
+
255
273
  # Inspect the file referenced in the kubectl stderr
256
274
  # to make it easier for developer to understand what's going on
257
275
  def find_bad_files_from_kubectl_output(line)
data/lib/krane/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Krane
3
- VERSION = "3.6.1"
3
+ VERSION = "3.7.0"
4
4
  end
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: krane
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.1
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Verey
8
8
  - Daniel Turner
9
9
  - Kir Shatrov
10
- autorequire:
11
10
  bindir: exe
12
11
  cert_chain: []
13
- date: 2024-08-06 00:00:00.000000000 Z
12
+ date: 2025-01-16 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: activesupport
@@ -91,7 +90,7 @@ dependencies:
91
90
  version: '2.8'
92
91
  - - "<"
93
92
  - !ruby/object:Gem::Version
94
- version: '4'
93
+ version: '3.9'
95
94
  type: :runtime
96
95
  prerelease: false
97
96
  version_requirements: !ruby/object:Gem::Requirement
@@ -101,7 +100,7 @@ dependencies:
101
100
  version: '2.8'
102
101
  - - "<"
103
102
  - !ruby/object:Gem::Version
104
- version: '4'
103
+ version: '3.9'
105
104
  - !ruby/object:Gem::Dependency
106
105
  name: multi_json
107
106
  requirement: !ruby/object:Gem::Requirement
@@ -512,7 +511,6 @@ licenses:
512
511
  - MIT
513
512
  metadata:
514
513
  allowed_push_host: https://rubygems.org
515
- post_install_message:
516
514
  rdoc_options: []
517
515
  require_paths:
518
516
  - lib
@@ -527,8 +525,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
527
525
  - !ruby/object:Gem::Version
528
526
  version: '0'
529
527
  requirements: []
530
- rubygems_version: 3.5.16
531
- signing_key:
528
+ rubygems_version: 3.6.2
532
529
  specification_version: 4
533
530
  summary: A command line tool that helps you ship changes to a Kubernetes namespace
534
531
  and understand the result