kubes 0.8.8 → 0.9.0
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 +4 -4
- data/CHANGELOG.md +12 -0
- data/docs/_docs/layering/debug.md +62 -0
- data/docs/_docs/layering/dsl.md +3 -0
- data/docs/_docs/layering/extra.md +18 -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 -4
- data/docs/_includes/sidebar.html +4 -5
- data/lib/kubes/compiler/shared/runtime_helpers.rb +35 -2
- data/lib/kubes/compiler/strategy/base.rb +1 -0
- data/lib/kubes/compiler/strategy/dispatcher.rb +11 -0
- 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 +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db6959c3513133da9d5340dc8c332e15f86be47e5f72d47188243fafb21b3bd0
|
4
|
+
data.tar.gz: 94762322cb38b47c1d4167060545012dd6416515628801efdd969fc8dd189b91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a506b81df303fd915146596f792fcbd6b0ede5b93c81d6bcd75f0fa3123a47129086969decef3d44b273e6740d518facf91053c8f10e61ad3de6698c673a0e9
|
7
|
+
data.tar.gz: f2ddb1238b542b0279069a5b7417d4ed458384729cdd3859511b55222161c6443131ade97534f91fe19df9f20fae3074943a40120a3470bbf91142cd8d419a89
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,18 @@
|
|
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.0] - 2022-08-24
|
7
|
+
- [#66](https://github.com/boltops-tools/kubes/pull/66) show layering improvements: show resource layers also
|
8
|
+
- only show error if exit_on_fail
|
9
|
+
|
10
|
+
## [0.8.10] - 2022-08-18
|
11
|
+
- [#65](https://github.com/boltops-tools/kubes/pull/65) show variables layers support
|
12
|
+
- improve new secret generator
|
13
|
+
|
14
|
+
## [0.8.9] - 2022-08-11
|
15
|
+
- [#64](https://github.com/boltops-tools/kubes/pull/64) extra variable layering
|
16
|
+
- add extra layering docs
|
17
|
+
|
6
18
|
## [0.8.8] - 2022-08-11
|
7
19
|
- add Kubes.extra method
|
8
20
|
- update managed_certificate and ingress apiVersion
|
@@ -0,0 +1,62 @@
|
|
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 turning a config to show the **found** layers. Currently, only variables layering is shown.
|
12
|
+
|
13
|
+
.kubes/config.rb
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
Kubes.configure do |config|
|
17
|
+
config.layering.show = true
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
This will show the **found** layers.
|
22
|
+
|
23
|
+
$ kubes compile
|
24
|
+
Compiling .kubes/resources/shared/namespace.yaml
|
25
|
+
.kubes/variables/base.rb
|
26
|
+
.kubes/variables/dev.rb
|
27
|
+
Compiling .kubes/resources/web/deployment.yaml
|
28
|
+
.kubes/variables/base.rb
|
29
|
+
.kubes/variables/dev.rb
|
30
|
+
Compiling .kubes/resources/web/service.yaml
|
31
|
+
.kubes/variables/base.rb
|
32
|
+
.kubes/variables/dev.rb
|
33
|
+
|
34
|
+
## All Considered Layers
|
35
|
+
|
36
|
+
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.
|
37
|
+
|
38
|
+
$ export KUBES_LAYERING_SHOW_ALL=1
|
39
|
+
Compiling .kubes/resources/web/deployment.yaml
|
40
|
+
Rendering .kubes/resources/web/deployment.yaml
|
41
|
+
.kubes/variables/base.rb
|
42
|
+
.kubes/variables/dev.rb
|
43
|
+
.kubes/variables/base/all.rb
|
44
|
+
.kubes/variables/base/all/dev.rb
|
45
|
+
.kubes/variables/base/deployment.rb
|
46
|
+
.kubes/variables/base/deployment/base.rb
|
47
|
+
.kubes/variables/base/deployment/dev.rb
|
48
|
+
.kubes/variables/web/deployment.rb
|
49
|
+
.kubes/variables/web/deployment/base.rb
|
50
|
+
.kubes/variables/web/deployment/dev.rb
|
51
|
+
Rendering .kubes/resources/base/all.yaml
|
52
|
+
.kubes/variables/base.rb
|
53
|
+
.kubes/variables/dev.rb
|
54
|
+
.kubes/variables/base/all.rb
|
55
|
+
.kubes/variables/base/all/dev.rb
|
56
|
+
.kubes/variables/base/deployment.rb
|
57
|
+
.kubes/variables/base/deployment/base.rb
|
58
|
+
.kubes/variables/base/deployment/dev.rb
|
59
|
+
.kubes/variables/web/deployment.rb
|
60
|
+
.kubes/variables/web/deployment/base.rb
|
61
|
+
.kubes/variables/web/deployment/dev.rb
|
62
|
+
...
|
data/docs/_docs/layering/dsl.md
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
title: Extra Layering
|
3
|
+
category: layering
|
4
|
+
order: 8
|
5
|
+
---
|
6
|
+
|
7
|
+
Setting KUBES_EXTRA will process extra layers.
|
8
|
+
|
9
|
+
## Variables
|
10
|
+
|
11
|
+
Example
|
12
|
+
|
13
|
+
KUBES_EXTRA=2 kubes deploy
|
14
|
+
|
15
|
+
Will process:
|
16
|
+
|
17
|
+
.kubes/variables/dev.rb
|
18
|
+
.kubes/variables/dev-2.rb
|
@@ -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,7 +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
|
-
|
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,11 +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>
|
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 %}
|
131
130
|
</ul>
|
132
131
|
</li>
|
133
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
|
@@ -59,15 +60,23 @@ module Kubes::Compiler::Shared
|
|
59
60
|
layers = [
|
60
61
|
"base.rb",
|
61
62
|
"#{Kubes.env}.rb",
|
63
|
+
"#{Kubes.env}-#{Kubes.extra}.rb",
|
62
64
|
"base/all.rb",
|
63
65
|
"base/all/#{Kubes.env}.rb",
|
66
|
+
"base/all/#{Kubes.env}-#{Kubes.extra}.rb",
|
64
67
|
"base/#{kind}.rb",
|
65
68
|
"base/#{kind}/base.rb",
|
66
69
|
"base/#{kind}/#{Kubes.env}.rb",
|
70
|
+
"base/#{kind}/#{Kubes.env}-#{Kubes.extra}.rb",
|
67
71
|
"#{role}/#{kind}.rb",
|
68
72
|
"#{role}/#{kind}/base.rb",
|
69
73
|
"#{role}/#{kind}/#{Kubes.env}.rb",
|
74
|
+
"#{role}/#{kind}/#{Kubes.env}-#{Kubes.extra}.rb",
|
70
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
|
+
|
71
80
|
if Kubes.app
|
72
81
|
app_layers = ["#{Kubes.app}.rb"]
|
73
82
|
app_layers += layers.map do |path|
|
@@ -76,10 +85,34 @@ module Kubes::Compiler::Shared
|
|
76
85
|
layers += app_layers
|
77
86
|
end
|
78
87
|
|
79
|
-
layers.
|
80
|
-
|
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)
|
81
92
|
evaluate_file(path)
|
82
93
|
end
|
83
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
|
84
117
|
end
|
85
118
|
end
|
@@ -1,6 +1,7 @@
|
|
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|
|
@@ -10,12 +11,22 @@ class Kubes::Compiler::Strategy
|
|
10
11
|
Result.new(@save_file, data)
|
11
12
|
end
|
12
13
|
|
14
|
+
def show_layers
|
15
|
+
logger.info "Compiling #{pretty_path(@path)}"
|
16
|
+
logger.info " Resource layers:"
|
17
|
+
all_layers = pre_layers + [@path] + post_layers
|
18
|
+
all_layers.each do |layer|
|
19
|
+
logger.info " #{pretty_path(layer)}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
13
23
|
# Render via to Erb or one of the DSL syntax classes or Core/Blocks class
|
14
24
|
def render(path)
|
15
25
|
if path.include?('.rb')
|
16
26
|
klass = dsl_class(path) # IE: Kubes::Compiler::Dsl::Syntax::Deployment or Kubes::Compiler::Dsl::Core::Blocks
|
17
27
|
klass.new(@options.merge(path: path, data: @data)).run
|
18
28
|
else
|
29
|
+
logger.info "Rendering #{pretty_path(path)}" if ENV['KUBES_LAYERING_SHOW_RENDERING']
|
19
30
|
Erb.new(@options.merge(data: @data)).render_result(path)
|
20
31
|
end
|
21
32
|
end
|
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.0
|
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,7 +367,9 @@ 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
|
372
|
+
- docs/_docs/layering/extra.md
|
371
373
|
- docs/_docs/layering/merge-dsl.md
|
372
374
|
- docs/_docs/layering/merge-options.md
|
373
375
|
- docs/_docs/layering/mix.md
|
@@ -721,6 +723,7 @@ files:
|
|
721
723
|
- lib/kubes/logging.rb
|
722
724
|
- lib/kubes/plugin.rb
|
723
725
|
- lib/kubes/util/consider.rb
|
726
|
+
- lib/kubes/util/pretty.rb
|
724
727
|
- lib/kubes/util/sh.rb
|
725
728
|
- lib/kubes/util/sure.rb
|
726
729
|
- lib/kubes/util/time.rb
|