kube_deploy_tools 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
require 'open3'
|
3
|
+
require 'shellwords'
|
4
|
+
|
5
|
+
require 'kube_deploy_tools/formatted_logger'
|
6
|
+
|
7
|
+
module KubeDeployTools
|
8
|
+
class Shellrunner
|
9
|
+
class << self
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
attr_accessor :shellrunner
|
13
|
+
def_delegators :@shellrunner, :check_call, :run_call
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_call(*cmd, **opts)
|
20
|
+
out, err, status = run_call(*cmd, **opts)
|
21
|
+
if !status.success?
|
22
|
+
raise "Command failed: #{Shellwords.join(cmd)} with the following error: #{err}"
|
23
|
+
end
|
24
|
+
out
|
25
|
+
end
|
26
|
+
|
27
|
+
def run_call(*cmd, **opts)
|
28
|
+
print_cmd = opts.fetch(:print_cmd, true)
|
29
|
+
if print_cmd
|
30
|
+
Logger.info(Shellwords.join(cmd))
|
31
|
+
else
|
32
|
+
Logger.debug(Shellwords.join(cmd))
|
33
|
+
end
|
34
|
+
out, err, status = Open3.capture3(*cmd, stdin_data: opts[:stdin_data])
|
35
|
+
Logger.debug(out.shellescape)
|
36
|
+
|
37
|
+
if !status.success? && print_cmd
|
38
|
+
Logger.warn("The following command failed: #{Shellwords.join(cmd)}")
|
39
|
+
Logger.warn(err)
|
40
|
+
end
|
41
|
+
|
42
|
+
[out.chomp, err.chomp, status]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module KubeDeployTools
|
2
|
+
# Default method to derive a tag name.
|
3
|
+
# An image is tagged for the git sha.
|
4
|
+
def self.tag_from_local_env
|
5
|
+
codestamp = `git describe --always --abbrev=7 --match=NONE --dirty`.chop
|
6
|
+
|
7
|
+
# Include the Jenkins build ID, in the case that there are
|
8
|
+
# multiple builds at the same git branch and git commit,
|
9
|
+
# but with different dependencies. e.g. Java builds
|
10
|
+
build = ENV.fetch('BUILD_ID', 'dev')[0...7]
|
11
|
+
|
12
|
+
docker_tag = "#{codestamp}-#{build}"
|
13
|
+
|
14
|
+
# Validate image tag.
|
15
|
+
#
|
16
|
+
# Definition of a valid image tag via:
|
17
|
+
# https://docs.docker.com/engine/reference/commandline/tag/#extended-description:
|
18
|
+
#
|
19
|
+
# > A tag name must be valid ASCII and may contain lowercase and uppercase
|
20
|
+
# > letters, digits, underscores, periods and dashes.
|
21
|
+
# > A tag name may not start with a period or a dash and
|
22
|
+
# > may contain a maximum of 128 characters.
|
23
|
+
#
|
24
|
+
# Regex for a valid image tag via:
|
25
|
+
# https://github.com/docker/distribution/blob/749f6afb4572201e3c37325d0ffedb6f32be8950/reference/regexp.go#L37
|
26
|
+
docker_tag = docker_tag.scan(/[\w][\w.-]{0,127}/).first
|
27
|
+
if docker_tag.nil?
|
28
|
+
raise "Expected valid Docker tag, but received '#{codestamp}'"
|
29
|
+
end
|
30
|
+
|
31
|
+
"#{docker_tag}"
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Heart of the templating engine used by render_deploys.
|
2
|
+
require 'erb'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
require 'kube_deploy_tools/object'
|
6
|
+
|
7
|
+
module KubeDeployTools
|
8
|
+
|
9
|
+
class Templater
|
10
|
+
def template(template, values)
|
11
|
+
output = render_erb_with_hash template, values
|
12
|
+
|
13
|
+
output
|
14
|
+
end
|
15
|
+
|
16
|
+
def render_erb_with_hash(template, values)
|
17
|
+
begin
|
18
|
+
renderer = ERB.new(File.read(template), nil, '-')
|
19
|
+
config = StrictHash.new(values)
|
20
|
+
renderer.result(binding)
|
21
|
+
rescue Exception => e
|
22
|
+
raise "Error rendering template #{template} with #{config}: #{e}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def template_to_file(template, values, maybeOutputFilepath = nil)
|
27
|
+
raise "Expected template to be an existing file, received '#{template}'" unless File.file?(template)
|
28
|
+
raise "Expected output filepath to be a new filepath, received '#{maybeOutputFilepath}'" if maybeOutputFilepath.present? && (File.file?(maybeOutputFilepath) || File.directory?(maybeOutputFilepath))
|
29
|
+
|
30
|
+
output = template(template, values)
|
31
|
+
|
32
|
+
# If an output filepath is not given, print to stdout
|
33
|
+
if !maybeOutputFilepath
|
34
|
+
$stdout.puts output
|
35
|
+
elsif output.present?
|
36
|
+
# Save file if output is not blank. This will suppress output file
|
37
|
+
# generation when using ERB early returns at the top of an ERB template:
|
38
|
+
# <% return if ... %>
|
39
|
+
FileUtils.mkdir_p(File.dirname(maybeOutputFilepath))
|
40
|
+
File.open(maybeOutputFilepath, "w") { |f| f << output }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class StrictHash
|
46
|
+
def initialize(h)
|
47
|
+
@h = h
|
48
|
+
end
|
49
|
+
|
50
|
+
def [](k)
|
51
|
+
@h.fetch(k)
|
52
|
+
end
|
53
|
+
|
54
|
+
def fetch(*args)
|
55
|
+
@h.fetch(*args)
|
56
|
+
end
|
57
|
+
|
58
|
+
def extra_flag(k)
|
59
|
+
@h[k]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'yaml'
|
3
|
+
require 'kube_deploy_tools/object'
|
4
|
+
|
5
|
+
module KubeDeployTools
|
6
|
+
class Templater::Optparser
|
7
|
+
class Options
|
8
|
+
attr_accessor :output,
|
9
|
+
:template,
|
10
|
+
:values,
|
11
|
+
:values_from_flags,
|
12
|
+
:values_from_yaml
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
# Values available in the ERB template to be merged.
|
16
|
+
# Avoid errors by forcing explicit checks for keys. With this, config[]
|
17
|
+
# indirection requires the key to exist.
|
18
|
+
self.values = {}
|
19
|
+
self.values_from_yaml = {}
|
20
|
+
self.values_from_flags = {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def define_options(parser)
|
24
|
+
parser.on('-tFILEPATH', '--template FILEPATH', 'The template file FILEPATH') do |f|
|
25
|
+
self.template = f
|
26
|
+
end
|
27
|
+
|
28
|
+
parser.on('-vFILENAME', '--values FILENAME', 'Set template variables from the values in a YAML file, FILENAME') do |f|
|
29
|
+
raise "Cannot find --values FILENAME '#{f}'" unless File.file?(f)
|
30
|
+
self.values_from_yaml = YAML::load(File.read(f))
|
31
|
+
end
|
32
|
+
|
33
|
+
parser.on('-sKEY=VALUE', '--set KEY=VALUE', 'Set a template variable with KEY=VALUE') do |kv|
|
34
|
+
raise "Cannot parse --set KEY=VALUE '#{kv}'" unless kv.include? '='
|
35
|
+
k, v = *kv.split("=")
|
36
|
+
self.values_from_flags[k] = v
|
37
|
+
end
|
38
|
+
|
39
|
+
parser.on('-oFILEPATH', '--output FILEPATH', 'Set the output file FILEPATH. Default output is to stdout.') do |f|
|
40
|
+
self.output = f
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def require_options
|
45
|
+
raise 'Must provide --template' unless template.present?
|
46
|
+
raise "Cannot find --template FILEPATH '#{template}'" unless File.file?(template)
|
47
|
+
raise "Expected --template FILEPATH '#{template}' to end with .yaml.erb" unless template.end_with?(".yaml.erb")
|
48
|
+
raise "Expected --output FILEPATH to be a new file location" unless output.blank? || !File.file?(output) || File.directory?(output)
|
49
|
+
end
|
50
|
+
|
51
|
+
def merge_values
|
52
|
+
# merge values from yaml
|
53
|
+
self.values = self.values.merge(self.values_from_yaml)
|
54
|
+
|
55
|
+
# merge values from flags
|
56
|
+
self.values = self.values.merge(self.values_from_flags)
|
57
|
+
|
58
|
+
warn 'Warning: No values provided from --values, --set' unless ! self.values.empty?
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def parse(args)
|
64
|
+
@options = Options.new
|
65
|
+
OptionParser.new do |parser|
|
66
|
+
@options.define_options(parser)
|
67
|
+
parser.parse(args)
|
68
|
+
@options.require_options
|
69
|
+
end
|
70
|
+
@options
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
metadata
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kube_deploy_tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fabien Goncalves
|
8
|
+
- Peter Hu
|
9
|
+
- Joshua Kwan
|
10
|
+
- Pratik Mallya
|
11
|
+
- Julian Modesto
|
12
|
+
- Renaud Pere
|
13
|
+
- Aditya Sarang
|
14
|
+
- Aaron Sproul
|
15
|
+
- Tiantian Tang
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
date: 2020-05-27 00:00:00.000000000 Z
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: colorize
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.8'
|
28
|
+
type: :runtime
|
29
|
+
prerelease: false
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0.8'
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: artifactory
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2.0'
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.0'
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: prmd
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.13'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.13'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rake
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '12.0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '12.0'
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: rspec
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.0'
|
84
|
+
type: :development
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.0'
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: rspec_junit_formatter
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 0.4.1
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 0.4.1
|
105
|
+
description: Tools used by LiveRamp to facilitate generation, packaging, and deployment
|
106
|
+
of Docker images and Kubernetes manifests.
|
107
|
+
email: ops@liveramp.com
|
108
|
+
executables:
|
109
|
+
- kdt
|
110
|
+
extensions: []
|
111
|
+
extra_rdoc_files: []
|
112
|
+
files:
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.md
|
115
|
+
- bin/deploy
|
116
|
+
- bin/generate
|
117
|
+
- bin/kdt
|
118
|
+
- bin/make_configmap
|
119
|
+
- bin/publish
|
120
|
+
- bin/push
|
121
|
+
- bin/render_deploys_hook
|
122
|
+
- bin/templater
|
123
|
+
- bin/upgrade
|
124
|
+
- lib/kube_deploy_tools.rb
|
125
|
+
- lib/kube_deploy_tools/artifact_registry.rb
|
126
|
+
- lib/kube_deploy_tools/artifact_registry/driver.rb
|
127
|
+
- lib/kube_deploy_tools/artifact_registry/driver_artifactory.rb
|
128
|
+
- lib/kube_deploy_tools/artifact_registry/driver_base.rb
|
129
|
+
- lib/kube_deploy_tools/artifact_registry/driver_gcs.rb
|
130
|
+
- lib/kube_deploy_tools/built_artifacts_file.rb
|
131
|
+
- lib/kube_deploy_tools/concurrency.rb
|
132
|
+
- lib/kube_deploy_tools/deferred_summary_logging.rb
|
133
|
+
- lib/kube_deploy_tools/deploy.rb
|
134
|
+
- lib/kube_deploy_tools/deploy/options.rb
|
135
|
+
- lib/kube_deploy_tools/deploy_config_file.rb
|
136
|
+
- lib/kube_deploy_tools/deploy_config_file/deep_merge.rb
|
137
|
+
- lib/kube_deploy_tools/deploy_config_file/util.rb
|
138
|
+
- lib/kube_deploy_tools/errors.rb
|
139
|
+
- lib/kube_deploy_tools/file_filter.rb
|
140
|
+
- lib/kube_deploy_tools/formatted_logger.rb
|
141
|
+
- lib/kube_deploy_tools/generate.rb
|
142
|
+
- lib/kube_deploy_tools/generate/options.rb
|
143
|
+
- lib/kube_deploy_tools/image_registry.rb
|
144
|
+
- lib/kube_deploy_tools/image_registry/driver.rb
|
145
|
+
- lib/kube_deploy_tools/image_registry/driver/aws.rb
|
146
|
+
- lib/kube_deploy_tools/image_registry/driver/base.rb
|
147
|
+
- lib/kube_deploy_tools/image_registry/driver/gcp.rb
|
148
|
+
- lib/kube_deploy_tools/image_registry/driver/login.rb
|
149
|
+
- lib/kube_deploy_tools/image_registry/driver/noop.rb
|
150
|
+
- lib/kube_deploy_tools/image_registry/image.rb
|
151
|
+
- lib/kube_deploy_tools/kdt.rb
|
152
|
+
- lib/kube_deploy_tools/kubectl.rb
|
153
|
+
- lib/kube_deploy_tools/kubernetes_resource.rb
|
154
|
+
- lib/kube_deploy_tools/kubernetes_resource/deployment.rb
|
155
|
+
- lib/kube_deploy_tools/make_configmap.rb
|
156
|
+
- lib/kube_deploy_tools/make_configmap/options.rb
|
157
|
+
- lib/kube_deploy_tools/object.rb
|
158
|
+
- lib/kube_deploy_tools/publish.rb
|
159
|
+
- lib/kube_deploy_tools/publish/options.rb
|
160
|
+
- lib/kube_deploy_tools/push.rb
|
161
|
+
- lib/kube_deploy_tools/push/options.rb
|
162
|
+
- lib/kube_deploy_tools/render_deploys_hook.rb
|
163
|
+
- lib/kube_deploy_tools/shellrunner.rb
|
164
|
+
- lib/kube_deploy_tools/tag.rb
|
165
|
+
- lib/kube_deploy_tools/templater.rb
|
166
|
+
- lib/kube_deploy_tools/templater/options.rb
|
167
|
+
- lib/kube_deploy_tools/version.rb
|
168
|
+
homepage: https://github.com/LiveRamp/kube_deploy_tools
|
169
|
+
licenses:
|
170
|
+
- Apache-2.0
|
171
|
+
metadata: {}
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '2.5'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
requirements: []
|
187
|
+
rubygems_version: 3.0.3
|
188
|
+
signing_key:
|
189
|
+
specification_version: 4
|
190
|
+
summary: Kubernetes Deploy Tools
|
191
|
+
test_files: []
|