kubernetes-deploy 0.21.1 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.buildkite/pipeline.nightly.yml +8 -8
- data/.buildkite/pipeline.yml +8 -8
- data/.gitignore +1 -0
- data/CHANGELOG.md +27 -1
- data/README.md +22 -10
- data/bin/setup +2 -2
- data/kubernetes-deploy.gemspec +1 -1
- data/lib/kubernetes-deploy.rb +1 -2
- data/lib/kubernetes-deploy/container_logs.rb +1 -1
- data/lib/kubernetes-deploy/deploy_task.rb +2 -3
- data/lib/kubernetes-deploy/kubeclient_builder.rb +8 -0
- data/lib/kubernetes-deploy/kubernetes_resource/deployment.rb +0 -1
- data/lib/kubernetes-deploy/kubernetes_resource/pod.rb +0 -4
- data/lib/kubernetes-deploy/kubernetes_resource/role_binding.rb +22 -0
- data/lib/kubernetes-deploy/kubernetes_resource/stateful_set.rb +0 -1
- data/lib/kubernetes-deploy/restart_task.rb +3 -3
- data/lib/kubernetes-deploy/runner_task.rb +11 -1
- data/lib/kubernetes-deploy/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93fa4f3f00a9ff96a2dfc20fa26ead2ccf77d5e2
|
4
|
+
data.tar.gz: 6b1e6a305c64c94ffb1cb38b5f7d722ba2e11fd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88e0586648309f18d49b7d7e27650edd273bc0fdef8ae9bb0a0aa639ed6e4016fb0d7c6d2a1c25caede0774bb5fdc30b79d100e0ade49fcd6dd1a3823d20dc3a
|
7
|
+
data.tar.gz: a2ae7f6b727838b2c090c4208d0d321dee080902f8a50057c62f53691888294121211b863225945d5178ceea24876299e49ebdee1bc70f911e66eafd129e28fe
|
@@ -4,6 +4,14 @@ shared: &shared
|
|
4
4
|
- exit_status: "*"
|
5
5
|
limit: 1
|
6
6
|
steps:
|
7
|
+
- name: 'Run Test Suite (:kubernetes: 1.12-latest)'
|
8
|
+
<<: *shared
|
9
|
+
command: bin/ci
|
10
|
+
agents:
|
11
|
+
queue: k8s-ci
|
12
|
+
env:
|
13
|
+
LOGGING_LEVEL: 4
|
14
|
+
KUBERNETES_VERSION: v1.12-latest
|
7
15
|
- name: 'Run Test Suite (:kubernetes: 1.11-latest)'
|
8
16
|
<<: *shared
|
9
17
|
command: bin/ci
|
@@ -28,11 +36,3 @@ steps:
|
|
28
36
|
env:
|
29
37
|
LOGGING_LEVEL: 4
|
30
38
|
KUBERNETES_VERSION: v1.9-latest
|
31
|
-
- name: 'Run Test Suite (:kubernetes: 1.8-latest)'
|
32
|
-
<<: *shared
|
33
|
-
command: bin/ci
|
34
|
-
agents:
|
35
|
-
queue: minikube-ci
|
36
|
-
env:
|
37
|
-
LOGGING_LEVEL: 4
|
38
|
-
KUBERNETES_VERSION: v1.8-latest
|
data/.buildkite/pipeline.yml
CHANGED
@@ -4,6 +4,14 @@ shared: &shared
|
|
4
4
|
- exit_status: "*"
|
5
5
|
limit: 1
|
6
6
|
steps:
|
7
|
+
- name: 'Run Test Suite (:kubernetes: 1.12-latest)'
|
8
|
+
<<: *shared
|
9
|
+
command: bin/ci
|
10
|
+
agents:
|
11
|
+
queue: k8s-ci
|
12
|
+
env:
|
13
|
+
LOGGING_LEVEL: 4
|
14
|
+
KUBERNETES_VERSION: v1.12-latest
|
7
15
|
- name: 'Run Test Suite (:kubernetes: 1.11-latest)'
|
8
16
|
<<: *shared
|
9
17
|
command: bin/ci
|
@@ -28,11 +36,3 @@ steps:
|
|
28
36
|
env:
|
29
37
|
LOGGING_LEVEL: 4
|
30
38
|
KUBERNETES_VERSION: v1.9-latest
|
31
|
-
- name: 'Run Test Suite (:kubernetes: 1.8-latest)'
|
32
|
-
<<: *shared
|
33
|
-
command: bin/ci
|
34
|
-
agents:
|
35
|
-
queue: minikube-ci
|
36
|
-
env:
|
37
|
-
LOGGING_LEVEL: 4
|
38
|
-
KUBERNETES_VERSION: v1.8-latest
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
## 0.22.0
|
2
|
+
|
3
|
+
*Features*
|
4
|
+
- **[Breaking change]** `kubernetes-restart` now produces StatsD `distribution` instead of `metric`.
|
5
|
+
Dashboards that used these metrics will need to be updated. ([#374](https://github.com/Shopify/kubernetes-deploy/pull/374))
|
6
|
+
- `kubernetes-run` now produces StatsD `distribution` to aid in tracking usage ([#374](https://github.com/Shopify/kubernetes-deploy/pull/374))
|
7
|
+
|
8
|
+
*Enhancements*
|
9
|
+
- Predeploy RoleBinding before unmanaged pods ([#354](https://github.com/Shopify/kubernetes-deploy/pull/354))
|
10
|
+
|
11
|
+
*Bug Fixes*
|
12
|
+
- Fixed bug in `kubernetes-restart` that caused "Pod spec does not contain a template
|
13
|
+
container called 'task-runner'" error message to not be printed
|
14
|
+
([#371](https://github.com/Shopify/kubernetes-deploy/pull/371))
|
15
|
+
|
16
|
+
*Other*
|
17
|
+
- Kubernetes 1.8 is no longer officially supported as of this version
|
18
|
+
|
19
|
+
## 0.21.1
|
20
|
+
|
21
|
+
*Enhancements*
|
22
|
+
- Improved failure detection for job resources. ([#355](https://github.com/Shopify/kubernetes-deploy/pull/355))
|
23
|
+
- Unmanaged pods are now immediately identified as failed if they are evicted, preempted or deleted out of band. This is especially important to `kubernetes-run`. ([#353](https://github.com/Shopify/kubernetes-deploy/pull/353))
|
24
|
+
|
25
|
+
*Other*
|
26
|
+
- Relaxed our `googleauth` dependency. ([#333](https://github.com/Shopify/kubernetes-deploy/pull/333))
|
27
|
+
|
1
28
|
## 0.21.0
|
2
29
|
|
3
30
|
*Features*
|
@@ -13,7 +40,6 @@
|
|
13
40
|
- All resources marked as prunable will now be added to the prune whitelist ([#326](https://github.com/Shopify/kubernetes-deploy/pull/326))
|
14
41
|
- Improve deploy status detection by ensuring we examine the correct generation ([#325](https://github.com/Shopify/kubernetes-deploy/pull/325))
|
15
42
|
|
16
|
-
*Bug Fixes*
|
17
43
|
|
18
44
|
## 0.20.5
|
19
45
|
*Enhancements*
|
data/README.md
CHANGED
@@ -69,21 +69,26 @@ This repo also includes related tools for [running tasks](#kubernetes-run) and [
|
|
69
69
|
## Prerequisites
|
70
70
|
|
71
71
|
* Ruby 2.3+
|
72
|
-
* Your cluster must be running Kubernetes v1.
|
72
|
+
* Your cluster must be running Kubernetes v1.9.0 or higher<sup>1</sup>
|
73
73
|
* Each app must have a deploy directory containing its Kubernetes templates (see [Templates](#using-templates-and-variables))
|
74
74
|
* You must remove the` kubectl.kubernetes.io/last-applied-configuration` annotation from any resources in the namespace that are not included in your deploy directory. This annotation is added automatically when you create resources with `kubectl apply`. `kubernetes-deploy` will prune any resources that have this annotation and are not in the deploy directory.<sup>2</sup>
|
75
75
|
* Each app managed by `kubernetes-deploy` must have its own exclusive Kubernetes namespace.
|
76
76
|
|
77
|
-
<sup>1</sup> We run integration tests against these Kubernetes versions.
|
78
|
-
|
79
|
-
v1.5 was officially supported in gem versions < 0.12.
|
77
|
+
<sup>1</sup> We run integration tests against these Kubernetes versions. You can find our
|
78
|
+
offical compatibility chart below.
|
80
79
|
|
81
80
|
<sup>2</sup> This requirement can be bypassed with the `--no-prune` option, but it is not recommended.
|
82
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 |
|
83
88
|
|
84
89
|
## Installation
|
85
90
|
|
86
|
-
1. [Install kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-binary-via-curl) (requires v1.
|
91
|
+
1. [Install kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-binary-via-curl) (requires v1.9.0 or higher) and make sure it is available in your $PATH
|
87
92
|
2. Set up your [kubeconfig file](https://kubernetes.io/docs/tasks/access-application-cluster/authenticate-across-clusters-kubeconfig/) for access to your cluster(s).
|
88
93
|
3. `gem install kubernetes-deploy`
|
89
94
|
|
@@ -374,7 +379,7 @@ Based on this specification `kubernetes-run` will create a new pod with the entr
|
|
374
379
|
|
375
380
|
If you work for Shopify, just run `dev up`, but otherwise:
|
376
381
|
|
377
|
-
1. [Install kubectl version 1.
|
382
|
+
1. [Install kubectl version 1.9.0 or higher](https://kubernetes.io/docs/user-guide/prereqs/) and make sure it is in your path
|
378
383
|
2. [Install minikube](https://kubernetes.io/docs/getting-started-guides/minikube/#installation) (required to run the test suite)
|
379
384
|
3. Check out the repo
|
380
385
|
4. Run `bin/setup` to install dependencies
|
@@ -385,16 +390,23 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
385
390
|
|
386
391
|
## Running the test suite locally
|
387
392
|
|
388
|
-
|
389
|
-
2. Make sure you have a context named "minikube" in your kubeconfig. Minikube adds this context for you when you run `minikube start`; please do not rename it. You can check for it using `kubectl config get-contexts`.
|
390
|
-
3. Run `bundle exec rake test`
|
393
|
+
Using minikube:
|
391
394
|
|
395
|
+
1. Start [minikube](https://kubernetes.io/docs/getting-started-guides/minikube/#installation) (`minikube start [options]`).
|
396
|
+
2. Make sure you have a context named "minikube" in your kubeconfig. Minikube adds this context for you when you run `minikube start`. You can check for it using `kubectl config get-contexts`.
|
397
|
+
3. Run `bundle exec rake test` (or `dev test` if you work for Shopify).
|
392
398
|
|
399
|
+
Using another local cluster:
|
393
400
|
|
394
|
-
|
401
|
+
1. Start your cluster.
|
402
|
+
2. Put the name of the context you want to use in a file named `.local-context` in the root of this project. For example: `echo "dind" > .local-context`.
|
403
|
+
3. Run `bundle exec rake test` (or `dev test` if you work for Shopify).
|
395
404
|
|
396
405
|
To make StatsD log what it would have emitted, run a test with `STATSD_DEV=1`.
|
397
406
|
|
407
|
+
To see the full-color output of a specific integration test, you can use `PRINT_LOGS=1`. For example: `PRINT_LOGS=1 bundle exec ruby -I test test/integration/kubernetes_deploy_test.rb -n/test_name/`.
|
408
|
+
|
409
|
+
|
398
410
|
|
399
411
|
|
400
412
|
![test-output](screenshots/test-output.png)
|
data/bin/setup
CHANGED
@@ -9,8 +9,8 @@ if [ ! -x "$(which minikube)" ]; then
|
|
9
9
|
fi
|
10
10
|
|
11
11
|
if [ ! -x "$(which kubectl)" ]; then
|
12
|
-
echo -e "\n\033[0;33mPlease install kubectl version 1.
|
12
|
+
echo -e "\n\033[0;33mPlease install kubectl version 1.9.0 or higher:\nhttps://kubernetes.io/docs/user-guide/prereqs/\033[0m"
|
13
13
|
else
|
14
14
|
KUBECTL_VERSION=$(kubectl version --short --client | grep -oe "v[[:digit:]\.]\+")
|
15
|
-
echo -e "\n\033[0;32mKubectl version $KUBECTL_VERSION is already installed. This gem requires version v1.
|
15
|
+
echo -e "\n\033[0;32mKubectl version $KUBECTL_VERSION is already installed. This gem requires version v1.9.0 or greater.\033[0m"
|
16
16
|
fi
|
data/kubernetes-deploy.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency "googleauth", "~> 0.6.6" # https://github.com/google/google-auth-library-ruby/issues/153
|
29
29
|
spec.add_dependency "ejson", "~> 1.0"
|
30
30
|
spec.add_dependency "colorize", "~> 0.8"
|
31
|
-
spec.add_dependency "statsd-instrument", "~> 2.
|
31
|
+
spec.add_dependency "statsd-instrument", "~> 2.3"
|
32
32
|
|
33
33
|
spec.add_development_dependency "bundler"
|
34
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/kubernetes-deploy.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# rubocop:disable Naming/FileName
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'active_support/core_ext/object/blank'
|
@@ -22,6 +21,6 @@ require 'kubernetes-deploy/duration_parser'
|
|
22
21
|
require 'kubernetes-deploy/sync_mediator'
|
23
22
|
|
24
23
|
module KubernetesDeploy
|
25
|
-
MIN_KUBE_VERSION = '1.
|
24
|
+
MIN_KUBE_VERSION = '1.9.0'
|
26
25
|
KubernetesDeploy::StatsD.build
|
27
26
|
end
|
@@ -73,7 +73,7 @@ module KubernetesDeploy
|
|
73
73
|
timestamp, message = log_line.split(" ", 2)
|
74
74
|
[Time.parse(timestamp), message]
|
75
75
|
rescue ArgumentError
|
76
|
-
#
|
76
|
+
# Don't fail on unparsable timestamp
|
77
77
|
[nil, log_line]
|
78
78
|
end
|
79
79
|
|
@@ -52,6 +52,7 @@ module KubernetesDeploy
|
|
52
52
|
ConfigMap
|
53
53
|
PersistentVolumeClaim
|
54
54
|
ServiceAccount
|
55
|
+
RoleBinding
|
55
56
|
Pod
|
56
57
|
)
|
57
58
|
|
@@ -82,10 +83,8 @@ module KubernetesDeploy
|
|
82
83
|
apps/v1beta1/StatefulSet
|
83
84
|
autoscaling/v1/HorizontalPodAutoscaler
|
84
85
|
policy/v1beta1/PodDisruptionBudget
|
86
|
+
batch/v1beta1/CronJob
|
85
87
|
)
|
86
|
-
if server_version >= Gem::Version.new('1.8.0')
|
87
|
-
wl << "batch/v1beta1/CronJob"
|
88
|
-
end
|
89
88
|
wl + cluster_resource_discoverer.crds(@sync_mediator).select(&:prunable?).map(&:group_version_kind)
|
90
89
|
end
|
91
90
|
|
@@ -76,6 +76,14 @@ module KubernetesDeploy
|
|
76
76
|
)
|
77
77
|
end
|
78
78
|
|
79
|
+
def build_rbac_v1_kubeclient(context)
|
80
|
+
_build_kubeclient(
|
81
|
+
api_version: "v1",
|
82
|
+
context: context,
|
83
|
+
endpoint_path: "/apis/rbac.authorization.k8s.io"
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
79
87
|
def _build_kubeclient(api_version:, context:, endpoint_path: nil)
|
80
88
|
# Find a context defined in kube conf files that matches the input context by name
|
81
89
|
friendly_configs = config_files.map { |f| GoogleFriendlyConfig.read(f) }
|
@@ -210,10 +210,6 @@ module KubernetesDeploy
|
|
210
210
|
limbo_message.match(/(?:not found)|(?:back-off)/i)
|
211
211
|
"Failed to pull image #{@image}. "\
|
212
212
|
"Did you wait for it to be built and pushed to the registry before deploying?"
|
213
|
-
elsif limbo_message == "Generate Container Config Failed"
|
214
|
-
# reason/message are backwards in <1.8.0 (next condition used by 1.8.0+)
|
215
|
-
# Fixed by https://github.com/kubernetes/kubernetes/commit/df41787b1a3f51b73fb6db8a2203f0a7c7c92931
|
216
|
-
"Failed to generate container configuration: #{limbo_reason}"
|
217
213
|
elsif limbo_reason == "CreateContainerConfigError"
|
218
214
|
"Failed to generate container configuration: #{limbo_message}"
|
219
215
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module KubernetesDeploy
|
3
|
+
class RoleBinding < KubernetesResource
|
4
|
+
TIMEOUT = 30.seconds
|
5
|
+
|
6
|
+
def status
|
7
|
+
exists? ? "Created" : "Unknown"
|
8
|
+
end
|
9
|
+
|
10
|
+
def deploy_succeeded?
|
11
|
+
exists?
|
12
|
+
end
|
13
|
+
|
14
|
+
def deploy_failed?
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
def timeout_message
|
19
|
+
UNUSUAL_FAILURE_MESSAGE
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -58,14 +58,14 @@ module KubernetesDeploy
|
|
58
58
|
raise DeploymentTimeoutError
|
59
59
|
end
|
60
60
|
raise FatalDeploymentError unless success
|
61
|
-
::StatsD.
|
61
|
+
::StatsD.distribution('restart.duration', StatsD.duration(start), tags: tags('success', deployments))
|
62
62
|
@logger.print_summary(:success)
|
63
63
|
rescue DeploymentTimeoutError
|
64
|
-
::StatsD.
|
64
|
+
::StatsD.distribution('restart.duration', StatsD.duration(start), tags: tags('timeout', deployments))
|
65
65
|
@logger.print_summary(:timed_out)
|
66
66
|
raise
|
67
67
|
rescue FatalDeploymentError => error
|
68
|
-
::StatsD.
|
68
|
+
::StatsD.distribution('restart.duration', StatsD.duration(start), tags: tags('failure', deployments))
|
69
69
|
@logger.summary.add_action(error.message) if error.message != error.class.to_s
|
70
70
|
@logger.print_summary(:failure)
|
71
71
|
raise
|
@@ -28,6 +28,7 @@ module KubernetesDeploy
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def run!(task_template:, entrypoint:, args:, env_vars: [], verify_result: true)
|
31
|
+
start = Time.now.utc
|
31
32
|
@logger.reset
|
32
33
|
|
33
34
|
@logger.phase_heading("Initializing task")
|
@@ -44,11 +45,14 @@ module KubernetesDeploy
|
|
44
45
|
else
|
45
46
|
record_status_once(pod)
|
46
47
|
end
|
48
|
+
::StatsD.distribution('task_runner.duration', StatsD.duration(start), tags: statsd_tags('success'))
|
47
49
|
@logger.print_summary(:success)
|
48
50
|
rescue DeploymentTimeoutError
|
51
|
+
::StatsD.distribution('task_runner.duration', StatsD.duration(start), tags: statsd_tags('timeout'))
|
49
52
|
@logger.print_summary(:timed_out)
|
50
53
|
raise
|
51
54
|
rescue FatalDeploymentError
|
55
|
+
::StatsD.distribution('task_runner.duration', StatsD.duration(start), tags: statsd_tags('failure'))
|
52
56
|
@logger.print_summary(:failure)
|
53
57
|
raise
|
54
58
|
end
|
@@ -164,7 +168,9 @@ module KubernetesDeploy
|
|
164
168
|
def set_container_overrides!(pod_definition, entrypoint, args, env_vars)
|
165
169
|
container = pod_definition.spec.containers.find { |cont| cont.name == 'task-runner' }
|
166
170
|
if container.nil?
|
167
|
-
|
171
|
+
message = "Pod spec does not contain a template container called 'task-runner'"
|
172
|
+
@logger.summary.add_paragraph(message)
|
173
|
+
raise TaskConfigurationError, message
|
168
174
|
end
|
169
175
|
|
170
176
|
container.command = entrypoint
|
@@ -198,5 +204,9 @@ module KubernetesDeploy
|
|
198
204
|
def kubeclient
|
199
205
|
@kubeclient ||= build_v1_kubeclient(@context)
|
200
206
|
end
|
207
|
+
|
208
|
+
def statsd_tags(status)
|
209
|
+
%W(namespace:#{@namespace} context:#{@context} status:#{status})
|
210
|
+
end
|
201
211
|
end
|
202
212
|
end
|
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.
|
4
|
+
version: 0.22.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: 2018-
|
12
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -87,14 +87,14 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '2.
|
90
|
+
version: '2.3'
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '2.
|
97
|
+
version: '2.3'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: bundler
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- lib/kubernetes-deploy/kubernetes_resource/redis.rb
|
245
245
|
- lib/kubernetes-deploy/kubernetes_resource/replica_set.rb
|
246
246
|
- lib/kubernetes-deploy/kubernetes_resource/resource_quota.rb
|
247
|
+
- lib/kubernetes-deploy/kubernetes_resource/role_binding.rb
|
247
248
|
- lib/kubernetes-deploy/kubernetes_resource/service.rb
|
248
249
|
- lib/kubernetes-deploy/kubernetes_resource/service_account.rb
|
249
250
|
- lib/kubernetes-deploy/kubernetes_resource/stateful_set.rb
|