kubes 0.8.7 → 0.8.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2acdb3453d1240b7be08aa022731c41ffa227a9a0ca5e5fdf28774f2a9be6c6
4
- data.tar.gz: 418fcd60375f6379c14e32432c8b202562ae87477dd93480987ef02a43e1d7a8
3
+ metadata.gz: 306b63f7f97138b489a5877a2726499b8329c805787e282f1e856ad76226ebec
4
+ data.tar.gz: 1943fd0f6e702d8bf285ba201d89da359f8425988a542a408f6635b70e57d3c7
5
5
  SHA512:
6
- metadata.gz: 471c5ef845fc8b904cfb3299ec42a08e68a5fb801639af39e683d379e9de20f5b0c89394d73bae34dc6cc06d0292ec5fd4216f7660c76bea2ba785048c5e86bb
7
- data.tar.gz: a41933ec8b9f216fffd3022856e36cdf9e0555bdb460562e61525a2829e34546f50cfb01fc8ebe058bf4e6aeba49b22d5b256881c21ae92b6e94891a16e0496b
6
+ metadata.gz: 32d2554b904d987cf40271cf1f924fc8c5aae7c309395c70bd0cef6ccd2b88fee401e34ad3b9f99f4c10056530b456be0713e740bb58972775b5e9e957b5e2c8
7
+ data.tar.gz: 7deec002773c177e201d5b8712a350cf087349260ecbc8945292325c76df4e9c4382be8ba9070a23493838c752281b204650538dcd71d0b71c8a6214496e7f63
@@ -0,0 +1 @@
1
+ github: boltops-tools
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.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
+
10
+ ## [0.8.9] - 2022-08-11
11
+ - [#64](https://github.com/boltops-tools/kubes/pull/64) extra variable layering
12
+ - add extra layering docs
13
+
14
+ ## [0.8.8] - 2022-08-11
15
+ - add Kubes.extra method
16
+ - update managed_certificate and ingress apiVersion
17
+
6
18
  ## [0.8.7] - 2022-06-21
7
19
  - [#63](https://github.com/boltops-tools/kubes/pull/63) remove kubes meta from yaml
8
20
  - adjust app layer. keep old layer also for now though
@@ -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" %}
@@ -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,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,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
- * [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 %})
7
+ {% assign docs = site.docs | where: "categories","layering" | sort: "order" %}
8
+ {% for doc in docs -%}
9
+ * [{{ doc.title }}]({{ doc.url }})
10
+ {% endfor %}
@@ -123,11 +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>
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|
@@ -78,8 +87,23 @@ module Kubes::Compiler::Shared
78
87
 
79
88
  layers.each do |layer|
80
89
  path = "#{Kubes.root}/.kubes/variables/#{layer}"
90
+ show_variable_layer_path(path)
81
91
  evaluate_file(path)
82
92
  end
83
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
84
108
  end
85
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
 
data/lib/kubes/core.rb CHANGED
@@ -3,11 +3,15 @@ module Kubes
3
3
  extend Memoist
4
4
 
5
5
  def app
6
- ENV['KUBES_APP']
6
+ ENV['KUBES_APP'] unless ENV['KUBES_APP'].blank?
7
7
  end
8
8
 
9
9
  def env
10
- ENV['KUBES_ENV'] || "dev"
10
+ ENV['KUBES_ENV'].blank? ? "dev" : ENV['KUBES_ENV']
11
+ end
12
+
13
+ def extra
14
+ ENV['KUBES_EXTRA'] unless ENV['KUBES_EXTRA'].blank?
11
15
  end
12
16
 
13
17
  def root
@@ -36,7 +40,7 @@ module Kubes
36
40
  def check_project!
37
41
  return if File.exist?("#{Kubes.root}/.kubes/config.rb")
38
42
  logger.error "ERROR: It doesnt look like this is a kubes project. Are you sure you are in a kubes project?".color(:red)
39
- ENV['TS_TEST'] ? raise : exit(1)
43
+ ENV['KUBES_TEST'] ? raise : exit(1)
40
44
  end
41
45
 
42
46
  # wrapper to ensure we use the same deeper_merge options everywhere
@@ -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.7"
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
@@ -1,12 +1,10 @@
1
- apiVersion: networking.k8s.io/v1beta1
1
+ apiVersion: networking.k8s.io/v1
2
2
  kind: Ingress
3
3
  metadata:
4
4
  name: <%= role %>
5
5
  spec:
6
- rules:
7
- - http:
8
- paths:
9
- - path: "/*"
10
- backend:
11
- serviceName: <%= role %>
12
- servicePort: 80
6
+ defaultBackend:
7
+ service:
8
+ name: web
9
+ port:
10
+ number: 80
@@ -1,7 +1,9 @@
1
- apiVersion: networking.gke.io/v1beta2
1
+ # Docs: https://cloud.google.com/kubernetes-engine/docs/how-to/managed-certs#setting_up_a_google-managed_certificate
2
+ # https://kubes.guru/docs/dsl/resources/managed_certificate/
3
+ apiVersion: networking.gke.io/v1
2
4
  kind: ManagedCertificate
3
5
  metadata:
4
- name: cert1
6
+ name: managed-cert
5
7
  spec:
6
8
  domains:
7
- - cert1.example.com
9
+ - subdomain1.example.com
@@ -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.7
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-06-21 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
@@ -258,6 +258,7 @@ extra_rdoc_files: []
258
258
  files:
259
259
  - ".dockerignore"
260
260
  - ".gcloudignore"
261
+ - ".github/FUNDING.yml"
261
262
  - ".github/ISSUE_TEMPLATE.md"
262
263
  - ".github/ISSUE_TEMPLATE/bug_report.md"
263
264
  - ".github/ISSUE_TEMPLATE/documentation.md"
@@ -366,7 +367,9 @@ files:
366
367
  - docs/_docs/intro/ordering/custom.md
367
368
  - docs/_docs/intro/structure.md
368
369
  - docs/_docs/layering.md
370
+ - docs/_docs/layering/debugging.md
369
371
  - docs/_docs/layering/dsl.md
372
+ - docs/_docs/layering/extra.md
370
373
  - docs/_docs/layering/merge-dsl.md
371
374
  - docs/_docs/layering/merge-options.md
372
375
  - docs/_docs/layering/mix.md
@@ -720,6 +723,7 @@ files:
720
723
  - lib/kubes/logging.rb
721
724
  - lib/kubes/plugin.rb
722
725
  - lib/kubes/util/consider.rb
726
+ - lib/kubes/util/pretty.rb
723
727
  - lib/kubes/util/sh.rb
724
728
  - lib/kubes/util/sure.rb
725
729
  - lib/kubes/util/time.rb