krane 3.6.2 → 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: ba72a52b848777243b9335d8df21f98080fcf49142706c2443bf40475d071b5f
4
- data.tar.gz: 4f1a17c291e5ef38847f7a083cc1d6dcc00262c0dd447a39b7c39ab044268142
3
+ metadata.gz: 0bb4b346e9146186c9e1549f71708707568aa9872a2b7e0e1a0e6fd01e9f4d52
4
+ data.tar.gz: fb3662468c546ba6717cfd9de125cd4d6ef2caa2269404a618c2152770fc0d3d
5
5
  SHA512:
6
- metadata.gz: fdae1d679008ec4de4ee83c2f1925f7b168456189f824face6b3d3f7079bdda89c25bea6da676ab95508cc5ce125587863e8af307a6f6d3814dc75b029280d56
7
- data.tar.gz: 603e6f890a482b0e549ed9b1c0deca4ae3e4bb73144c7174f2a430c964127ee4cd75d516eb4e7561258afac29c711f5b595c3cc35316cf4c9e05a6a1aeab9bf0
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,5 +1,13 @@
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
+
3
11
  ## 3.6.2
4
12
 
5
13
  - Pinning `stats-instrument` to < 3.9 to avoid breaking changes.
@@ -8,7 +16,7 @@
8
16
 
9
17
  *Features*
10
18
 
11
- - 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`.
12
20
 
13
21
  ## 3.6.0
14
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,7 +6,7 @@ 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
12
  run: bin/test unit_test && bin/test cli_test && bin/test serial_integration_test && bin/test integration_test
@@ -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.2"
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.2
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-21 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
@@ -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.17
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