krane 2.3.7 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +7 -16
- data/CHANGELOG.md +32 -0
- data/README.md +11 -11
- data/dev.yml +2 -2
- data/lib/krane/deploy_task.rb +4 -0
- data/lib/krane/kubernetes_resource/custom_resource_definition.rb +4 -1
- data/lib/krane/kubernetes_resource/mutating_webhook_configuration.rb +1 -0
- data/lib/krane/kubernetes_resource/stateful_set.rb +5 -5
- data/lib/krane/resource_deployer.rb +1 -0
- data/lib/krane/restart_task.rb +24 -11
- data/lib/krane/template_sets.rb +2 -2
- data/lib/krane/version.rb +1 -1
- metadata +2 -3
- data/.buildkite/pipeline.nightly.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 422192af588ad4f4eb53c73fbf56ee6b8fc7dad69c5cec7dfe5a4f7b7f702b98
|
4
|
+
data.tar.gz: 413719980210e537b8c4d1958d7867224cb5743905f489680caac3261a4b60c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2ade15d59fe5fae20839c5aaa7002b3fbfc0e39373afbc7f66ddcde77f51f98451b2e5ac250147dd6cb4e0cc0cf23b234e764415a75764f53422f14f579ee74
|
7
|
+
data.tar.gz: addcd5f11bdb4a6fe4b0eaf82056fbd7aff79831a6813888e01192fe7edd094b05f83399af4c0b34370076153f7bb469bee8ca4f2c4761fd3e8ae4f022dff56f
|
data/.github/workflows/ci.yml
CHANGED
@@ -11,24 +11,23 @@ jobs:
|
|
11
11
|
fail-fast: false
|
12
12
|
matrix:
|
13
13
|
ruby:
|
14
|
-
|
15
|
-
- '3.0' # With k8s 1.
|
16
|
-
- '3.0' # With k8s 1.
|
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
|
17
18
|
- '3.0' # With k8s 1.20
|
18
19
|
- '2.7' # With k8s 1.19
|
19
|
-
- '2.6.6' # With k8s 1.18
|
20
|
-
- '2.6.6' # With k8s 1.17
|
21
20
|
include:
|
22
21
|
# Match kind images with chosen version https://github.com/kubernetes-sigs/kind/releases
|
23
|
-
- ruby: '3.0'
|
22
|
+
- ruby: '3.0.3'
|
24
23
|
kind_version: 'v0.11.1'
|
25
24
|
kubernetes_version: '1.23.0'
|
26
25
|
kind_image: 'kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac'
|
27
|
-
- ruby: '3.0'
|
26
|
+
- ruby: '3.0.2'
|
28
27
|
kind_version: 'v0.11.1'
|
29
28
|
kubernetes_version: '1.22.0'
|
30
29
|
kind_image: 'kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047'
|
31
|
-
- ruby: '3.0'
|
30
|
+
- ruby: '3.0.1'
|
32
31
|
kind_version: 'v0.11.1'
|
33
32
|
kubernetes_version: '1.21.1'
|
34
33
|
kind_image: 'kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6'
|
@@ -40,14 +39,6 @@ jobs:
|
|
40
39
|
kind_version: 'v0.11.1'
|
41
40
|
kubernetes_version: '1.19.11'
|
42
41
|
kind_image: 'kindest/node:v1.19.11@sha256:07db187ae84b4b7de440a73886f008cf903fcf5764ba8106a9fd5243d6f32729'
|
43
|
-
- ruby: '2.6.6'
|
44
|
-
kind_version: 'v0.11.1'
|
45
|
-
kubernetes_version: '1.18.19'
|
46
|
-
kind_image: '1.18: kindest/node:v1.18.19@sha256:7af1492e19b3192a79f606e43c35fb741e520d195f96399284515f077b3b622c'
|
47
|
-
- ruby: '2.6.6'
|
48
|
-
kind_version: 'v0.11.1'
|
49
|
-
kubernetes_version: '1.17.17'
|
50
|
-
kind_image: 'kindest/node:v1.17.17@sha256:66f1d0d91a88b8a001811e2f1054af60eef3b669a9a74f9b6db871f2f1eeed00'
|
51
42
|
|
52
43
|
steps:
|
53
44
|
- uses: actions/checkout@v2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,37 @@
|
|
1
1
|
## next
|
2
2
|
|
3
|
+
## 2.4.2
|
4
|
+
|
5
|
+
*Bug fixes*
|
6
|
+
|
7
|
+
- Resolve errors for StatefulSet restart with `updateStrategy: OnDelete` [#876](https://github.com/Shopify/krane/pull/876)
|
8
|
+
- Timeouts during the "predeploy priority resources" phase now raise `DeploymentTimeoutError` instead of `FatalDeploymentError` [#874](https://github.com/Shopify/krane/pull/874)
|
9
|
+
|
10
|
+
## 2.4.1
|
11
|
+
|
12
|
+
*Enhancements*
|
13
|
+
|
14
|
+
- Support restart task for stateful sets that use the `OnDelete` strategy [#840](https://github.com/Shopify/krane/pull/840)
|
15
|
+
- Make `krane render` produce output in a deterministic order [#871](https://github.com/Shopify/krane/pull/871)
|
16
|
+
|
17
|
+
*Other*
|
18
|
+
|
19
|
+
- Remove buildkite [#869](https://github.com/Shopify/krane/pull/869)
|
20
|
+
|
21
|
+
## 2.4.0
|
22
|
+
|
23
|
+
*Enhancements*
|
24
|
+
|
25
|
+
- Ensure deploy tasks fail without at least one non-empty resource [#865](https://github.com/Shopify/krane/issues/865)
|
26
|
+
|
27
|
+
*Other*
|
28
|
+
|
29
|
+
- 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+.
|
30
|
+
|
31
|
+
## 2.3.7
|
32
|
+
|
33
|
+
- isolated_execution_state active_support require for Rails 7+
|
34
|
+
|
3
35
|
## 2.3.6
|
4
36
|
|
5
37
|
- Update kubeclient for better Ruby 3.1 compatibility.
|
data/README.md
CHANGED
@@ -73,24 +73,24 @@ If you need the ability to render dynamic values in templates before deploying,
|
|
73
73
|
|
74
74
|
## Prerequisites
|
75
75
|
|
76
|
-
* Ruby 2.
|
77
|
-
* Your cluster must be running Kubernetes v1.
|
76
|
+
* Ruby 2.7+
|
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.
|
85
|
-
| 1.
|
86
|
-
| 1.
|
87
|
-
| 1.
|
88
|
-
| 1.
|
89
|
-
| 1.
|
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.
|
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/dev.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
name: krane
|
3
3
|
up:
|
4
|
-
- ruby:
|
4
|
+
- ruby: '3.0.3' # Matches gemspec
|
5
5
|
- bundler
|
6
6
|
- custom:
|
7
7
|
name: Install Kubernetes in Docker (KinD)
|
@@ -13,7 +13,7 @@ up:
|
|
13
13
|
- custom:
|
14
14
|
name: Create KinD Cluster
|
15
15
|
met?: bin/kind get clusters | grep -q krane
|
16
|
-
meet: bin/kind create cluster --name krane
|
16
|
+
meet: bin/kind create cluster --name krane --image "kindest/node:v1.22.0@sha256:b8bda84bb3a190e6e028b1760d277454a72267a5454b57db34437c34a588d047"
|
17
17
|
down: |
|
18
18
|
((bin/kind get clusters | grep -q krane) && bin/kind delete cluster --name krane) || true
|
19
19
|
commands:
|
data/lib/krane/deploy_task.rb
CHANGED
@@ -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
|
-
|
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
|
|
@@ -19,6 +19,9 @@ module Krane
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def deploy_succeeded?
|
22
|
+
success = observed_generation == current_generation &&
|
23
|
+
desired_replicas == status_data['readyReplicas'].to_i &&
|
24
|
+
status_data['currentRevision'] == status_data['updateRevision']
|
22
25
|
if update_strategy == ONDELETE
|
23
26
|
# Gem cannot monitor update since it doesn't occur until delete
|
24
27
|
unless @success_assumption_warning_shown
|
@@ -27,13 +30,10 @@ module Krane
|
|
27
30
|
"Consider switching to rollingUpdate.")
|
28
31
|
@success_assumption_warning_shown = true
|
29
32
|
end
|
30
|
-
true
|
31
33
|
else
|
32
|
-
|
33
|
-
status_data['currentRevision'] == status_data['updateRevision'] &&
|
34
|
-
desired_replicas == status_data['readyReplicas'].to_i &&
|
35
|
-
desired_replicas == status_data['currentReplicas'].to_i
|
34
|
+
success &= desired_replicas == status_data['currentReplicas'].to_i
|
36
35
|
end
|
36
|
+
success
|
37
37
|
end
|
38
38
|
|
39
39
|
def deploy_failed?
|
@@ -70,6 +70,7 @@ module Krane
|
|
70
70
|
r.sync_debug_info(kubectl)
|
71
71
|
end
|
72
72
|
failed_resources.each { |r| logger.summary.add_paragraph(r.debug_message) }
|
73
|
+
raise DeploymentTimeoutError if failed_resources.all?(&:deploy_timed_out?)
|
73
74
|
raise FatalDeploymentError, "Failed to deploy #{fail_count} priority #{'resource'.pluralize(fail_count)}"
|
74
75
|
end
|
75
76
|
logger.blank_line
|
data/lib/krane/restart_task.rb
CHANGED
@@ -69,10 +69,10 @@ module Krane
|
|
69
69
|
deployments, statefulsets, daemonsets = identify_target_workloads(deployments, statefulsets,
|
70
70
|
daemonsets, selector: selector)
|
71
71
|
|
72
|
-
@logger.phase_heading("Triggering restart
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
@logger.phase_heading("Triggering restart")
|
73
|
+
restart_deployments!(deployments)
|
74
|
+
restart_statefulsets!(statefulsets)
|
75
|
+
restart_daemonsets!(daemonsets)
|
76
76
|
|
77
77
|
if verify_result
|
78
78
|
@logger.phase_heading("Waiting for rollout")
|
@@ -210,7 +210,15 @@ module Krane
|
|
210
210
|
apps_v1_kubeclient.patch_daemon_set(record.metadata.name, build_patch_payload(record), @namespace)
|
211
211
|
end
|
212
212
|
|
213
|
-
def
|
213
|
+
def delete_statefulset_pods(record)
|
214
|
+
pods = kubeclient.get_pods(namespace: record.metadata.namespace)
|
215
|
+
pods.select! do |pod|
|
216
|
+
pod.metadata&.ownerReferences&.find { |ref| ref.uid == record.metadata.uid }
|
217
|
+
end
|
218
|
+
pods.each { |pod| kubeclient.delete_pod(pod.metadata.name, pod.metadata.namespace) }
|
219
|
+
end
|
220
|
+
|
221
|
+
def restart_deployments!(deployments)
|
214
222
|
deployments.each do |record|
|
215
223
|
begin
|
216
224
|
patch_deployment_with_restart(record)
|
@@ -221,18 +229,23 @@ module Krane
|
|
221
229
|
end
|
222
230
|
end
|
223
231
|
|
224
|
-
def
|
232
|
+
def restart_statefulsets!(statefulsets)
|
225
233
|
statefulsets.each do |record|
|
226
|
-
|
234
|
+
@logger.info("Triggered `StatefulSet/#{record.metadata.name}` restart")
|
235
|
+
if record.spec.updateStrategy&.type == "OnDelete"
|
236
|
+
@logger.info("`StatefulSet/#{record.metadata.name}` has updateStrategy: OnDelete," \
|
237
|
+
" Restarting by forcefully deleting child pods"
|
238
|
+
)
|
239
|
+
delete_statefulset_pods(record)
|
240
|
+
else
|
227
241
|
patch_statefulset_with_restart(record)
|
228
|
-
@logger.info("Triggered `StatefulSet/#{record.metadata.name}` restart")
|
229
|
-
rescue Kubeclient::HttpError => e
|
230
|
-
raise RestartAPIError.new(record.metadata.name, e.message)
|
231
242
|
end
|
243
|
+
rescue Kubeclient::HttpError => e
|
244
|
+
raise RestartAPIError.new(record.metadata.name, e.message)
|
232
245
|
end
|
233
246
|
end
|
234
247
|
|
235
|
-
def
|
248
|
+
def restart_daemonsets!(daemonsets)
|
236
249
|
daemonsets.each do |record|
|
237
250
|
begin
|
238
251
|
patch_daemonset_with_restart(record)
|
data/lib/krane/template_sets.rb
CHANGED
@@ -104,11 +104,11 @@ module Krane
|
|
104
104
|
dir_paths.each do |template_dir|
|
105
105
|
resource_templates[template_dir] = Dir.foreach(template_dir).select do |filename|
|
106
106
|
filename.end_with?(*VALID_TEMPLATES) || filename == EjsonSecretProvisioner::EJSON_SECRETS_FILE
|
107
|
-
end
|
107
|
+
end.sort
|
108
108
|
end
|
109
109
|
|
110
110
|
# Filename paths
|
111
|
-
file_paths.each do |filename|
|
111
|
+
file_paths.sort.each do |filename|
|
112
112
|
dir_name = File.dirname(filename)
|
113
113
|
resource_templates[dir_name] ||= []
|
114
114
|
resource_templates[dir_name] << File.basename(filename) unless resource_templates[dir_name].include?(filename)
|
data/lib/krane/version.rb
CHANGED
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.
|
4
|
+
version: 2.4.2
|
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: 2022-
|
13
|
+
date: 2022-03-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -411,7 +411,6 @@ executables:
|
|
411
411
|
extensions: []
|
412
412
|
extra_rdoc_files: []
|
413
413
|
files:
|
414
|
-
- ".buildkite/pipeline.nightly.yml"
|
415
414
|
- ".github/CODEOWNERS"
|
416
415
|
- ".github/ISSUE_TEMPLATE.md"
|
417
416
|
- ".github/probots.yml"
|
@@ -1,15 +0,0 @@
|
|
1
|
-
steps:
|
2
|
-
- name: 'Run Test Suite (:kubernetes: 1.16-latest)'
|
3
|
-
command: bin/ci
|
4
|
-
agents:
|
5
|
-
queue: k8s-ci
|
6
|
-
env:
|
7
|
-
LOGGING_LEVEL: 4
|
8
|
-
KUBERNETES_VERSION: v1.16-latest
|
9
|
-
- name: 'Run Test Suite (:kubernetes: 1.15-latest)'
|
10
|
-
command: bin/ci
|
11
|
-
agents:
|
12
|
-
queue: k8s-ci
|
13
|
-
env:
|
14
|
-
LOGGING_LEVEL: 4
|
15
|
-
KUBERNETES_VERSION: v1.15-latest
|