krane 1.0.0 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -0
- data/{ISSUE_TEMPLATE.md → .github/ISSUE_TEMPLATE.md} +0 -0
- data/{pull_request_template.md → .github/pull_request_template.md} +0 -0
- data/.gitignore +0 -3
- data/.rubocop-http---shopify-github-io-ruby-style-guide-rubocop-yml +1020 -0
- data/.rubocop.yml +0 -12
- data/.shopify-build/{kubernetes-deploy.yml → krane.yml} +16 -1
- data/1.0-Upgrade.md +4 -5
- data/CHANGELOG.md +55 -1
- data/CONTRIBUTING.md +5 -5
- data/Gemfile +0 -11
- data/README.md +22 -24
- data/bin/ci +1 -1
- data/bin/test +2 -2
- data/dev.yml +4 -4
- data/krane.gemspec +22 -5
- data/lib/krane/cli/deploy_command.rb +3 -4
- data/lib/krane/cli/global_deploy_command.rb +3 -3
- data/lib/krane/cli/render_command.rb +3 -3
- data/lib/krane/cluster_resource_discovery.rb +9 -6
- data/lib/krane/concurrency.rb +2 -2
- data/lib/krane/container_logs.rb +1 -1
- data/lib/krane/container_overrides.rb +33 -0
- data/lib/krane/deploy_task.rb +5 -5
- data/lib/krane/ejson_secret_provisioner.rb +7 -4
- data/lib/krane/global_deploy_task.rb +3 -2
- data/lib/krane/kubectl.rb +11 -1
- data/lib/krane/kubernetes_resource.rb +7 -6
- data/lib/krane/kubernetes_resource/custom_resource.rb +1 -1
- data/lib/krane/kubernetes_resource/custom_resource_definition.rb +1 -1
- data/lib/krane/kubernetes_resource/daemon_set.rb +1 -0
- data/lib/krane/kubernetes_resource/deployment.rb +3 -2
- data/lib/krane/kubernetes_resource/pod.rb +12 -8
- data/lib/krane/kubernetes_resource/replica_set.rb +2 -16
- data/lib/krane/kubernetes_resource/service.rb +3 -7
- data/lib/krane/kubernetes_resource/stateful_set.rb +1 -0
- data/lib/krane/render_task.rb +2 -2
- data/lib/krane/resource_cache.rb +6 -0
- data/lib/krane/resource_watcher.rb +2 -1
- data/lib/krane/restart_task.rb +2 -2
- data/lib/krane/runner_task.rb +16 -17
- data/lib/krane/statsd.rb +2 -2
- data/lib/krane/template_sets.rb +1 -1
- data/lib/krane/version.rb +1 -1
- metadata +168 -20
- data/lib/krane/kubernetes_resource/cloudsql.rb +0 -43
- data/shipit.yml +0 -4
data/.rubocop.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
containers:
|
2
2
|
default:
|
3
|
-
docker: circleci/ruby:2.
|
3
|
+
docker: circleci/ruby:2.5.7
|
4
4
|
|
5
5
|
steps:
|
6
6
|
- label: Lint
|
@@ -9,6 +9,21 @@ steps:
|
|
9
9
|
- bundle exec rubocop
|
10
10
|
dependencies:
|
11
11
|
- bundler
|
12
|
+
- label: 'Run Test Suite (:kubernetes: 1.17-latest :ruby: 2.7)'
|
13
|
+
command: bin/ci
|
14
|
+
agents:
|
15
|
+
queue: k8s-ci
|
16
|
+
env:
|
17
|
+
LOGGING_LEVEL: "4"
|
18
|
+
KUBERNETES_VERSION: v1.17-latest
|
19
|
+
RUBY_VERSION: "2.7"
|
20
|
+
- label: 'Run Test Suite (:kubernetes: 1.17-latest)'
|
21
|
+
command: bin/ci
|
22
|
+
agents:
|
23
|
+
queue: k8s-ci
|
24
|
+
env:
|
25
|
+
LOGGING_LEVEL: "4"
|
26
|
+
KUBERNETES_VERSION: v1.17-latest
|
12
27
|
- label: 'Run Test Suite (:kubernetes: 1.16-latest)'
|
13
28
|
command: bin/ci
|
14
29
|
agents:
|
data/1.0-Upgrade.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
* There are breaking changes in the public API (such as the renaming of the `KubernetesDeploy` namespace to `Krane`, and the change in default values for different arguments of the public interface).
|
8
8
|
* StatsD metrics will now be generated with the `krane` prefix.
|
9
9
|
* `krane deploy` now considers all namespaced resources eligible for pruning, including
|
10
|
-
custom resources. See [blacklist](https://github.com/Shopify/
|
10
|
+
custom resources. See [blacklist](https://github.com/Shopify/krane/blob/master/lib/krane/cluster_resource_discovery.rb#L20) for exceptions.
|
11
11
|
* `kubernetes-deploy` (now `krane deploy`) / `DeployTask` can no longer deploy global (non-namespaced) resources. A new command called `krane global-deploy` and a related class called `GlobalDeployTask` were added to replace that feature.
|
12
12
|
* `krane deploy` will not render erb templates. Use `krane render | krane deploy --stdin` to reproduce this functionality.
|
13
13
|
* If you attempt to install two gems that have conflicting executables, `gem install` will warn you but the most recently installed one will win.
|
@@ -119,15 +119,14 @@ Old flag | New flag | Comments
|
|
119
119
|
--skip-wait | --verify-result=true |
|
120
120
|
--allow-protected-ns | --protected-namespaces=default,kube-system,kube-public | Added the ability to specify which namespaces are protected
|
121
121
|
--no-prune | --prune=true |
|
122
|
-
--template-dir | -f, --
|
122
|
+
--template-dir | -f, --filenames | Makes all krane commands accept this argument, which is now required for the deploy task
|
123
123
|
--verbose-log-prefix | --verbose-log-prefix |
|
124
124
|
--max-watch-seconds=seconds | --global-timeout=300s | Changed flag name and default value to be a duration (expressed using strings like "300s" or "1h")
|
125
125
|
--selector | --selector |
|
126
126
|
-h, --help | -h, --help |
|
127
127
|
-v, --version | [none] | Replaced with `krane version`
|
128
128
|
$ENVIRONMENT | [none] | Dropped in favour of `-f`
|
129
|
-
$REVISION |
|
130
|
-
[none] | --render-erb | **Important:** the new CLI doesn't render ERB by default
|
129
|
+
$REVISION | [none] | The environment variable REVISION was dropped because deploy no longer renders.
|
131
130
|
[none] | --stdin | Allow template filenames given from stdin stream
|
132
131
|
|
133
132
|
#### krane restart
|
@@ -154,7 +153,7 @@ Old flag | New flag | Comments
|
|
154
153
|
Old flag | New flag | Comments
|
155
154
|
--- | --- | ---
|
156
155
|
--bindings=BINDINGS | --bindings=BINDINGS |
|
157
|
-
--template-dir | -f, --
|
156
|
+
--template-dir | -f, --filenames | Changed to be more aligned with `kubectl apply` and other krane tasks
|
158
157
|
$REVISION | --current-sha | The environment variable REVISION was dropped in favour of an explicit flag
|
159
158
|
[none] | --stdin | Allow template filenames given from stdin stream
|
160
159
|
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,63 @@
|
|
1
1
|
## next
|
2
2
|
|
3
|
+
## 1.1.4
|
4
|
+
|
5
|
+
*Bug Fixes*
|
6
|
+
- Properly look up constant on Krane namespace. [#720](https://github.com/Shopify/krane/pull/720)
|
7
|
+
|
8
|
+
*Enhancements*
|
9
|
+
- Allow to configure `image_tag` when using task runner. [#719](https://github.com/Shopify/krane/pull/719)
|
10
|
+
|
11
|
+
## 1.1.3
|
12
|
+
|
13
|
+
*Bug Fixes*
|
14
|
+
- Retry dry-run validation when no error is returned. [#705](https://github.com/Shopify/krane/pull/705)
|
15
|
+
- Stop deploys if ClusterResourceDiscovery's kubectl calls fail. [#701](https://github.com/Shopify/krane/pull/701)
|
16
|
+
|
17
|
+
*Other*
|
18
|
+
- Dropped support for Ruby 2.4 since it will be EoL shortly. [#693](https://github.com/Shopify/krane/pull/693).
|
19
|
+
- Ruby 2.7 support: fix deprecation warnings, add testing. [#710](https://github.com/Shopify/krane/pull/705)
|
20
|
+
|
21
|
+
## 1.1.2
|
22
|
+
*Enhancements*
|
23
|
+
- Don't treat `containerCannotRun` termination reason as a fatal deploy failure, since it is usually transient. [#694](https://github.com/Shopify/krane/pull/694)
|
24
|
+
|
25
|
+
*Bug Fixes*
|
26
|
+
- Help ruby correctly identify kubectl output encoding. [#646](https://github.com/Shopify/krane/pull/646)
|
27
|
+
- Add an override for Job kind for version `batch/v2alpha1` [#696](https://github.com/Shopify/krane/pull/696)
|
28
|
+
|
29
|
+
*Other*
|
30
|
+
- `--stdin` flag is deprecated. To read from STDIN, use `-f -` (can be combined with other files/directories) [#684](https://github.com/Shopify/krane/pull/684).
|
31
|
+
- Reduces the number of container logs printed for failures from 250 to 25 to reduce noise. [#676](https://github.com/Shopify/krane/pull/676)
|
32
|
+
- Remove hardcoded cloudsql class. [#680](https://github.com/Shopify/krane/pull/680)
|
33
|
+
|
34
|
+
## 1.1.1
|
35
|
+
|
36
|
+
*Enhancements*
|
37
|
+
- Detect and handle case when webhook prevents server-dry-run. [#663](https://github.com/Shopify/krane/pull/663)
|
38
|
+
- Deploy CustomResources after most other resources in the priority deploy phase. [#672](https://github.com/Shopify/krane/pull/672)
|
39
|
+
|
40
|
+
*Bug Fixes*
|
41
|
+
- Prints the correct argument name in error message. [#660](https://github.com/Shopify/krane/pull/660)
|
42
|
+
- Fix mistakes in README.md [#664](https://github.com/Shopify/krane/pull/664), [#659](https://github.com/Shopify/krane/pull/659), & [#668](https://github.com/Shopify/krane/pull/668)
|
43
|
+
- Restores the default value of the `--verbose-log-prefix` flag on `krane deploy` to false. [#673](https://github.com/Shopify/krane/pull/673)
|
44
|
+
|
45
|
+
*Other*
|
46
|
+
|
47
|
+
- Relax dependency requirements. [#657](https://github.com/Shopify/krane/pull/657)
|
48
|
+
|
49
|
+
## 1.1.0
|
50
|
+
|
51
|
+
*Bug Fixes*
|
52
|
+
- Fix a bug causing secret generation from ejson to fail when decryption succeeded but a warning was also emitted. [#647](https://github.com/Shopify/krane/pull/647)
|
53
|
+
|
54
|
+
*Enhancements*
|
55
|
+
- Warm the ResourceCache before running resource.sync to improve sync performance. ([#603](https://github.com/Shopify/kubernetes-deploy/pull/603))
|
56
|
+
|
3
57
|
# 1.0.0
|
4
58
|
|
5
59
|
We've renamed the gem and cli to Krane.
|
6
|
-
See our [migration guide](https://github.com/Shopify/
|
60
|
+
See our [migration guide](https://github.com/Shopify/krane/blob/master/1.0-Upgrade.md) to help navigate the breaking changes.
|
7
61
|
|
8
62
|
## 1.0.0.pre.1
|
9
63
|
|
data/CONTRIBUTING.md
CHANGED
@@ -22,7 +22,7 @@ The following is a set of guidelines for contributing to krane. Please take a mo
|
|
22
22
|
* [CI (External contributors)](#ci-external-contributors)
|
23
23
|
## Code of Conduct
|
24
24
|
|
25
|
-
This project and everyone participating in it are governed by the [Code of Conduct](https://github.com/Shopify/
|
25
|
+
This project and everyone participating in it are governed by the [Code of Conduct](https://github.com/Shopify/krane/blob/master/CODE_OF_CONDUCT.md).
|
26
26
|
By participating, you are expected to uphold this code. Please report unacceptable
|
27
27
|
behavior to [krane@shopify.com](mailto:krane@shopify.com).
|
28
28
|
|
@@ -97,9 +97,9 @@ This gem uses subclasses of `KubernetesResource` to implement custom success/fai
|
|
97
97
|
* `deploy_failed?`
|
98
98
|
3. Adjust the `TIMEOUT` constant to an appropriate value for this type.
|
99
99
|
4. Add the new class to list of resources in
|
100
|
-
[`deploy_task.rb`](https://github.com/Shopify/
|
101
|
-
5. Add the new resource to the [prune whitelist](https://github.com/Shopify/
|
102
|
-
6. Add a basic example of the type to the hello-cloud [fixture set](https://github.com/Shopify/
|
100
|
+
[`deploy_task.rb`](https://github.com/Shopify/krane/blob/master/lib/krane/deploy_task.rb#L8)
|
101
|
+
5. Add the new resource to the [prune whitelist](https://github.com/Shopify/krane/blob/master/lib/krane/deploy_task.rb#L81)
|
102
|
+
6. Add a basic example of the type to the hello-cloud [fixture set](https://github.com/Shopify/krane/tree/master/test/fixtures/hello-cloud) and appropriate assertions to `#assert_all_up` in [`hello_cloud.rb`](https://github.com/Shopify/krane/blob/master/test/helpers/fixture_sets/hello_cloud.rb). This will get you coverage in several existing tests, such as `test_full_hello_cloud_set_deploy_succeeds`.
|
103
103
|
7. Add tests for any edge cases you foresee.
|
104
104
|
|
105
105
|
### Contributor License Agreement
|
@@ -159,6 +159,6 @@ Please make sure you run the tests locally before submitting your PR (see [Runni
|
|
159
159
|
|
160
160
|
#### Employees: Triggering CI for a contributed PR
|
161
161
|
|
162
|
-
Go to the [krane pipeline](https://buildkite.com/shopify/
|
162
|
+
Go to the [krane pipeline](https://buildkite.com/shopify/krane) and click "New Build". Use branch `external_contrib_ci` and the specific sha of the commit you want to build. Add `BUILDKITE_REFSPEC="refs/pull/${PR_NUM}/head"` in the Environment Variables section. Since CI is only visible to Shopify employees, you will need to provide any failing tests and output to the the contributor.
|
163
163
|
|
164
164
|
<img width="350" alt="build external contrib PR" src="https://screenshot.click/2017-11-07--163728_7ovek-wrpwq.png">
|
data/Gemfile
CHANGED
@@ -3,14 +3,3 @@ source 'https://rubygems.org'
|
|
3
3
|
|
4
4
|
# Specify your gem's dependencies in krane.gemspec
|
5
5
|
gemspec
|
6
|
-
|
7
|
-
gem 'pry'
|
8
|
-
gem 'pry-byebug'
|
9
|
-
gem 'rubocop'
|
10
|
-
gem 'timecop'
|
11
|
-
gem 'byebug'
|
12
|
-
gem 'codecov', require: false
|
13
|
-
gem 'ruby-prof', require: false
|
14
|
-
gem 'ruby-prof-flamegraph', require: false
|
15
|
-
gem 'minitest-reporters'
|
16
|
-
gem 'yard', require: false
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# krane [![Build status](https://badge.buildkite.com/
|
1
|
+
# krane [![Build status](https://badge.buildkite.com/35c56e797c3bbd6ba50053aefdded0715898cd8e8c86f7e462.svg?branch=master)](https://buildkite.com/shopify/krane) [![codecov](https://codecov.io/gh/Shopify/kubernetes-deploy/branch/master/graph/badge.svg)](https://codecov.io/gh/Shopify/kubernetes-deploy)
|
2
2
|
|
3
|
-
> This project used to be called `kubernetes-deploy`. Check out our [migration guide](https://github.com/Shopify/
|
3
|
+
> This project used to be called `kubernetes-deploy`. Check out our [migration guide](https://github.com/Shopify/krane/blob/master/1.0-Upgrade.md) for more information including details about breaking changes.
|
4
4
|
|
5
5
|
|
6
6
|
`krane` is a command line tool that helps you ship changes to a Kubernetes namespace and understand the result. At Shopify, we use it within our much-beloved, open-source [Shipit](https://github.com/Shopify/shipit-engine#kubernetes) deployment app.
|
@@ -40,7 +40,7 @@ If you need the ability to render dynamic values in templates before deploying,
|
|
40
40
|
* [Prerequisites](#prerequisites)
|
41
41
|
* [Installation](#installation)
|
42
42
|
* [Usage](#usage)
|
43
|
-
* [Using templates
|
43
|
+
* [Using templates](#using-templates)
|
44
44
|
* [Customizing behaviour with annotations](#customizing-behaviour-with-annotations)
|
45
45
|
* [Running tasks at the beginning of a deploy](#running-tasks-at-the-beginning-of-a-deploy)
|
46
46
|
* [Deploying Kubernetes secrets (from EJSON)](#deploying-kubernetes-secrets-from-ejson)
|
@@ -54,11 +54,11 @@ If you need the ability to render dynamic values in templates before deploying,
|
|
54
54
|
* [Usage](#usage-2)
|
55
55
|
|
56
56
|
**KRANE RUN**
|
57
|
-
* [Prerequisites](#prerequisites-
|
57
|
+
* [Prerequisites](#prerequisites-1)
|
58
58
|
* [Usage](#usage-3)
|
59
59
|
|
60
60
|
**KRANE RENDER**
|
61
|
-
* [Prerequisites](#prerequisites-
|
61
|
+
* [Prerequisites](#prerequisites-2)
|
62
62
|
* [Usage](#usage-4)
|
63
63
|
|
64
64
|
**CONTRIBUTING**
|
@@ -73,7 +73,7 @@ If you need the ability to render dynamic values in templates before deploying,
|
|
73
73
|
|
74
74
|
## Prerequisites
|
75
75
|
|
76
|
-
* Ruby 2.
|
76
|
+
* Ruby 2.5+
|
77
77
|
* Your cluster must be running Kubernetes v1.11.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
|
@@ -103,7 +103,7 @@ official compatibility chart below.
|
|
103
103
|
|
104
104
|
*Environment variables:*
|
105
105
|
|
106
|
-
- `$KUBECONFIG`: points to one or multiple valid kubeconfig files that include the context you want to deploy to. File names are separated by colon for Linux and Mac, and semi-colon for Windows. If
|
106
|
+
- `$KUBECONFIG`: points to one or multiple valid kubeconfig files that include the context you want to deploy to. File names are separated by colon for Linux and Mac, and semi-colon for Windows. If omitted, Krane will use the Kubernetes default of `~/.kube/config`.
|
107
107
|
- `$GOOGLE_APPLICATION_CREDENTIALS`: points to the credentials for an authenticated service account (required if your kubeconfig `user`'s auth provider is GCP)
|
108
108
|
|
109
109
|
|
@@ -112,8 +112,7 @@ official compatibility chart below.
|
|
112
112
|
Refer to `krane help` for the authoritative set of options.
|
113
113
|
|
114
114
|
|
115
|
-
- `--filenames / -f [PATHS]`: Accepts a list of directories and/or filenames to specify the set of directories/files that will be deployed.
|
116
|
-
- `--stdin`: Read from STDIN. Can be combined with `-f` Example: `cat templates_from_stdin/*.yml | krane deploy ns ctx -f path/to/dir path/to/file.yml --stdin`
|
115
|
+
- `--filenames / -f [PATHS]`: Accepts a list of directories and/or filenames to specify the set of directories/files that will be deployed, use `-` to specify reading from STDIN.
|
117
116
|
- `--no-prune`: Skips pruning of resources that are no longer in your Kubernetes template set. Not recommended, as it allows your namespace to accumulate cruft that is not reflected in your deploy directory.
|
118
117
|
- `--global-timeout=duration`: Raise a timeout error if it takes longer than _duration_ for any
|
119
118
|
resource to deploy.
|
@@ -138,7 +137,7 @@ If you need to share a namespace with resources which are managed by other tools
|
|
138
137
|
All templates must be YAML formatted.
|
139
138
|
We recommended storing each app's templates in a single directory, `{app root}/config/deploy/{env}`. However, you may use multiple directories.
|
140
139
|
|
141
|
-
If you want dynamic templates, you may render ERB with `krane render` and then pipe that result to `krane deploy
|
140
|
+
If you want dynamic templates, you may render ERB with `krane render` and then pipe that result to `krane deploy -f -`.
|
142
141
|
|
143
142
|
### Customizing behaviour with annotations
|
144
143
|
- `krane.shopify.io/timeout-override`: Override the tool's hard timeout for one specific resource. Both full ISO8601 durations and the time portion of ISO8601 durations are valid. Value must be between 1 second and 24 hours.
|
@@ -324,12 +323,12 @@ status:
|
|
324
323
|
|
325
324
|
### Deploy walkthrough
|
326
325
|
|
327
|
-
Let's walk through what happens when you run the `deploy` task with [this directory of templates](https://github.com/Shopify/
|
326
|
+
Let's walk through what happens when you run the `deploy` task with [this directory of templates](https://github.com/Shopify/krane/tree/master/test/fixtures/hello-cloud). This particular example uses ERB templates as well, so we'll use the [krane render](#krane-render) task to achieve that.
|
328
327
|
|
329
328
|
You can test this out for yourself by running the following command:
|
330
329
|
|
331
330
|
```bash
|
332
|
-
krane render -f test/fixtures/hello-cloud --current-sha 1 | krane deploy my-namespace my-k8s-cluster
|
331
|
+
krane render -f test/fixtures/hello-cloud --current-sha 1 | krane deploy my-namespace my-k8s-cluster -f -
|
333
332
|
```
|
334
333
|
|
335
334
|
As soon as you run this, you'll start seeing some output being streamed to STDERR.
|
@@ -391,7 +390,7 @@ In this phase, we:
|
|
391
390
|
|
392
391
|
Just like in the previous phase, we essentially run `kubectl apply` on those templates and periodically check the cluster for the current status of each resource so we can display error or success information.
|
393
392
|
|
394
|
-
If pruning is enabled (which, again, is the default), any [kind not listed in the blacklist](https://github.com/Shopify/
|
393
|
+
If pruning is enabled (which, again, is the default), any [kind not listed in the blacklist](https://github.com/Shopify/krane/blob/master/lib/krane/cluster_resource_discovery.rb#L20) that we can find in the namespace but not in the templates will be removed. A particular message about pruning will be printed in the next phase if any resource matches this criteria.
|
395
394
|
|
396
395
|
#### Result
|
397
396
|
|
@@ -434,8 +433,7 @@ $ krane global-deploy my-k8s-context -f my-template.yml --selector app=krane
|
|
434
433
|
|
435
434
|
Refer to `krane global-deploy help` for the authoritative set of options.
|
436
435
|
|
437
|
-
- `--filenames / -
|
438
|
-
- `--stdin`: Read from STDIN. Can be combined with `-f`
|
436
|
+
- `--filenames / -f [PATHS]`: Accepts a list of directories and/or filenames to specify the set of directories/files that will be deployed. Use `-` to specify STDIN.
|
439
437
|
- `--no-prune`: Skips pruning of resources that are no longer in your Kubernetes template set. Not recommended, as it allows your namespace to accumulate cruft that is not reflected in your deploy directory.
|
440
438
|
- `--selector`: Instructs krane to only prune resources which match the specified label selector, such as `environment=staging`. By using this option, all resource templates must specify matching labels. See [Sharing a namespace](#sharing-a-namespace) below.
|
441
439
|
- `--global-timeout=duration`: Raise a timeout error if it takes longer than _duration_ for any
|
@@ -503,7 +501,7 @@ Based on this specification `krane run` will create a new pod with the entrypoin
|
|
503
501
|
|
504
502
|
*Options:*
|
505
503
|
|
506
|
-
* `--template=TEMPLATE`:
|
504
|
+
* `--template=TEMPLATE`: Specifies the name of the PodTemplate to use.
|
507
505
|
* `--env-vars=ENV_VARS`: Accepts a list of environment variables to be added to the pod template. For example, `--env-vars="ENV=VAL ENV2=VAL2"` will make `ENV` and `ENV2` available to the container.
|
508
506
|
* `--command=`: Override the default command in the container image.
|
509
507
|
* `--no-verify-result`: Skip verification of pod success
|
@@ -542,20 +540,17 @@ krane render -f ./path/to/template/dir/template.yaml.erb > template.yaml
|
|
542
540
|
|
543
541
|
*Options:*
|
544
542
|
|
545
|
-
- `--filenames / -f [PATHS]`: Accepts a list of directories and/or filenames to specify the set of directories/files that will be deployed.
|
546
|
-
- `--stdin`: Read from STDIN. Can be combined with `-f` Example: `cat templates_from_stdin/*.yml | krane render -f path/to/dir path/to/file.yml --stdin`
|
543
|
+
- `--filenames / -f [PATHS]`: Accepts a list of directories and/or filenames to specify the set of directories/files that will be deployed. Use `-` to specify STDIN.
|
547
544
|
- `--bindings=BINDINGS`: Makes additional variables available to your ERB templates. For example, `krane render --bindings=color=blue size=large -f some-template.yaml.erb` will expose `color` and `size` to `some-template.yaml.erb`.
|
548
545
|
- `--current-sha`: Expose SHA `current_sha` in ERB bindings
|
549
546
|
|
550
|
-
You can add additional variables using the `--bindings=BINDINGS` option which can be
|
551
|
-
file path prefixed with an `@` sign. An argument error will be raised if the string argument cannot be parsed, the referenced file does not include a
|
552
|
-
valid extension (`.json`, `.yaml` or `.yml`) or the referenced file does not exist.
|
547
|
+
You can add additional variables using the `--bindings=BINDINGS` option which can be formatted as a string, JSON string or path to a JSON or YAML file. Complex JSON or YAML data will be converted to a Hash for use in templates. To load a file, the argument should include the relative file path prefixed with an `@` sign. An argument error will be raised if the string argument cannot be parsed, the referenced file does not include a valid extension (`.json`, `.yaml` or `.yml`) or the referenced file does not exist.
|
553
548
|
|
554
549
|
#### Bindings examples
|
555
550
|
|
556
551
|
```
|
557
552
|
# Comma separated string. Exposes, 'color' and 'size'
|
558
|
-
$ krane render --bindings=color=blue
|
553
|
+
$ krane render --bindings=color=blue,size=large
|
559
554
|
|
560
555
|
# JSON string. Exposes, 'color' and 'size'
|
561
556
|
$ krane render --bindings='{"color":"blue","size":"large"}'
|
@@ -565,6 +560,9 @@ $ krane render --bindings='@config/production.json'
|
|
565
560
|
|
566
561
|
# Load YAML file from ./config (.yaml or yml supported)
|
567
562
|
$ krane render --bindings='@config/production.yaml'
|
563
|
+
|
564
|
+
# Load multiple files via a space separated string
|
565
|
+
$ krane render --bindings='@config/production.yaml' '@config/common.yaml'
|
568
566
|
```
|
569
567
|
|
570
568
|
#### Using partials
|
@@ -641,13 +639,13 @@ This is a limitation of the current implementation.
|
|
641
639
|
# Contributing
|
642
640
|
|
643
641
|
We :heart: contributors! To make it easier for you and us we've written a
|
644
|
-
[Contributing Guide](https://github.com/Shopify/
|
642
|
+
[Contributing Guide](https://github.com/Shopify/krane/blob/master/CONTRIBUTING.md)
|
645
643
|
|
646
644
|
|
647
645
|
You can also reach out to us on our slack channel, #krane, at https://kubernetes.slack.com. All are welcome!
|
648
646
|
|
649
647
|
## Code of Conduct
|
650
|
-
Everyone is expected to follow our [Code of Conduct](https://github.com/Shopify/
|
648
|
+
Everyone is expected to follow our [Code of Conduct](https://github.com/Shopify/krane/blob/master/CODE_OF_CONDUCT.md).
|
651
649
|
|
652
650
|
|
653
651
|
# License
|
data/bin/ci
CHANGED
data/bin/test
CHANGED
@@ -41,7 +41,7 @@ bundle exec rake unit_test
|
|
41
41
|
print_header "Run Non-Parallel Integration Tests"
|
42
42
|
bundle exec rake serial_integration_test
|
43
43
|
|
44
|
-
print_header "Run Parallel Integration Tests (
|
45
|
-
PARALLELIZE_ME=1
|
44
|
+
print_header "Run Parallel Integration Tests (MT_CPU=$PARALLELISM)"
|
45
|
+
PARALLELIZE_ME=1 MT_CPU=$PARALLELISM bundle exec rake integration_test
|
46
46
|
|
47
47
|
test $err -eq 0
|
data/dev.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
name:
|
2
|
+
name: krane
|
3
3
|
up:
|
4
|
-
- ruby: 2.
|
4
|
+
- ruby: 2.5.7 # Matches gemspec
|
5
5
|
- bundler
|
6
6
|
- homebrew:
|
7
7
|
- Caskroom/cask/minikube
|
@@ -11,8 +11,8 @@ up:
|
|
11
11
|
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
|
12
12
|
- custom:
|
13
13
|
name: Minikube Cluster
|
14
|
-
met?: test $(minikube status | grep Running | wc -l) -ge 2 && $(minikube status | grep -q '
|
15
|
-
meet: minikube start --kubernetes-version=v1.11.
|
14
|
+
met?: test $(minikube status | grep Running | wc -l) -ge 2 && $(minikube status | grep -q 'Configured')
|
15
|
+
meet: minikube start --kubernetes-version=v1.11.10 --vm-driver=hyperkit
|
16
16
|
down: minikube stop
|
17
17
|
commands:
|
18
18
|
reset-minikube: minikube delete && rm -rf ~/.minikube
|
data/krane.gemspec
CHANGED
@@ -23,22 +23,39 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = %w(lib)
|
25
25
|
|
26
|
-
spec.
|
26
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
27
|
+
|
28
|
+
spec.required_ruby_version = '>= 2.5.0'
|
27
29
|
spec.add_dependency("activesupport", ">= 5.0")
|
28
30
|
spec.add_dependency("kubeclient", "~> 4.3")
|
29
|
-
spec.add_dependency("googleauth", "~> 0.8
|
31
|
+
spec.add_dependency("googleauth", "~> 0.8")
|
30
32
|
spec.add_dependency("ejson", "~> 1.0")
|
31
33
|
spec.add_dependency("colorize", "~> 0.8")
|
32
34
|
spec.add_dependency("statsd-instrument", ['>= 2.8', "< 3.1"])
|
33
35
|
spec.add_dependency("oj", "~> 3.0")
|
34
36
|
spec.add_dependency("concurrent-ruby", "~> 1.1")
|
35
37
|
spec.add_dependency("jsonpath", "~> 0.9.6")
|
36
|
-
spec.add_dependency("thor", "
|
38
|
+
spec.add_dependency("thor", ">= 1.0", "< 2.0")
|
37
39
|
|
40
|
+
# Basics
|
38
41
|
spec.add_development_dependency("bundler")
|
39
42
|
spec.add_development_dependency("rake", "~> 10.0")
|
40
|
-
spec.add_development_dependency("
|
43
|
+
spec.add_development_dependency("yard")
|
44
|
+
|
45
|
+
# Test framework
|
46
|
+
spec.add_development_dependency("minitest", "~> 5.12")
|
41
47
|
spec.add_development_dependency("minitest-stub-const", "~> 0.6")
|
42
|
-
spec.add_development_dependency("
|
48
|
+
spec.add_development_dependency("minitest-reporters")
|
43
49
|
spec.add_development_dependency("mocha", "~> 1.5")
|
50
|
+
spec.add_development_dependency("webmock", "~> 3.0")
|
51
|
+
spec.add_development_dependency("timecop")
|
52
|
+
|
53
|
+
# Debugging and analysis
|
54
|
+
spec.add_development_dependency("pry")
|
55
|
+
spec.add_development_dependency("pry-byebug")
|
56
|
+
spec.add_development_dependency("byebug")
|
57
|
+
spec.add_development_dependency("ruby-prof")
|
58
|
+
spec.add_development_dependency("ruby-prof-flamegraph")
|
59
|
+
spec.add_development_dependency("rubocop", "~> 0.78.0")
|
60
|
+
spec.add_development_dependency("codecov")
|
44
61
|
end
|
@@ -14,7 +14,7 @@ module Krane
|
|
14
14
|
aliases: :f, required: false, default: [],
|
15
15
|
desc: "Directories and files that contains the configuration to apply" },
|
16
16
|
"stdin" => { type: :boolean, default: false,
|
17
|
-
desc: "Read resources from stdin" },
|
17
|
+
desc: "[DEPRECATED] Read resources from stdin" },
|
18
18
|
"global-timeout" => { type: :string, banner: "duration", default: DEFAULT_DEPLOY_TIMEOUT,
|
19
19
|
desc: "Max duration to monitor workloads correctly deployed" },
|
20
20
|
"protected-namespaces" => { type: :array, banner: "namespace1 namespace2 namespaceN",
|
@@ -26,7 +26,7 @@ module Krane
|
|
26
26
|
"selector" => { type: :string, banner: "'label=value'",
|
27
27
|
desc: "Select workloads by selector(s)" },
|
28
28
|
"verbose-log-prefix" => { type: :boolean, desc: "Add [context][namespace] to the log prefix",
|
29
|
-
default:
|
29
|
+
default: false },
|
30
30
|
"verify-result" => { type: :boolean, default: true,
|
31
31
|
desc: "Verify workloads correctly deployed" },
|
32
32
|
}
|
@@ -46,11 +46,10 @@ module Krane
|
|
46
46
|
protected_namespaces = []
|
47
47
|
end
|
48
48
|
|
49
|
-
# never mutate options directly
|
50
49
|
filenames = options[:filenames].dup
|
51
50
|
filenames << "-" if options[:stdin]
|
52
51
|
if filenames.empty?
|
53
|
-
raise
|
52
|
+
raise(Thor::RequiredArgumentMissingError, '--filenames must be set and not empty')
|
54
53
|
end
|
55
54
|
|
56
55
|
::Krane::OptionsHelper.with_processed_template_paths(filenames) do |paths|
|