kubes 0.8.9 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/docs/_docs/layering/debug.md +60 -0
- data/docs/_docs/layering/dsl.md +3 -0
- data/docs/_docs/layering/extra.md +2 -0
- data/docs/_docs/layering/merge-dsl.md +3 -0
- data/docs/_docs/layering/merge-options.md +2 -0
- data/docs/_docs/layering/mix.md +3 -0
- data/docs/_docs/layering/yaml.md +3 -0
- data/docs/_docs/layering.md +4 -5
- data/docs/_includes/sidebar.html +4 -6
- data/lib/kubes/compiler/shared/runtime_helpers.rb +31 -2
- data/lib/kubes/compiler/strategy/base.rb +1 -0
- data/lib/kubes/compiler/strategy/dispatcher.rb +12 -0
- data/lib/kubes/compiler.rb +3 -3
- data/lib/kubes/config.rb +3 -0
- data/lib/kubes/util/pretty.rb +7 -0
- data/lib/kubes/util/sh.rb +1 -1
- data/lib/kubes/version.rb +1 -1
- data/lib/templates/base/.kubes/config.rb.tt +2 -1
- data/lib/templates/new/resource/yaml/secret.yaml +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2481a18249c348869a45a16c59ab5718f7e0e0eabb0ad5d613720e162b0b6150
|
4
|
+
data.tar.gz: baab953af69e63ee3697dc995abdac3a49e734d825d4b60dbe253618c0adea69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db322cd2a2c7154f56f6980b2e76319d211ad84290d8d5fbf1ce11e502b65260a2f7b9202636cf59d9a03a25ed84d96024598e97117a465679383cd733679cce
|
7
|
+
data.tar.gz: 67e8ad348fd9bebc223c2b83c038c74999f7e1afc573fe94a989b161f7f1fde6cd35410b9fb120497dd93f565009f0793d6d8bc8208721f0aefd98324d4d6ed4
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,17 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.9.1] - 2022-08-24
|
7
|
+
- [#67](https://github.com/boltops-tools/kubes/pull/67) small improvement to show layering: show compiled output path
|
8
|
+
|
9
|
+
## [0.9.0] - 2022-08-24
|
10
|
+
- [#66](https://github.com/boltops-tools/kubes/pull/66) show layering improvements: show resource layers also
|
11
|
+
- only show error if exit_on_fail
|
12
|
+
|
13
|
+
## [0.8.10] - 2022-08-18
|
14
|
+
- [#65](https://github.com/boltops-tools/kubes/pull/65) show variables layers support
|
15
|
+
- improve new secret generator
|
16
|
+
|
6
17
|
## [0.8.9] - 2022-08-11
|
7
18
|
- [#64](https://github.com/boltops-tools/kubes/pull/64) extra variable layering
|
8
19
|
- add extra layering docs
|
@@ -0,0 +1,60 @@
|
|
1
|
+
---
|
2
|
+
title: "Debug Layering"
|
3
|
+
category: layering
|
4
|
+
order: 9
|
5
|
+
---
|
6
|
+
|
7
|
+
Kube's Layering abilities are so powerful that they can be difficult to debug when overly used. It is recommended that you chose only a few layers that make sense for your goals and stick to them. Essentially, limit the rope length. Here are also some debugging tips.
|
8
|
+
|
9
|
+
## Enable Logging
|
10
|
+
|
11
|
+
You can debug layers by setting `KUBES_LAYERING_SHOW=1`.
|
12
|
+
|
13
|
+
export KUBES_LAYERING_SHOW=1
|
14
|
+
|
15
|
+
You can also turn on show layering with a config.
|
16
|
+
|
17
|
+
.kubes/config.rb
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
Kubes.configure do |config|
|
21
|
+
config.layering.show = true
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
This will show the **found** layers.
|
26
|
+
|
27
|
+
$ kubes compile
|
28
|
+
Compiling .kubes/resources/web/deployment.yaml
|
29
|
+
Resource layers:
|
30
|
+
.kubes/resources/base/all.yaml
|
31
|
+
.kubes/resources/base/deployment.yaml
|
32
|
+
.kubes/resources/web/deployment.yaml
|
33
|
+
.kubes/resources/web/deployment/dev.yaml
|
34
|
+
Variables layers:
|
35
|
+
.kubes/variables/base.rb
|
36
|
+
.kubes/variables/dev.rb
|
37
|
+
|
38
|
+
## All Considered Layers
|
39
|
+
|
40
|
+
If you want to also see all the considered layers use `KUBES_LAYERING_SHOW_ALL=1`. Note, this will show a lot of layers. Kubes considers many layers and for files `base/all.yml` also perform layering and results are ultimately merged together. Here's an example snippet of the output.
|
41
|
+
|
42
|
+
$ export KUBES_LAYERING_SHOW_ALL=1
|
43
|
+
Compiling .kubes/resources/web/deployment.yaml
|
44
|
+
Resource layers:
|
45
|
+
.kubes/resources/base/all.yaml
|
46
|
+
.kubes/resources/base/deployment.yaml
|
47
|
+
.kubes/resources/web/deployment.yaml
|
48
|
+
.kubes/resources/web/deployment/dev.yaml
|
49
|
+
Variables layers:
|
50
|
+
.kubes/variables/base.rb
|
51
|
+
.kubes/variables/dev.rb
|
52
|
+
.kubes/variables/base/all.rb
|
53
|
+
.kubes/variables/base/all/dev.rb
|
54
|
+
.kubes/variables/base/deployment.rb
|
55
|
+
.kubes/variables/base/deployment/base.rb
|
56
|
+
.kubes/variables/base/deployment/dev.rb
|
57
|
+
.kubes/variables/web/deployment.rb
|
58
|
+
.kubes/variables/web/deployment/base.rb
|
59
|
+
.kubes/variables/web/deployment/dev.rb
|
60
|
+
...
|
data/docs/_docs/layering/dsl.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
---
|
2
2
|
title: Merge Options
|
3
|
+
category: layering
|
4
|
+
order: 5
|
3
5
|
---
|
4
6
|
|
5
7
|
Underneath the hood, Kubes uses the [danielsdeleo/deep_merge](https://github.com/danielsdeleo/deep_merge) library to merge layers together. You can control the merge behavior options with [config.merger.options]({% link _docs/config/reference.md %}).
|
data/docs/_docs/layering/mix.md
CHANGED
data/docs/_docs/layering/yaml.md
CHANGED
data/docs/_docs/layering.md
CHANGED
@@ -4,8 +4,7 @@ title: Layering
|
|
4
4
|
|
5
5
|
Kubes supports layering files together so you can use the same Kubernetes files to build multiple environments like dev and prod.
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
* [
|
10
|
-
|
11
|
-
* [Extra Layering]({% link _docs/layering/extra.md %})
|
7
|
+
{% assign docs = site.docs | where: "categories","layering" | sort: "order" %}
|
8
|
+
{% for doc in docs -%}
|
9
|
+
* [{{ doc.title }}]({{ doc.url }})
|
10
|
+
{% endfor %}
|
data/docs/_includes/sidebar.html
CHANGED
@@ -123,12 +123,10 @@
|
|
123
123
|
</li>
|
124
124
|
<li><a href="{% link _docs/layering.md %}">Layering</a>
|
125
125
|
<ul>
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
<li><a href="{% link _docs/layering/merge-options.md %}">Merge Options</a></li>
|
131
|
-
<li><a href="{% link _docs/layering/extra.md %}">Extra Layering</a></li>
|
126
|
+
{% assign docs = site.docs | where: "categories","layering" | sort: "order" %}
|
127
|
+
{% for doc in docs -%}
|
128
|
+
<li><a href="{{ doc.url }}">{% if doc.nav_text %}{{ doc.nav_text }}{% else %}{{ doc.title }}{% endif %}</a></li>
|
129
|
+
{% endfor %}
|
132
130
|
</ul>
|
133
131
|
</li>
|
134
132
|
<li><a href="{% link _docs/dsl.md %}">DSL</a>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Kubes::Compiler::Shared
|
2
2
|
module RuntimeHelpers
|
3
3
|
include Kubes::Compiler::Shared::Helpers
|
4
|
+
include Kubes::Util::Pretty
|
4
5
|
|
5
6
|
def load_runtime_helpers
|
6
7
|
load_plugin_helpers
|
@@ -72,6 +73,10 @@ module Kubes::Compiler::Shared
|
|
72
73
|
"#{role}/#{kind}/#{Kubes.env}.rb",
|
73
74
|
"#{role}/#{kind}/#{Kubes.env}-#{Kubes.extra}.rb",
|
74
75
|
]
|
76
|
+
# filter out the -.rb layers when Kubes.extra is not set
|
77
|
+
# IE: .kubes/variables/dev-.rb
|
78
|
+
layers.reject! { |layer| layer.ends_with?('-.rb') }
|
79
|
+
|
75
80
|
if Kubes.app
|
76
81
|
app_layers = ["#{Kubes.app}.rb"]
|
77
82
|
app_layers += layers.map do |path|
|
@@ -80,10 +85,34 @@ module Kubes::Compiler::Shared
|
|
80
85
|
layers += app_layers
|
81
86
|
end
|
82
87
|
|
83
|
-
layers.
|
84
|
-
|
88
|
+
layer_paths = layers.map { |layer| "#{Kubes.root}/.kubes/variables/#{layer}" }
|
89
|
+
layer_paths = layer_paths.select { |path| File.exist?(path) } unless ENV['KUBES_LAYERING_SHOW_ALL']
|
90
|
+
layer_paths.each do |path|
|
91
|
+
show_variable_layer_path(path)
|
85
92
|
evaluate_file(path)
|
86
93
|
end
|
87
94
|
end
|
95
|
+
|
96
|
+
@@header_shown = {} # key is main @path
|
97
|
+
@@shown = {}
|
98
|
+
def show_variable_layer_path(path)
|
99
|
+
main_path = @path # main path is main resource file
|
100
|
+
|
101
|
+
show_header = !@@header_shown.dig(main_path)
|
102
|
+
if show_header && Kubes.config.layering.show
|
103
|
+
logger.info " Variables layers:"
|
104
|
+
@@header_shown[main_path] = true
|
105
|
+
end
|
106
|
+
# Examples:
|
107
|
+
# .kubes/resources/web/deployment.yaml
|
108
|
+
# .kubes/resources/shared/namespace.yaml
|
109
|
+
show_once = !@@shown.dig(main_path, path)
|
110
|
+
show_layer = Kubes.config.layering.show && show_once
|
111
|
+
if show_layer
|
112
|
+
logger.info " #{pretty_path(path)}"
|
113
|
+
@@shown[main_path] ||= {}
|
114
|
+
@@shown[main_path][path] = true
|
115
|
+
end
|
116
|
+
end
|
88
117
|
end
|
89
118
|
end
|
@@ -1,21 +1,33 @@
|
|
1
1
|
class Kubes::Compiler::Strategy
|
2
2
|
class Dispatcher < Base
|
3
3
|
def dispatch
|
4
|
+
show_layers if Kubes.config.layering.show
|
4
5
|
result = render(@path) # main
|
5
6
|
results = [result].flatten # ensure array
|
6
7
|
data = results.map! do |main|
|
7
8
|
hash = Kubes.deep_merge!(pre_layer, main)
|
8
9
|
Kubes.deep_merge!(hash, post_layer)
|
9
10
|
end
|
11
|
+
logger.info "Compiled .kubes/output/#{@save_file}" if Kubes.config.layering.show
|
10
12
|
Result.new(@save_file, data)
|
11
13
|
end
|
12
14
|
|
15
|
+
def show_layers
|
16
|
+
logger.info "Compiling #{pretty_path(@path)}"
|
17
|
+
logger.info " Resource layers:"
|
18
|
+
all_layers = pre_layers + [@path] + post_layers
|
19
|
+
all_layers.each do |layer|
|
20
|
+
logger.info " #{pretty_path(layer)}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
13
24
|
# Render via to Erb or one of the DSL syntax classes or Core/Blocks class
|
14
25
|
def render(path)
|
15
26
|
if path.include?('.rb')
|
16
27
|
klass = dsl_class(path) # IE: Kubes::Compiler::Dsl::Syntax::Deployment or Kubes::Compiler::Dsl::Core::Blocks
|
17
28
|
klass.new(@options.merge(path: path, data: @data)).run
|
18
29
|
else
|
30
|
+
logger.info "Rendering #{pretty_path(path)}" if ENV['KUBES_LAYERING_SHOW_RENDERING']
|
19
31
|
Erb.new(@options.merge(data: @data)).render_result(path)
|
20
32
|
end
|
21
33
|
end
|
data/lib/kubes/compiler.rb
CHANGED
@@ -24,7 +24,7 @@ module Kubes
|
|
24
24
|
|
25
25
|
write_full
|
26
26
|
|
27
|
-
logger.info "Compiled
|
27
|
+
logger.info "Compiled .kubes/resources files to .kubes/output" if show_compiled_message?
|
28
28
|
end
|
29
29
|
|
30
30
|
def resources
|
@@ -51,7 +51,7 @@ module Kubes
|
|
51
51
|
IO.write(dest, content)
|
52
52
|
end
|
53
53
|
|
54
|
-
logger.debug "
|
54
|
+
logger.debug "Written #{pretty(dest)}"
|
55
55
|
end
|
56
56
|
|
57
57
|
def write_full
|
@@ -62,7 +62,7 @@ module Kubes
|
|
62
62
|
path = "#{Kubes.root}/.kubes/tmp/full.yaml" # write to tmp instead of output so it doesnt interfere with kubes get
|
63
63
|
FileUtils.mkdir_p(File.dirname(path))
|
64
64
|
IO.write(path, content)
|
65
|
-
logger.debug "
|
65
|
+
logger.debug "Written #{pretty(path)}"
|
66
66
|
end
|
67
67
|
|
68
68
|
def show_compiled_message?
|
data/lib/kubes/config.rb
CHANGED
@@ -33,6 +33,9 @@ module Kubes
|
|
33
33
|
config.repo = nil # expected to be set by .kubes/config.rb
|
34
34
|
config.repo_auto_auth = true
|
35
35
|
|
36
|
+
config.layering = ActiveSupport::OrderedOptions.new
|
37
|
+
config.layering.show = ENV['KUBES_LAYERING_SHOW'] || false
|
38
|
+
|
36
39
|
config.logger = Logger.new($stderr)
|
37
40
|
config.logger.level = ENV['KUBES_LOG_LEVEL'] || :info
|
38
41
|
|
data/lib/kubes/util/sh.rb
CHANGED
@@ -24,7 +24,7 @@ module Kubes::Util
|
|
24
24
|
logger.info "=> #{command}" if show_command
|
25
25
|
success = system(env, command)
|
26
26
|
unless success
|
27
|
-
logger.error "ERROR: running #{command}".color(:red)
|
27
|
+
logger.error "ERROR: running #{command}".color(:red) if exit_on_fail
|
28
28
|
exit $?.exitstatus if exit_on_fail
|
29
29
|
end
|
30
30
|
success
|
data/lib/kubes/version.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
Kubes.configure do |config|
|
2
2
|
config.repo = "<%= @options[:repo] %>"
|
3
|
-
config.logger.level = "
|
3
|
+
# config.logger.level = "debug"
|
4
|
+
# config.layering.show = true
|
4
5
|
# auto-switching
|
5
6
|
# config.kubectl.context = "dev-cluster"
|
6
7
|
# config.kubectl.context_keep = true # keep context after switching
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -367,6 +367,7 @@ files:
|
|
367
367
|
- docs/_docs/intro/ordering/custom.md
|
368
368
|
- docs/_docs/intro/structure.md
|
369
369
|
- docs/_docs/layering.md
|
370
|
+
- docs/_docs/layering/debug.md
|
370
371
|
- docs/_docs/layering/dsl.md
|
371
372
|
- docs/_docs/layering/extra.md
|
372
373
|
- docs/_docs/layering/merge-dsl.md
|
@@ -722,6 +723,7 @@ files:
|
|
722
723
|
- lib/kubes/logging.rb
|
723
724
|
- lib/kubes/plugin.rb
|
724
725
|
- lib/kubes/util/consider.rb
|
726
|
+
- lib/kubes/util/pretty.rb
|
725
727
|
- lib/kubes/util/sh.rb
|
726
728
|
- lib/kubes/util/sure.rb
|
727
729
|
- lib/kubes/util/time.rb
|