kube_deploy_tools 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +177 -0
- data/README.md +142 -0
- data/bin/deploy +60 -0
- data/bin/generate +28 -0
- data/bin/kdt +17 -0
- data/bin/make_configmap +20 -0
- data/bin/publish +28 -0
- data/bin/push +57 -0
- data/bin/render_deploys_hook +18 -0
- data/bin/templater +34 -0
- data/bin/upgrade +23 -0
- data/lib/kube_deploy_tools.rb +17 -0
- data/lib/kube_deploy_tools/artifact_registry.rb +30 -0
- data/lib/kube_deploy_tools/artifact_registry/driver.rb +13 -0
- data/lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb +155 -0
- data/lib/kube_deploy_tools/artifact_registry/driver_base.rb +37 -0
- data/lib/kube_deploy_tools/artifact_registry/driver_gcs.rb +120 -0
- data/lib/kube_deploy_tools/built_artifacts_file.rb +28 -0
- data/lib/kube_deploy_tools/concurrency.rb +18 -0
- data/lib/kube_deploy_tools/deferred_summary_logging.rb +69 -0
- data/lib/kube_deploy_tools/deploy.rb +215 -0
- data/lib/kube_deploy_tools/deploy/options.rb +114 -0
- data/lib/kube_deploy_tools/deploy_config_file.rb +286 -0
- data/lib/kube_deploy_tools/deploy_config_file/deep_merge.rb +38 -0
- data/lib/kube_deploy_tools/deploy_config_file/util.rb +39 -0
- data/lib/kube_deploy_tools/errors.rb +5 -0
- data/lib/kube_deploy_tools/file_filter.rb +43 -0
- data/lib/kube_deploy_tools/formatted_logger.rb +59 -0
- data/lib/kube_deploy_tools/generate.rb +145 -0
- data/lib/kube_deploy_tools/generate/options.rb +66 -0
- data/lib/kube_deploy_tools/image_registry.rb +30 -0
- data/lib/kube_deploy_tools/image_registry/driver.rb +18 -0
- data/lib/kube_deploy_tools/image_registry/driver/aws.rb +121 -0
- data/lib/kube_deploy_tools/image_registry/driver/base.rb +50 -0
- data/lib/kube_deploy_tools/image_registry/driver/gcp.rb +71 -0
- data/lib/kube_deploy_tools/image_registry/driver/login.rb +26 -0
- data/lib/kube_deploy_tools/image_registry/driver/noop.rb +15 -0
- data/lib/kube_deploy_tools/image_registry/image.rb +17 -0
- data/lib/kube_deploy_tools/kdt.rb +52 -0
- data/lib/kube_deploy_tools/kubectl.rb +25 -0
- data/lib/kube_deploy_tools/kubernetes_resource.rb +57 -0
- data/lib/kube_deploy_tools/kubernetes_resource/deployment.rb +56 -0
- data/lib/kube_deploy_tools/make_configmap.rb +51 -0
- data/lib/kube_deploy_tools/make_configmap/options.rb +39 -0
- data/lib/kube_deploy_tools/object.rb +11 -0
- data/lib/kube_deploy_tools/publish.rb +40 -0
- data/lib/kube_deploy_tools/publish/options.rb +34 -0
- data/lib/kube_deploy_tools/push.rb +129 -0
- data/lib/kube_deploy_tools/push/options.rb +46 -0
- data/lib/kube_deploy_tools/render_deploys_hook.rb +95 -0
- data/lib/kube_deploy_tools/shellrunner.rb +46 -0
- data/lib/kube_deploy_tools/tag.rb +33 -0
- data/lib/kube_deploy_tools/templater.rb +63 -0
- data/lib/kube_deploy_tools/templater/options.rb +74 -0
- data/lib/kube_deploy_tools/version.rb +3 -0
- metadata +191 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9f4077fc4d8fce7c7d5e9ea6f664f7be3f19b1c9e41ef8a1fa909685f195550d
|
4
|
+
data.tar.gz: 33e8aeebd5a2235e23111c36dcef8b228c0754b45b9a1af03cd2054437649ccc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aeca489af252fafbc3e493197765b3bbbd8db09ff21ef0372d07d87f53317f00bd3d55e3efdc27fec2d0f7ad9555ead6a5adbff73486cdea45ad3e45efb294c1
|
7
|
+
data.tar.gz: c5be546497348d309048bcefd55f0d255c50f2fd2a21405f091a9042089984d6e118b59024a4f60c47af7c3a3aa401c900482c250c31244af35a827062dc342e
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
data/README.md
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# kube_deploy_tools (kdt)
|
2
|
+
|
3
|
+
`kube_deploy_tools` (kdt) is a tool to simplify kubernetes manifest generation
|
4
|
+
and deployment. In short, it is able to:
|
5
|
+
|
6
|
+
* ***generate*** Kubernetes manifests from flexible [ERB] templates.
|
7
|
+
Templating contexts have access to a `config` Hash of options.
|
8
|
+
Multiple versions of the same manifests can be defined by creating
|
9
|
+
separate *artifacts* and *flavors* which modify `config`.
|
10
|
+
* ***push*** Docker images tagged with the prefix `local-registry/`
|
11
|
+
to your configured image registry/ies. kdt will retag images
|
12
|
+
appropriately for the destination and push in parallel.
|
13
|
+
* ***publish*** a manifest of all generated manifests, docker images and
|
14
|
+
tags for archival and eventual expiration of all artifacts related
|
15
|
+
to a single build.
|
16
|
+
* ***deploy*** manifests referencing your built and pushed images out to
|
17
|
+
production.
|
18
|
+
|
19
|
+
kdt is written in Ruby, but can be used with any project that
|
20
|
+
deploys to Kubernetes. It can be seen as a lightweight alternative to more
|
21
|
+
popular products like [Helm].
|
22
|
+
|
23
|
+
Each of the use cases described above is defined as a separate subcommand of
|
24
|
+
the parent `kdt` command. The tools are singularly configured by a
|
25
|
+
`deploy.yaml` document checked-in to the root of your repository. While all of
|
26
|
+
these components are used today at [@LiveRamp](https://github.com/LiveRamp) for
|
27
|
+
a complete production lifecycle, they are also designed to be used
|
28
|
+
individually.
|
29
|
+
|
30
|
+
[Helm]: https://helm.sh
|
31
|
+
|
32
|
+
# Getting Started
|
33
|
+
|
34
|
+
## Install
|
35
|
+
|
36
|
+
Include the `gem 'kube_deploy_tools', '~> 3'` in your project via a Gemfile
|
37
|
+
or gemspec.
|
38
|
+
|
39
|
+
## Configure
|
40
|
+
|
41
|
+
Once kdt is installed, you will need to configure it. This is done by adding
|
42
|
+
a new file named `deploy.yaml` at the root of your project. A minimal
|
43
|
+
`deploy.yaml` for deploying to [Google Container Registry] is shown below:
|
44
|
+
|
45
|
+
```yaml
|
46
|
+
version: 2 # version of kdt to be used
|
47
|
+
default_flags:
|
48
|
+
pull_policy: IfNotPresent # define default k-v pairs to be made available in ERB's `config` to all artifacts and flavors
|
49
|
+
artifacts: # define groups of manifests as named artifacts for `kdt generate`
|
50
|
+
- name: prod
|
51
|
+
image_registry: gcp
|
52
|
+
flags: {} # define extra k-v pairs for ERB `config` during `kdt generate` for a specific artifact
|
53
|
+
flavors:
|
54
|
+
default: # define extra k-v pairs for ERB `config` during `kdt generate` for a specific flavor
|
55
|
+
important_config: '42' # appears in `config` for the prod/default flavor, but nowhere else
|
56
|
+
artifact_registries: # define destination for `kdt publish`
|
57
|
+
image_registries: # define image registries for `kdt push`
|
58
|
+
- name: gcp # `kdt push` will deploy to Google Container Registry
|
59
|
+
driver: gcp
|
60
|
+
prefix: gcr.io/my-gcr-project
|
61
|
+
```
|
62
|
+
|
63
|
+
You can check out a [complete description] of the `deploy.yaml` schema.
|
64
|
+
|
65
|
+
Next, create a `kubernetes/deployment.yaml.erb` file as follows:
|
66
|
+
|
67
|
+
```yaml
|
68
|
+
apiVersion: apps/v1
|
69
|
+
kind: Deployment
|
70
|
+
metadata:
|
71
|
+
name: my-first-kdt-app
|
72
|
+
labels:
|
73
|
+
app: my-first-kdt-app
|
74
|
+
spec:
|
75
|
+
replicas: 1
|
76
|
+
selector:
|
77
|
+
matchLabels:
|
78
|
+
app: my-first-kdt-app
|
79
|
+
template:
|
80
|
+
metadata:
|
81
|
+
labels:
|
82
|
+
app: my-first-kdt-app
|
83
|
+
spec:
|
84
|
+
containers:
|
85
|
+
- name: my-app
|
86
|
+
image: <%= config['image_registry'] %>/my-app:<%= config['tag'] %>
|
87
|
+
imagePullPolicy: <%= config['pull_policy'] %>
|
88
|
+
env:
|
89
|
+
- name: IMPORTANT_CONFIG
|
90
|
+
value: <%= config['important_config'] %>
|
91
|
+
```
|
92
|
+
|
93
|
+
Observe the use of ERB tags to fill in various values from the `config` Hash. The `config` hash
|
94
|
+
is generated from a combination of artifact `flags`, `flavors`, `default_flags`, and the settings
|
95
|
+
from `image_registries`. `tag` is autogenerated from your Git SCM workspace.
|
96
|
+
|
97
|
+
Now, run `bundle exec kdt generate` and observe
|
98
|
+
`build/kubernetes/prod_default/deployment.yaml` is created with all template
|
99
|
+
variables filled in.
|
100
|
+
|
101
|
+
To explore further,
|
102
|
+
* Build a docker image tagged `local-registry/my-app`, then run `kdt push my-app`.
|
103
|
+
* Run `kdt deploy -f build/kubernetes/prod_default --context my-kube-context` to send your generated
|
104
|
+
manifests to a Kubernetes API server.
|
105
|
+
|
106
|
+
[complete description]: XXX
|
107
|
+
|
108
|
+
# FAQ
|
109
|
+
|
110
|
+
* ***Q***: Will KDT help me build my Docker images?
|
111
|
+
* ***A***: No. The recommended usage is to build your docker images ahead of time and pre-tag them as local-registry/name-here.
|
112
|
+
Then running `kdt push name-here` will automatically retag your images with your target registry and send them off.
|
113
|
+
|
114
|
+
# Changes
|
115
|
+
|
116
|
+
For breaking changes, new features, and new fixes, see
|
117
|
+
[CHANGELOG.md](CHANGELOG.md).
|
118
|
+
|
119
|
+
# Contribute
|
120
|
+
|
121
|
+
```bash
|
122
|
+
# Install ruby w/ Homebrew
|
123
|
+
brew install ruby
|
124
|
+
|
125
|
+
# Or install ruby w/ rbenv
|
126
|
+
brew install rbenv ruby-build
|
127
|
+
rbenv install 2.3.0
|
128
|
+
rbenv global 2.3.0
|
129
|
+
|
130
|
+
# Install gem
|
131
|
+
gem install bundler
|
132
|
+
```
|
133
|
+
|
134
|
+
```bash
|
135
|
+
bundle install --with development
|
136
|
+
|
137
|
+
# Run tests
|
138
|
+
bundle exec rake test
|
139
|
+
|
140
|
+
# Exec a binary in bin/
|
141
|
+
bundle exec kdt generate
|
142
|
+
```
|
data/bin/deploy
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Utility for applying Kubernetes manifests.
|
3
|
+
|
4
|
+
require 'tmpdir'
|
5
|
+
|
6
|
+
require 'kube_deploy_tools/formatted_logger'
|
7
|
+
require 'kube_deploy_tools/kubectl'
|
8
|
+
require 'kube_deploy_tools/shellrunner'
|
9
|
+
require 'kube_deploy_tools/deploy'
|
10
|
+
require 'kube_deploy_tools/deploy/options'
|
11
|
+
require 'kube_deploy_tools/deploy_config_file'
|
12
|
+
require 'kube_deploy_tools/artifact_registry'
|
13
|
+
|
14
|
+
def options
|
15
|
+
@options ||= KubeDeployTools::Deploy::Optparser.new.parse(ARGV)
|
16
|
+
end
|
17
|
+
|
18
|
+
KubeDeployTools::Logger.logger = KubeDeployTools::FormattedLogger.build
|
19
|
+
KubeDeployTools::Shellrunner.shellrunner = KubeDeployTools::Shellrunner.new
|
20
|
+
context = options.context || KubeDeployTools.kube_context(target: options.target, environment: options.environment)
|
21
|
+
namespace = KubeDeployTools::Deploy::kube_namespace(context: context, kubeconfig: options.kubeconfig)
|
22
|
+
KubeDeployTools::Logger.logger = KubeDeployTools::FormattedLogger.build(context: context, namespace: namespace)
|
23
|
+
kubectl = KubeDeployTools::Kubectl.new(
|
24
|
+
context: options.context,
|
25
|
+
kubeconfig: options.kubeconfig
|
26
|
+
)
|
27
|
+
|
28
|
+
config = KubeDeployTools::DeployConfigFile.new('deploy.yaml')
|
29
|
+
artifact_registry = config.artifact_registries[config.artifact_registry].driver
|
30
|
+
|
31
|
+
Dir.mktmpdir do |tmpdir|
|
32
|
+
if options.from_files
|
33
|
+
deploy_artifact_path = options.from_files
|
34
|
+
else
|
35
|
+
if options.build_number == 'latest'
|
36
|
+
options.build_number = artifact_registry.get_latest_build_number(options.project)
|
37
|
+
end
|
38
|
+
|
39
|
+
deploy_artifact_path = artifact_registry.download(
|
40
|
+
project: options.project,
|
41
|
+
build_number: options.build_number,
|
42
|
+
flavor: options.flavor,
|
43
|
+
name: options.artifact,
|
44
|
+
pre_apply_hook: options.pre_apply_hook,
|
45
|
+
output_dir: tmpdir
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
deploy = KubeDeployTools::Deploy.new(
|
50
|
+
kubectl: kubectl,
|
51
|
+
namespace: namespace,
|
52
|
+
input_path: deploy_artifact_path,
|
53
|
+
glob_files: options.glob_files,
|
54
|
+
max_retries: options.max_retries,
|
55
|
+
retry_delay: options.retry_delay
|
56
|
+
)
|
57
|
+
deploy.run(
|
58
|
+
dry_run: options.dry_run,
|
59
|
+
)
|
60
|
+
end
|
data/bin/generate
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Run from the root of a repository. |deploy.json| is expected to exist there.
|
4
|
+
# Generates all deploys based on permutations defined in deploy.yml combined
|
5
|
+
# with cluster configuration from kube_deploy_tools.
|
6
|
+
|
7
|
+
require 'kube_deploy_tools/formatted_logger'
|
8
|
+
require 'kube_deploy_tools/shellrunner'
|
9
|
+
require 'kube_deploy_tools/generate'
|
10
|
+
require 'kube_deploy_tools/generate/options'
|
11
|
+
|
12
|
+
def options
|
13
|
+
parser = KubeDeployTools::Generate::Optparser.new
|
14
|
+
parser.parse(ARGV)
|
15
|
+
end
|
16
|
+
|
17
|
+
KubeDeployTools::Logger.logger = KubeDeployTools::FormattedLogger.build
|
18
|
+
KubeDeployTools::Shellrunner.shellrunner = KubeDeployTools::Shellrunner.new
|
19
|
+
|
20
|
+
app = KubeDeployTools::Generate.new(
|
21
|
+
options.manifest_file,
|
22
|
+
options.input_path,
|
23
|
+
options.output_path,
|
24
|
+
file_filters: options.file_filters,
|
25
|
+
print_flags_only: options.print_flags_only,
|
26
|
+
literals: options.literals,
|
27
|
+
)
|
28
|
+
app.generate
|
data/bin/kdt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'kube_deploy_tools/kdt'
|
4
|
+
|
5
|
+
kdt = KubeDeployTools::Kdt.new(__dir__, ARGV)
|
6
|
+
|
7
|
+
def show_help?
|
8
|
+
return true if ARGV.empty?
|
9
|
+
return true if ARGV.size == 1 && %w(--help help).include?(ARGV.first.strip)
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
if show_help?
|
14
|
+
kdt.display_bins
|
15
|
+
else
|
16
|
+
kdt.execute!
|
17
|
+
end
|
data/bin/make_configmap
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
require 'kube_deploy_tools/formatted_logger'
|
6
|
+
require 'kube_deploy_tools/make_configmap'
|
7
|
+
require 'kube_deploy_tools/make_configmap/options'
|
8
|
+
|
9
|
+
def options
|
10
|
+
opts = KubeDeployTools::Options.new
|
11
|
+
ops = opts.options
|
12
|
+
ops
|
13
|
+
end
|
14
|
+
|
15
|
+
KubeDeployTools::Logger.logger = KubeDeployTools::FormattedLogger.build
|
16
|
+
KubeDeployTools::Logger.warn "This subcommand will be disappearing in kdt v3.0."
|
17
|
+
|
18
|
+
ARGV << '--help' if ARGV.empty?
|
19
|
+
make_configmap = KubeDeployTools::ConfigMap.new(options[:name], options[:from_file], options[:namespace], options[:labels])
|
20
|
+
puts YAML::dump(make_configmap.target_hash)
|