krane 2.3.4 → 2.4.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: 3e1fd1232d053c7f2bc648a315551c103ebd4792165f7b8c9b81f1c0b2f810bc
4
- data.tar.gz: 214360319ed90c6bc752d99ee1b3e08244703ad56d3b5e964993fccee2b7562c
3
+ metadata.gz: 8100399551f3e460863aa36cd1be88385a4dc648701f53a0be2bf13005796b63
4
+ data.tar.gz: f5842c8d9d7f71ba9e7b0b5b2b16d956b4ba71931571d9badf3d7bc2a4eae846
5
5
  SHA512:
6
- metadata.gz: a98198f5aed91b383295bf7ddcd9dad6bdcc68d5361582ef873fa53b7b191d92963c9bd359c841f0c95b7e3c007e0f32dbc331019d5c8a4bf2c4358ccf0aac5c
7
- data.tar.gz: 6267bef54343cdf3c301cab0bd377a1d6110b1c2862bdf2dc5288fd0ffba8337a1cc88aa7e708e8a19dd042646699e3ad64c3d23171e0f23a9a5f5a85fcf470c
6
+ metadata.gz: 4ed454e7264750fd9b44ab0f3badbff014eb511b3ecd4696dce0b72cee7da2a0efdfac92a65214ead36fc336b941be6869e4282f47846e9dfbd2d9230a8a1607
7
+ data.tar.gz: 6be5ba46142a43dd1965dca486de1e42020b7aa7c9a806d21a150bb581598dfdf8bb203361be97072a6f7e18a6041335ce722073bc5cd6830f2444828c423484
@@ -0,0 +1,66 @@
1
+ name: Krane CI
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ ruby-tests:
7
+ runs-on: ubuntu-latest
8
+
9
+ name: "Tests - Ruby ${{ matrix.ruby }} with k8s ${{ matrix.kubernetes_version }}"
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby:
14
+ # Use unique Ruby versions, or GitHub gets confused when building the rest of the matrix
15
+ - '3.0.3' # With k8s 1.23
16
+ - '3.0.2' # With k8s 1.22
17
+ - '3.0.1' # With k8s 1.21
18
+ - '3.0' # With k8s 1.20
19
+ - '2.7' # With k8s 1.19
20
+ include:
21
+ # Match kind images with chosen version https://github.com/kubernetes-sigs/kind/releases
22
+ - ruby: '3.0.3'
23
+ kind_version: 'v0.11.1'
24
+ kubernetes_version: '1.23.0'
25
+ kind_image: 'kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac'
26
+ - ruby: '3.0.2'
27
+ kind_version: 'v0.11.1'
28
+ kubernetes_version: '1.22.0'
29
+ kind_image: 'kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047'
30
+ - ruby: '3.0.1'
31
+ kind_version: 'v0.11.1'
32
+ kubernetes_version: '1.21.1'
33
+ kind_image: 'kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6'
34
+ - ruby: '3.0'
35
+ kind_version: 'v0.11.1'
36
+ kubernetes_version: '1.20.7'
37
+ kind_image: 'kindest/node:v1.20.7@sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9'
38
+ - ruby: '2.7'
39
+ kind_version: 'v0.11.1'
40
+ kubernetes_version: '1.19.11'
41
+ kind_image: 'kindest/node:v1.19.11@sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729'
42
+
43
+ steps:
44
+ - uses: actions/checkout@v2
45
+
46
+ - name: Set up Ruby ${{ matrix.ruby }}
47
+ uses: ruby/setup-ruby@v1
48
+ with:
49
+ ruby-version: ${{ matrix.ruby }}
50
+ bundler-cache: true
51
+
52
+ - name: Setup kubectl
53
+ run: |
54
+ mkdir -p "${GITHUB_WORKSPACE}/bin"
55
+ curl -o "${GITHUB_WORKSPACE}/bin/kubectl" -LO "https://dl.k8s.io/release/v${{ matrix.kubernetes_version }}/bin/linux/amd64/kubectl"
56
+ chmod +x "${GITHUB_WORKSPACE}/bin/kubectl"
57
+ echo "PATH=$GITHUB_WORKSPACE/bin:${PATH}" >> $GITHUB_ENV
58
+
59
+ - uses: engineerd/setup-kind@v0.5.0
60
+ with:
61
+ version: "${{ matrix.kind_version }}"
62
+ image: "${{ matrix.kind_image }}"
63
+
64
+ - name: Run tests
65
+ run: |
66
+ bin/test
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ dev/flamegraph.svg
15
15
  dev/profile
