kubes 0.7.6 → 0.7.7

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: e73d57fba41a00e9ace349a4b3d9da7815e52a5025fcda97b64cfc185797ba35
4
- data.tar.gz: a6114d33d48893ed2f748b0720aaf7dca8f71a75b4b3e3f4ae3f690680b35f26
3
+ metadata.gz: 4f8112935cf2c796869c81fb0ede6a5b6b9589ba5daf981aab7ca2a806217e4c
4
+ data.tar.gz: d84869a02096b266edc9e0c51ea2ec344f97f96afb0ce1dcc74d80ef71cb7567
5
5
  SHA512:
6
- metadata.gz: e28f97ff9b675adbce4066afbbde6fa4c853f2172e430659db25b8865409d5fb19aace0a464c809a95ddee6152e8f389cd9e43c6dc9696c9297fd2b8465c5c77
7
- data.tar.gz: 42c6780d303119bb42d65075043bcaaf38fd1eec20a8b4448695a598ae22e7ab1b28f6d3920116c7cd9c76630be4d332871833f194383e1c05537ac3bab00a73
6
+ metadata.gz: 11e5302088c91d06c41c3f1b3c6774b2361d7a1537d9e9c609152b2de215b35d0dd1f792d54788a557a6d39dcc3816aa7caaa1191c888aed135b2290d72d6355
7
+ data.tar.gz: 0a47dee57d4ccb4ccd1e9877830328d60ba1a0a49b2d3592a7994f63cbe01cb84ee29ca646d057662a1dba0fafb94bc61c0a4ee84547ed951942d9c35cecf2ed
data/CHANGELOG.md CHANGED
@@ -3,6 +3,11 @@
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.7.7] - 2021-10-21
7
+ - [#51](https://github.com/boltops-tools/kubes/pull/51) add hash checksum for tls secretName
8
+ - [#52](https://github.com/boltops-tools/kubes/pull/52) add role all layer to pre_layers
9
+ - [#53](https://github.com/boltops-tools/kubes/pull/53) Merger options
10
+
6
11
  ## [0.7.6] - 2021-10-12
7
12
  - remove init yaml templates, removed duplication
8
13
  - write full.yaml to .kubes/tmp instead
@@ -20,3 +20,4 @@ repo_auto_auth | Whether or not to try to auth authorize docker repo registry if
20
20
  skip | List of resources to skip. Can also be set with the `KUBES_SKIP` env var. `KUBES_SKIP` should be a list of strings separated by spaces. It adds onto the `config.skip` option. | []
21
21
  state.path | Where to store the state file with the last build Docker image. | .kubes/state/KUBES_ENV/data.json
22
22
  suffix_hash | Whether or not to append suffix hash to ConfigMap and Secret | true
23
+ merger.options | Merger options that control how Hashes are merged. More info: [Merger Options]({% link _docs/layering/merge-options.md %}) | `{overwrite_arrays: true}`
data/docs/_docs/dsl.md CHANGED
@@ -63,4 +63,4 @@ In general:
63
63
 
64
64
  ## Merge Behavior
65
65
 
66
- Generally, the merge should behave as expected. For example, map or Hash fields are merged together from multiple layers. Strings are simply replaced. See more details at [Layering Merge Behavior]({% link _docs/layering/merge.md %})
66
+ Generally, the merge should behave as expected. For example, map or Hash fields are merged together from multiple layers. Strings are simply replaced. See more details at [Layering Merge Behavior]({% link _docs/layering/merge-dsl.md %})
@@ -34,10 +34,10 @@ Here's what a .kubes folder structure can look like this:
34
34
 
35
35
  Name | Description
36
36
  --- | ---
37
- base | The base folder is processed first and can be used to define common fields and resources. Learn more on the [Layering Docs]({% link _docs/layering.md %}).
38
37
  config | The config folder can be used to configure behavior of Kubes. The [docker]({% link _docs/config/docker.md %}) config is used to customize the docker command. The [env]({% link _docs/config/env.md %}) config is used to override `config.rb` settings on a `KUBES_ENV` basis. The [kubectl]({% link _docs/config/kubectl.md %}) config is used to customize the kubectl command.
39
38
  config.rb | The main thing to configure here is the repo to push the docker image to.
40
39
  output | Where kubes builds and writes the Kubernetes YAML to.
41
40
  resources | Where you define your Kubernetes resources.
42
- shared | The shared folder is where you can put shared resources. This folder gets applied first. More info: [Ordering]({% link _docs/intro/ordering.md %}).
41
+ resources/base | The base folder is processed first and can be used to define common fields and resources. Learn more on the [Layering Docs]({% link _docs/layering.md %}).
42
+ resources/shared | The shared folder is where you can put shared resources. This folder gets applied first. More info: [Ordering]({% link _docs/intro/ordering.md %}).
43
43
  state | Temporary state info that stores the built Docker image name.
File without changes
@@ -0,0 +1,76 @@
1
+ ---
2
+ title: Merge Options
3
+ ---
4
+
5
+ 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 %}).
6
+
7
+ The default merge options is:
8
+
9
+ {overwrite_arrays: true}
10
+
11
+ You can control the merge behavior by setting:
12
+
13
+ .kubes/config.rb
14
+
15
+ ```ruby
16
+ Kubes.configure do |config|
17
+ # ...
18
+ config.merger.options = {overwrite_arrays: false}
19
+ end
20
+ ```
21
+
22
+ See the [danielsdeleo/deep_merge](https://github.com/danielsdeleo/deep_merge) docs for the different options.
23
+
24
+ ## Example of overwrite_arrays false
25
+
26
+ An example of where you might want to use `{overwrite_arrays: false}` is if you are using YAML and want a base sidecar container in all of your deployments.
27
+
28
+ .kubes/resources/base/deployment.yaml
29
+
30
+ ```yaml
31
+ spec:
32
+ template:
33
+ spec:
34
+ containers:
35
+ - name: sidecar
36
+ image: sidecar-image
37
+ ```
38
+
39
+ .kubes/resources/web/deployment.yaml
40
+
41
+ ```yaml
42
+ spec:
43
+ template:
44
+ metadata:
45
+ labels:
46
+ role: web
47
+ spec:
48
+ containers:
49
+ - name: web
50
+ image: <%= docker_image %>
51
+ ```
52
+
53
+ Produces:
54
+
55
+ ```yaml
56
+ # ...
57
+ spec:
58
+ template:
59
+ metadata:
60
+ labels:
61
+ role: web
62
+ spec:
63
+ containers:
64
+ - name: sidecar
65
+ image: sidecar-image
66
+ - name: web
67
+ image: gcr.io/boltops-learn/demo:kubes-2021-10-21T18-06-48
68
+ # ...
69
+ ```
70
+
71
+ However, using this merge behavior will also add additional ports if you are assigning a `targetPort` in the DSL. See:
72
+
73
+ * [DSL in service creates always default port 80 #45](https://github.com/boltops-tools/kubes/issues/45)
74
+ * [use deep_merge overwrite_arrays option #48](https://github.com/boltops-tools/kubes/pull/48)
75
+
76
+ Will welcome PRs for improvements.
@@ -7,4 +7,4 @@ Kubes supports layering files together so you can use the same Kubernetes files
7
7
  * [YAML Layering]({% link _docs/layering/yaml.md %})
8
8
  * [DSL Layering]({% link _docs/layering/dsl.md %})
9
9
  * [Mix Layering]({% link _docs/layering/mix.md %})
10
- * [Merge Behavior]({% link _docs/layering/merge.md %})
10
+ * [Merge Behavior]({% link _docs/layering/merge-dsl.md %})
@@ -11,6 +11,7 @@ Here's an example structure, so we can understand how layering works.
11
11
  ├── clock
12
12
  │ └── deployment.{{ include.ext }}
13
13
  └── web
14
+ ├── all.{{ include.ext }}
14
15
  ├── deployment
15
16
  │ ├── dev.{{ include.ext }}
16
17
  │ └── prod.{{ include.ext }}
@@ -34,16 +35,17 @@ Notes
34
35
 
35
36
  Here's a table showing the the full layering.
36
37
 
37
- Folder/Pattern | Example
38
- -------------------|--------------------------------------------
39
- base/all.{{ include.ext }} | base/all.{{ include.ext }}
40
- base/all/ENV.{{ include.ext }} | base/all/dev.{{ include.ext }}
41
- base/KIND.{{ include.ext }} | base/deployment.{{ include.ext }}
42
- base/KIND/base.{{ include.ext }} | base/deployment/base.{{ include.ext }}
43
- base/KIND/ENV.{{ include.ext }} | base/deployment/dev.{{ include.ext }}
44
- ROLE/KIND.{{ include.ext }} | web/deployment.{{ include.ext }}
45
- ROLE/KIND/base.{{ include.ext }} | web/deployment/base.{{ include.ext }}
46
- ROLE/KIND/ENV.{{ include.ext }} | web/deployment/dev.{{ include.ext }}
38
+ Type | Folder/Pattern | Example
39
+ ---|---|---
40
+ pre | base/all.{{ include.ext }} | base/all.{{ include.ext }}
41
+ pre | base/all/ENV.{{ include.ext }} | base/all/dev.{{ include.ext }}
42
+ pre | base/KIND.{{ include.ext }} | base/deployment.{{ include.ext }}
43
+ pre | base/KIND/base.{{ include.ext }} | base/deployment/base.{{ include.ext }}
44
+ pre | base/KIND/ENV.{{ include.ext }} | base/deployment/dev.{{ include.ext }}
45
+ pre | ROLE/all.{{ include.ext }} | web/all.{{ include.ext }}
46
+ main | ROLE/KIND.{{ include.ext }} | web/deployment.{{ include.ext }}
47
+ post | ROLE/KIND/base.{{ include.ext }} | web/deployment/base.{{ include.ext }}
48
+ post | ROLE/KIND/ENV.{{ include.ext }} | web/deployment/dev.{{ include.ext }}
47
49
 
48
50
  ## Real-World Uses
49
51
 
@@ -97,7 +97,8 @@
97
97
  <li><a href="{% link _docs/layering/yaml.md %}">YAML</a></li>
98
98
  <li><a href="{% link _docs/layering/dsl.md %}">DSL</a></li>
99
99
  <li><a href="{% link _docs/layering/mix.md %}">Mix</a></li>
100
- <li><a href="{% link _docs/layering/merge.md %}">Merge Behavior</a></li>
100
+ <li><a href="{% link _docs/layering/merge-dsl.md %}">Merge DSL</a></li>
101
+ <li><a href="{% link _docs/layering/merge-options.md %}">Merge Options</a></li>
101
102
  </ul>
102
103
  </li>
103
104
  <li><a href="{% link _docs/dsl.md %}">DSL</a>
@@ -47,6 +47,7 @@ class Kubes::Compiler::Decorator::Hashable
47
47
  'secretRef' => 'name',
48
48
  'secretKeyRef' => 'name',
49
49
  'secret' => 'secretName',
50
+ 'tls' => 'secretName',
50
51
  }
51
52
  end
52
53
  end
@@ -6,29 +6,21 @@ class Kubes::Compiler
6
6
  ext = File.extname(@path)
7
7
  kind = File.basename(@path).sub(ext,'') # IE: deployment
8
8
  kind = kind.pluralize if @block_form
9
+ role = @path.split('/')[-2] # .kubes/resources/web/deployment.yaml
9
10
  layers = [
10
- "all",
11
- "all/#{Kubes.env}",
12
- "#{kind}",
13
- "#{kind}/#{Kubes.env}",
11
+ "base/all",
12
+ "base/all/#{Kubes.env}",
13
+ "base/#{kind}",
14
+ "base/#{kind}/#{Kubes.env}",
15
+ "#{role}/all",
14
16
  ]
15
17
  layers = add_exts(layers)
16
18
  layers.map! do |layer|
17
- "#{Kubes.root}/.kubes/resources/base/#{layer}"
19
+ "#{Kubes.root}/.kubes/resources/#{layer}"
18
20
  end
19
21
  layers.select { |layer| File.exist?(layer) }
20
22
  end
21
23
 
22
- def add_exts(layers)
23
- layers.map do |layer|
24
- [
25
- "#{layer}.rb",
26
- "#{layer}.yaml",
27
- "#{layer}.yml",
28
- ]
29
- end.flatten
30
- end
31
-
32
24
  def post_layers
33
25
  return [] if Kubes.kustomize?
34
26
 
@@ -45,5 +37,15 @@ class Kubes::Compiler
45
37
  end
46
38
  layers.select { |layer| File.exist?(layer) }
47
39
  end
40
+
41
+ def add_exts(*layers)
42
+ layers.flatten.map do |layer|
43
+ [
44
+ "#{layer}.rb",
45
+ "#{layer}.yaml",
46
+ "#{layer}.yml",
47
+ ]
48
+ end.flatten
49
+ end
48
50
  end
49
51
  end
data/lib/kubes/config.rb CHANGED
@@ -43,6 +43,9 @@ module Kubes
43
43
 
44
44
  config.suffix_hash = true # append suffix hash to ConfigMap and Secret
45
45
 
46
+ config.merger = ActiveSupport::OrderedOptions.new
47
+ config.merger.options = {overwrite_arrays: true}
48
+
46
49
  config
47
50
  end
48
51
 
data/lib/kubes/core.rb CHANGED
@@ -37,7 +37,7 @@ module Kubes
37
37
 
38
38
  # wrapper to ensure we use the same deeper_merge options everywhere
39
39
  def deep_merge!(a, b)
40
- a.deeper_merge!(b, overwrite_arrays: true)
40
+ a.deeper_merge!(b, config.merger.options)
41
41
  a
42
42
  end
43
43
  end
@@ -3,8 +3,8 @@ module Kubes::Util
3
3
  def consider?(path)
4
4
  File.file?(path) &&
5
5
  !path.include?('/resources/base') &&
6
- !path.include?('/base.yaml') &&
7
- !path.include?('/base.yml')
6
+ !path.include?('/base.') &&
7
+ !path.include?('/all.')
8
8
  end
9
9
  end
10
10
  end
data/lib/kubes/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kubes
2
- VERSION = "0.7.6"
2
+ VERSION = "0.7.7"
3
3
  end
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.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-12 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -336,7 +336,8 @@ files:
336
336
  - docs/_docs/intro/structure.md
337
337
  - docs/_docs/layering.md
338
338
  - docs/_docs/layering/dsl.md
339
- - docs/_docs/layering/merge.md
339
+ - docs/_docs/layering/merge-dsl.md
340
+ - docs/_docs/layering/merge-options.md
340
341
  - docs/_docs/layering/mix.md
341
342
  - docs/_docs/layering/yaml.md
342
343
  - docs/_docs/learn/dsl.md