kubes 0.8.9 → 0.8.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1089172c4489c77f34abd1cc5df408e11467950f40ae67ee062377f078c131d1
4
- data.tar.gz: 1c29e074651e78963aa1fbc83314e49b6da006c7902056c2ef108dd91302b8a7
3
+ metadata.gz: 306b63f7f97138b489a5877a2726499b8329c805787e282f1e856ad76226ebec
4
+ data.tar.gz: 1943fd0f6e702d8bf285ba201d89da359f8425988a542a408f6635b70e57d3c7
5
5
  SHA512:
6
- metadata.gz: ac9080b9f30461b48d4d4fbf5e6a9ca6be2a53385a0cde1b649e6da26c265ddb7adb7f3c66714ad179ebac3f3ae3ebd9ea112bc5a0f5e65beab7d51d30f9574d
7
- data.tar.gz: c6424d462ba9c7b834fcf1944fd75275ae6fa8b6abf7ea7b29fa9575fa6f5ae0853529ca10b32e1eeff11ac094e2ee920008c326936e2c1bd5e153cb8dc3f915
6
+ metadata.gz: 32d2554b904d987cf40271cf1f924fc8c5aae7c309395c70bd0cef6ccd2b88fee401e34ad3b9f99f4c10056530b456be0713e740bb58972775b5e9e957b5e2c8
7
+ data.tar.gz: 7deec002773c177e201d5b8712a350cf087349260ecbc8945292325c76df4e9c4382be8ba9070a23493838c752281b204650538dcd71d0b71c8a6214496e7f63
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
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.8.10] - 2022-08-18
7
+ - [#65](https://github.com/boltops-tools/kubes/pull/65) show variables layers support
8
+ - improve new secret generator
9
+
6
10
  ## [0.8.9] - 2022-08-11
7
11
  - [#64](https://github.com/boltops-tools/kubes/pull/64) extra variable layering
8
12
  - add extra layering docs
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: "Debugging 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 recommend 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
+ ...
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  title: DSL Layering
3
+ nav_text: DSL
4
+ category: layering
5
+ order: 2
3
6
  ---
4
7
 
5
8
  {% include layering/layers.md ext="rb" %}
@@ -1,5 +1,7 @@
1
1
  ---
2
2
  title: Extra Layering
3
+ category: layering
4
+ order: 8
3
5
  ---
4
6
 
5
7
  Setting KUBES_EXTRA will process extra layers.
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  title: DSL Merge Behavior
3
+ nav_text: DSL Merge
4
+ category: layering
5
+ order: 4
3
6
  ---
4
7
 
5
8
  Generally, the merge should behave as expected. For example, map or Hash fields are merged together from multiple layers. Strings are simply replaced.
@@ -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 %}).
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  title: Mixed Layering
3
+ nav_text: Mix and Match
4
+ category: layering
5
+ order: 3
3
6
  ---
4
7
 
5
8
  You can mix and match the YAML and DSL forms together and layering still works.
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  title: YAML Layering
3
+ nav_text: YAML
4
+ category: layering
5
+ order: 1
3
6
  ---
4
7
 
5
8
  {% include layering/layers.md ext="yaml" %}
@@ -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
- * [YAML Layering]({% link _docs/layering/yaml.md %})
8
- * [DSL Layering]({% link _docs/layering/dsl.md %})
9
- * [Mix Layering]({% link _docs/layering/mix.md %})
10
- * [Merge Behavior]({% link _docs/layering/merge-dsl.md %})
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 %}
@@ -123,12 +123,10 @@
123
123
  </li>
124
124
  <li><a href="{% link _docs/layering.md %}">Layering</a>
125
125
  <ul>
126
- <li><a href="{% link _docs/layering/yaml.md %}">YAML</a></li>
127
- <li><a href="{% link _docs/layering/dsl.md %}">DSL</a></li>
128
- <li><a href="{% link _docs/layering/mix.md %}">Mix</a></li>
129
- <li><a href="{% link _docs/layering/merge-dsl.md %}">Merge DSL</a></li>
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|
@@ -82,8 +87,23 @@ module Kubes::Compiler::Shared
82
87
 
83
88
  layers.each do |layer|
84
89
  path = "#{Kubes.root}/.kubes/variables/#{layer}"
90
+ show_variable_layer_path(path)
85
91
  evaluate_file(path)
86
92
  end
87
93
  end
94
+
95
+ @@shown = {}
96
+ def show_variable_layer_path(path)
97
+ # Examples:
98
+ # .kubes/resources/web/deployment.yaml
99
+ # .kubes/resources/shared/namespace.yaml
100
+ main_path = @path # main path is main resource file
101
+ show_once = !@@shown.dig(main_path, path)
102
+ if ENV['KUBES_LAYERING_SHOW_ALL'] || (Kubes.config.layering.show && show_once && File.exist?(path))
103
+ logger.info " #{pretty_path(path)}"
104
+ @@shown[main_path] ||= {}
105
+ @@shown[main_path][path] = true
106
+ end
107
+ end
88
108
  end
89
109
  end
@@ -4,6 +4,7 @@ class Kubes::Compiler::Strategy
4
4
  include Kubes::Compiler::Util::Normalize
5
5
  include Kubes::Compiler::Util::SaveFile
6
6
  include Kubes::Logging
7
+ include Kubes::Util::Pretty
7
8
 
8
9
  def initialize(options={})
9
10
  @options = options
@@ -1,6 +1,7 @@
1
1
  class Kubes::Compiler::Strategy
2
2
  class Dispatcher < Base
3
3
  def dispatch
4
+ logger.info "Compiling #{pretty_path(@path)}" 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|
@@ -16,6 +17,7 @@ class Kubes::Compiler::Strategy
16
17
  klass = dsl_class(path) # IE: Kubes::Compiler::Dsl::Syntax::Deployment or Kubes::Compiler::Dsl::Core::Blocks
17
18
  klass.new(@options.merge(path: path, data: @data)).run
18
19
  else
20
+ logger.info "Rendering #{pretty_path(path)}" if ENV['KUBES_LAYERING_SHOW_ALL']
19
21
  Erb.new(@options.merge(data: @data)).render_result(path)
20
22
  end
21
23
  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
 
@@ -0,0 +1,7 @@
1
+ module Kubes::Util
2
+ module Pretty
3
+ def pretty_path(path)
4
+ path.sub("#{Kubes.root}/",'')
5
+ end
6
+ end
7
+ end
data/lib/kubes/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kubes
2
- VERSION = "0.8.9"
2
+ VERSION = "0.8.10"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  Kubes.configure do |config|
2
2
  config.repo = "<%= @options[:repo] %>"
3
- config.logger.level = "info"
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
@@ -5,5 +5,5 @@ metadata:
5
5
  labels:
6
6
  app: <%= app %>
7
7
  data:
8
- username: dXNlcg==
9
- password: cGFzcw==
8
+ username: <%%= base64("user") %>
9
+ password: <%%= base64("pass") %>
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.8.9
4
+ version: 0.8.10
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 00:00:00.000000000 Z
11
+ date: 2022-08-18 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/debugging.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