16
16
  dev/flamegraph.pl
17
17
  .local-context
18
+ bin/kind
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  ## next
2
2
 
3
+ ## 2.4.0
4
+
5
+ *Enhancements*
6
+
7
+ - Ensure deploy tasks fail without at least one non-empty resource [#865](https://github.com/Shopify/krane/issues/865)
8
+
9
+ *Other*
10
+
11
+ - Remove Ruby 2.6 and K8s < 1.19 from the CI testing matrix. All fixtures have been updated to be compatible with K8s 1.22+.
12
+
13
+ ## 2.3.7
14
+
15
+ - isolated_execution_state active_support require for Rails 7+
16
+
17
+ ## 2.3.6
18
+
19
+ - Update kubeclient for better Ruby 3.1 compatibility.
20
+
21
+ ## 2.3.5
22
+
23
+ - Psych 4 compatibility
24
+
3
25
  ## 2.3.4
4
26
 
5
27
  - Fix for [CVE-2021-41817](https://www.ruby-lang.org/en/news/2021/11/15/date-parsing-method-regexp-dos-cve-2021-41817/). See [ServicesDB action item here](https://services.shopify.io/action_items/definitions/isolated/59).
data/README.md CHANGED
@@ -74,23 +74,23 @@ If you need the ability to render dynamic values in templates before deploying,
74
74
  ## Prerequisites
75
75
 
76
76
  * Ruby 2.6+
77
- * Your cluster must be running Kubernetes v1.15.0 or higher<sup>1</sup>
77
+ * Your cluster must be running Kubernetes v1.19.0 or higher<sup>1</sup>
78
78
 
79
79
  <sup>1</sup> We run integration tests against these Kubernetes versions. You can find our
80
80
  official compatibility chart below.
81
81
 
82
- | Kubernetes version | Last officially supported in gem version |
83
- | :----------------: | :-------------------: |
84
- | 1.5 | 0.11.2 |
85
- | 1.6 | 0.15.2 |
86
- | 1.7 | 0.20.6 |
87
- | 1.8 | 0.21.1 |
88
- | 1.9 | 0.24.0 |
89
- | 1.10 | 0.27.0 |
82
+ | Kubernetes version | Currently Tested? | Last officially supported in gem version |
83
+ |:------------------:|-------------------|:----------------------------------------:|
84
+ | 1.18 | No | 2.3.7 |
85
+ | 1.19 | Yes | -- |
86
+ | 1.20 | Yes | -- |
87
+ | 1.21 | Yes | -- |
88
+ | 1.22 | Yes | -- |
89
+ | 1.23 | Yes | -- |
90
90
 
91
91
  ## Installation
92
92
 
93
- 1. [Install kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-binary-via-curl) (requires v1.15.0 or higher) and make sure it is available in your $PATH
93
+ 1. [Install kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-binary-via-curl) (requires v1.19.0 or higher) and make sure it is available in your $PATH
94
94
  2. Set up your [kubeconfig file](https://kubernetes.io/docs/tasks/access-application-cluster/authenticate-across-clusters-kubeconfig/) for access to your cluster(s).
95
95
  3. `gem install krane`
96
96
 
data/Rakefile CHANGED
@@ -7,6 +7,7 @@ Rake::TestTask.new(:integration_test) do |t|
7
7
  t.libs << "test"
8
8
  t.libs << "lib"
9
9
  t.test_files = FileList['test/integration/**/*_test.rb']
10
+ t.warning = !ENV.key?('CI')
10
11
  end
11
12
 
12
13
  desc("Run integration tests that CANNOT be run in parallel")
@@ -14,6 +15,7 @@ Rake::TestTask.new(:serial_integration_test) do |t|
14
15
  t.libs << "test"
15
16
  t.libs << "lib"
16
17
  t.test_files = FileList['test/integration-serial/**/*_test.rb']
18
+ t.warning = !ENV.key?('CI')
17
19
  end
18
20
 
19
21
  desc("Run unit tests")
@@ -21,6 +23,7 @@ Rake::TestTask.new(:unit_test) do |t|
21
23
  t.libs << "test"
22
24
  t.libs << "lib"
23
25
  t.test_files = FileList['test/unit/**/*_test.rb']
26
+ t.warning = !ENV.key?('CI')
24
27
  end
25
28
 
26
29
  desc("Run cli tests")
@@ -28,6 +31,7 @@ Rake::TestTask.new(:cli_test) do |t|
28
31
  t.libs << "test"
29
32
  t.libs << "lib"
30
33
  t.test_files = FileList['test/exe/**/*_test.rb']
34
+ t.warning = !ENV.key?('CI')
31
35
  end
32
36
 
33
37
  desc("Run all tests")
data/bin/test CHANGED
@@ -27,9 +27,10 @@ if [[ ${PARALLELISM:=0} -lt 1 ]]; then
27
27
  fi
28
28
  fi
29
29
 
30
- if [[ ${CI:="0"} == "1" ]]; then
31
- echo "--- :ruby: Bundle Install"
32
- bundle install --jobs 4
30
+ if [[ "${CI:-0}" != "0" ]]; then
31
+ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
32
+ echo "kind-kind" > "${SCRIPT_DIR}/../.local-context"
33
+ PARALLELISM=2
33
34
  fi
34
35
 
35
36
  print_header "Run CLI Tests"
data/dev.yml CHANGED
@@ -1,22 +1,22 @@
1
1
  ---
2
2
  name: krane
3
3
  up:
4
- - ruby: 2.6.6 # Matches gemspec
4
+ - ruby: '3.0.3' # Matches gemspec
5
5
  - bundler
6
- - homebrew:
7
- - minikube
8
- - hyperkit
9
6
  - custom:
10
- name: Install the minikube fork of driver-hyperkit
11
- met?: command -v docker-machine-driver-hyperkit
12
- meet: curl -LO https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-hyperkit && sudo install -o root -g wheel -m 4755 docker-machine-driver-hyperkit /usr/local/bin/ && rm ./docker-machine-driver-hyperkit
7
+ name: Install Kubernetes in Docker (KinD)
8
+ met?: bin/kind version 2>&1 | grep -q v0.11.1
9
+ meet: |
10
+ mkdir -p bin
11
+ curl -sLo bin/kind "https://github.com/kubernetes-sigs/kind/releases/download/v0.11.1/kind-darwin-amd64"
12
+ chmod +x bin/kind
13
13
  - custom:
14
- name: Minikube Cluster
15
- met?: test $(minikube status | grep Running | wc -l) -ge 2 && $(minikube status | grep -q 'Configured')
16
- meet: minikube start --kubernetes-version=v1.18.18 --vm-driver=hyperkit
17
- down: minikube stop
14
+ name: Create KinD Cluster
15
+ met?: bin/kind get clusters | grep -q krane
16
+ meet: bin/kind create cluster --name krane --image "kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047"
17
+ down: |
18
+ ((bin/kind get clusters | grep -q krane) && bin/kind delete cluster --name krane) || true
18
19
  commands:
19
- reset-minikube: minikube delete && rm -rf ~/.minikube
20
20
  test:
21
21
  run: bin/test
22
22
  tophat:
data/krane.gemspec CHANGED
@@ -27,21 +27,19 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.required_ruby_version = '>= 2.6.0'
29
29
  spec.add_dependency("activesupport", ">= 5.0")
30
- spec.add_dependency("cgi")
31
- spec.add_dependency("date")
32
- spec.add_dependency("kubeclient", "~> 4.3")
30
+ spec.add_dependency("kubeclient", "~> 4.9")
33
31
  spec.add_dependency("googleauth", "~> 0.8")
34
32
  spec.add_dependency("ejson", "~> 1.0")
35
33
  spec.add_dependency("colorize", "~> 0.8")
36
34
  spec.add_dependency("statsd-instrument", ['>= 2.8', "< 4"])
37
35
  spec.add_dependency("oj", "~> 3.0")
38
36
  spec.add_dependency("concurrent-ruby", "~> 1.1")
39
- spec.add_dependency("jsonpath", "~> 0.9.6")
37
+ spec.add_dependency("jsonpath", "~> 1.0")
40
38
  spec.add_dependency("thor", ">= 1.0", "< 2.0")
41
39
 
42
40
  # Basics
43
41
  spec.add_development_dependency("bundler")
44
- spec.add_development_dependency("rake", "~> 10.0")
42
+ spec.add_development_dependency("rake", "~> 13.0")
45
43
  spec.add_development_dependency("yard")
46
44
 
47
45
  # Test framework
data/lib/krane/common.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support'
4
+ require 'active_support/isolated_execution_state' if ActiveSupport::VERSION::MAJOR > 6
3
5
  require 'active_support/core_ext/object/blank'
4
6
  require 'active_support/core_ext/hash/reverse_merge'
5
7
  require 'active_support/core_ext/hash/slice'
@@ -254,6 +254,10 @@ module Krane
254
254
 
255
255
  StatsD.client.gauge('discover_resources.count', resources.size, tags: statsd_tags)
256
256
 
257
+ if resources.empty?
258
+ raise FatalDeploymentError, "No deployable resources were found!"
259
+ end
260
+
257
261
  resources.sort
258
262
  rescue InvalidTemplateError => e
259
263
  record_invalid_template(logger: @logger, err: e.message, filename: e.filename,
@@ -37,7 +37,10 @@ module Krane
37
37
 
38
38
  def group_version_kind
39
39
  group = @definition.dig("spec", "group")
40
- version = @definition.dig("spec", "version")
40
+ # Since 1.22: spec.version is removed in v1; use spec.versions instead.
41
+ # New spec here: https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#create-a-customresourcedefinition
42
+ # This is only used in testing, so we will simply take the first version we see:
43
+ version = @definition.dig("spec", "versions", 0, "name")
41
44
  "#{group}/#{version}/#{kind}"
42
45
  end
43
46
 
@@ -48,6 +48,7 @@ module Krane
48
48
  end
49
49
 
50
50
  def has_side_effects?
51
+ # Note: After K8s 1.22, this should ALWAYS be false.
51
52
  !%w(None NoneOnDryRun).include?(side_effects)
52
53
  end
53
54
 
@@ -584,7 +584,12 @@ module Krane
584
584
  # If the resource template uses generateName, validating with apply will fail
585
585
  def validate_with_local_dry_run(kubectl)
586
586
  verb = deploy_method == :apply ? "apply" : "create"
587
- command = [verb, "-f", file_path, "--dry-run", "--output=name"]
587
+ command = if kubectl.client_version >= Gem::Version.new('1.18')
588
+ [verb, "-f", file_path, "--dry-run=client", "--output=name"]
589
+ else
590
+ [verb, "-f", file_path, "--dry-run", "--output=name"]
591
+ end
592
+
588
593
  kubectl.run(*command, log_failure: false, output_is_sensitive: sensitive_template_content?,
589
594
  retry_whitelist: [:client_timeout, :empty, :context_deadline], attempts: 3, use_namespace: !global?)
590
595
  end
@@ -73,7 +73,7 @@ module Krane
73
73
  file_basename = File.basename(filename)
74
74
  @logger.info("Rendering #{file_basename}...")
75
75
  implicit = []
76
- YAML.parse_stream(rendered_content, "<rendered> #{filename}") { |d| implicit << d.implicit }
76
+ YAML.parse_stream(rendered_content, filename: "<rendered> #{filename}") { |d| implicit << d.implicit }
77
77
  if rendered_content.present?
78
78
  stream.puts "---\n" if implicit.first
79
79
  stream.puts rendered_content
data/lib/krane/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Krane
3
- VERSION = "2.3.4"
3
+ VERSION = "2.4.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: krane
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.4
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Verey
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-11-24 00:00:00.000000000 Z
13
+ date: 2022-01-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -26,48 +26,20 @@ dependencies:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '5.0'
29
- - !ruby/object:Gem::Dependency
30
- name: cgi
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: '0'
36
- type: :runtime
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: '0'
43
- - !ruby/object:Gem::Dependency
44
- name: date
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '0'
50
- type: :runtime
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: '0'
57
29
  - !ruby/object:Gem::Dependency
58
30
  name: kubeclient
59
31
  requirement: !ruby/object:Gem::Requirement
60
32
  requirements:
61
33
  - - "~>"
62
34
  - !ruby/object:Gem::Version
63
- version: '4.3'
35
+ version: '4.9'
64
36
  type: :runtime
65
37
  prerelease: false
66
38
  version_requirements: !ruby/object:Gem::Requirement
67
39
  requirements:
68
40
  - - "~>"
69
41
  - !ruby/object:Gem::Version
70
- version: '4.3'
42
+ version: '4.9'
71
43
  - !ruby/object:Gem::Dependency
72
44
  name: googleauth
73
45
  requirement: !ruby/object:Gem::Requirement
@@ -164,14 +136,14 @@ dependencies:
164
136
  requirements:
165
137
  - - "~>"
166
138
  - !ruby/object:Gem::Version
167
- version: 0.9.6
139
+ version: '1.0'
168
140
  type: :runtime
169
141
  prerelease: false
170
142
  version_requirements: !ruby/object:Gem::Requirement
171
143
  requirements:
172
144
  - - "~>"
173
145
  - !ruby/object:Gem::Version
174
- version: 0.9.6
146
+ version: '1.0'
175
147
  - !ruby/object:Gem::Dependency
176
148
  name: thor
177
149
  requirement: !ruby/object:Gem::Requirement
@@ -212,14 +184,14 @@ dependencies:
212
184
  requirements:
213
185
  - - "~>"
214
186
  - !ruby/object:Gem::Version
215
- version: '10.0'
187
+ version: '13.0'
216
188
  type: :development
217
189
  prerelease: false
218
190
  version_requirements: !ruby/object:Gem::Requirement
219
191
  requirements:
220
192
  - - "~>"
221
193
  - !ruby/object:Gem::Version
222
- version: '10.0'
194
+ version: '13.0'
223
195
  - !ruby/object:Gem::Dependency
224
196
  name: yard
225
197
  requirement: !ruby/object:Gem::Requirement
@@ -444,11 +416,10 @@ files:
444
416
  - ".github/ISSUE_TEMPLATE.md"
445
417
  - ".github/probots.yml"
446
418
  - ".github/pull_request_template.md"
419
+ - ".github/workflows/ci.yml"
447
420
  - ".gitignore"
448
421
  - ".rubocop-http---shopify-github-io-ruby-style-guide-rubocop-yml"
449
422
  - ".rubocop.yml"
450
- - ".shopify-build/VERSION"
451
- - ".shopify-build/krane.yml"
452
423
  - 1.0-Upgrade.md
453
424
  - CHANGELOG.md
454
425
  - CODE_OF_CONDUCT.md
@@ -1 +0,0 @@
1
- v1
@@ -1,48 +0,0 @@
1
- containers:
2
- default:
3
- docker: circleci/ruby:2.6.6
4
-
5
- steps:
6
- - label: Lint
7
- timeout: 5m
8
- run:
9
- - bundle: ~
10
- - bundle exec rubocop
11
- - label: 'Run Test Suite (:kubernetes: 1.21-latest :ruby: 3.0)'
12
- command: bin/ci
13
- agents:
14
- queue: k8s-ci
15
- env:
16
- LOGGING_LEVEL: "4"
17
- KUBERNETES_VERSION: v1.21-latest
18
- RUBY_VERSION: "3.0"
19
- - label: 'Run Test Suite (:kubernetes: 1.20-latest :ruby: 3.0)'
20
- command: bin/ci
21
- agents:
22
- queue: k8s-ci
23
- env:
24
- LOGGING_LEVEL: "4"
25
- KUBERNETES_VERSION: v1.20-latest
26
- RUBY_VERSION: "3.0"
27
- - label: 'Run Test Suite (:kubernetes: 1.19-latest :ruby: 2.7)'
28
- command: bin/ci
29
- agents:
30
- queue: k8s-ci
31
- env:
32
- LOGGING_LEVEL: "4"
33
- KUBERNETES_VERSION: v1.19-latest
34
- RUBY_VERSION: "2.7"
35
- - label: 'Run Test Suite (:kubernetes: 1.18-latest)'
36
- command: bin/ci
37
- agents:
38
- queue: k8s-ci
39
- env:
40
- LOGGING_LEVEL: "4"
41
- KUBERNETES_VERSION: v1.18-latest
42
- - label: 'Run Test Suite (:kubernetes: 1.17-latest)'
43
- command: bin/ci
44
- agents:
45
- queue: k8s-ci
46
- env:
47
- LOGGING_LEVEL: "4"
48
- KUBERNETES_VERSION: v1.17-latest