kubes 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +4 -4
- data/docs/_docs/dsl/resources.md +1 -1
- data/docs/_docs/dsl.md +2 -2
- data/lib/kubes/compiler/decorator/hashable/field.rb +41 -22
- data/lib/kubes/compiler/decorator/post.rb +12 -12
- data/lib/kubes/version.rb +1 -1
- data/spec/fixtures/decorators/deployment/configMap/volumes-name-first.yaml +14 -0
- data/spec/fixtures/decorators/deployment/configMap/volumes-name-second.yaml +14 -0
- data/spec/fixtures/decorators/ingress/tls.yaml +12 -0
- data/spec/kubes/compiler/decorator/post/deployment_spec.rb +25 -0
- data/spec/kubes/compiler/decorator/post/ingress_spec.rb +22 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55d217f4b05371a806a18151034bf36ff420fbc6724f1367c441d337a3ed71ad
|
4
|
+
data.tar.gz: 31912f0fb17ac8bb91acbc03cbb3cbbcd5f769170535ca7a48ea5dfe61aa0e40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da80f1de9af4f31ae3b449261591979e499a70f29c85bea4aa2e87d2c4efba8c63ef6c09cd71a423e5164ed5f8598062d3ffbcb6cc5fb01855484a29794026d8
|
7
|
+
data.tar.gz: 926c67bb5cdef8be996b8ded90a251f4ef6643ea40aaa1a817ed596d6482dc1cfcecd6f99322730c0a68df5c113e7708b0c1222abdea2e299bcc79779cda2916
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
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.8] - 2021-10-29
|
7
|
+
- [#54](https://github.com/boltops-tools/kubes/pull/54) fix configMap and secret hash when not first element in Array
|
8
|
+
|
6
9
|
## [0.7.7] - 2021-10-21
|
7
10
|
- [#51](https://github.com/boltops-tools/kubes/pull/51) add hash checksum for tls secretName
|
8
11
|
- [#52](https://github.com/boltops-tools/kubes/pull/52) add role all layer to pre_layers
|
data/README.md
CHANGED
@@ -17,8 +17,8 @@ Official Docs Site: [kubes.guru](https://kubes.guru)
|
|
17
17
|
Kubes will:
|
18
18
|
|
19
19
|
1. Build the docker image and push it to repo
|
20
|
-
2. Compile Kubernetes YAML files from YAML/ERB or a DSL
|
21
|
-
3. Deploy via kubectl apply on the compiled Kubernetes YAML files
|
20
|
+
2. Compile Kubernetes YAML files from YAML/ERB or a DSL with built Docker image
|
21
|
+
3. Deploy via `kubectl apply` on the compiled Kubernetes YAML files
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
@@ -42,7 +42,7 @@ Now, use `kubectl` directly in the proper order:
|
|
42
42
|
kubectl apply -f .kubes/output/web/service.yaml
|
43
43
|
kubectl apply -f .kubes/output/web/deployment.yaml
|
44
44
|
|
45
|
-
You can also apply with kubes. This will compile the
|
45
|
+
You can also apply with kubes. This will automatically compile the files also.
|
46
46
|
|
47
47
|
kubes apply
|
48
48
|
|
@@ -50,7 +50,7 @@ The deploy command, does all 3 steps: builds the docker image, compiles the `.ku
|
|
50
50
|
|
51
51
|
kubes deploy
|
52
52
|
|
53
|
-
## Multiple
|
53
|
+
## Multiple Environments
|
54
54
|
|
55
55
|
You can easily create multiple environments with the same YAML configs. Example:
|
56
56
|
|
data/docs/_docs/dsl/resources.md
CHANGED
@@ -6,7 +6,7 @@ Here's a list of the resources supported by the Kubes DSL.
|
|
6
6
|
|
7
7
|
{% assign docs = site.docs | where: "categories","dsl" %}
|
8
8
|
{% for doc in docs -%}
|
9
|
-
* [{{ doc.
|
9
|
+
* [{{ doc.title }}]({{ doc.url }})
|
10
10
|
{% endfor %}
|
11
11
|
|
12
12
|
For resources, that are not supported, you can use the [Generic resource]({% link _docs/dsl/resources/generic.md %}) or use [YAML]({% link _docs/yaml.md %}) instead. You can use a mix of DSL and YAML definitions in the `.kubes/resources` folder.
|
data/docs/_docs/dsl.md
CHANGED
@@ -58,8 +58,8 @@ Notice how `port` and `targetPort` correspond to `spec.ports.port` and `spec.por
|
|
58
58
|
|
59
59
|
In general:
|
60
60
|
|
61
|
-
* The DSL methods behave as reader methods when no arguments are passed to it. IE: `name
|
62
|
-
* The DSL methods behave as writer methods when arguments are passed to it. IE: `name`
|
61
|
+
* The DSL methods behave as reader methods when no arguments are passed to it. IE: `name` returns the value.
|
62
|
+
* The DSL methods behave as writer methods when arguments are passed to it. IE: `name "demo-web"` sets the value.
|
63
63
|
|
64
64
|
## Merge Behavior
|
65
65
|
|
@@ -1,53 +1,72 @@
|
|
1
1
|
class Kubes::Compiler::Decorator::Hashable
|
2
2
|
class Field
|
3
|
-
# item is full
|
3
|
+
# item is full structure
|
4
4
|
#
|
5
|
-
# secretRef:
|
6
|
-
# name: demo-secret
|
5
|
+
# secretRef: <--- wrapper_key
|
6
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
7
7
|
#
|
8
|
+
attr_reader :item # for debugging
|
8
9
|
def initialize(item)
|
9
10
|
@item = item
|
10
11
|
end
|
11
12
|
|
12
13
|
def hashable?
|
13
|
-
x = @item.keys &
|
14
|
+
x = @item.keys & wrapper_map.keys
|
14
15
|
!x.empty?
|
15
16
|
end
|
16
17
|
|
17
18
|
def kind
|
18
|
-
|
19
|
+
wrapper_key =~ /configMap/ ? "ConfigMap" : "Secret"
|
19
20
|
end
|
20
21
|
|
21
|
-
# The key of the hashable value
|
22
|
+
# The target key of the hashable value is that key used for find value to add hash
|
22
23
|
#
|
23
24
|
# envFrom:
|
24
|
-
# - secretRef:
|
25
|
-
# name: demo-secret <---
|
25
|
+
# - secretRef: <--- wrapper_key
|
26
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
26
27
|
#
|
27
|
-
def
|
28
|
-
|
28
|
+
def target_key
|
29
|
+
wrapper_map[wrapper_key]
|
29
30
|
end
|
30
31
|
|
31
32
|
# The wrapper field is nested right above the item with the hashable value.
|
33
|
+
# Simple example:
|
32
34
|
#
|
33
35
|
# envFrom:
|
34
|
-
# - secretRef:
|
35
|
-
# name: demo-secret
|
36
|
+
# - secretRef: <--- wrapper_key
|
37
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
36
38
|
#
|
37
|
-
|
38
|
-
|
39
|
+
# More complex example where there's a configMap.name key also on the same level.
|
40
|
+
#
|
41
|
+
# volumes:
|
42
|
+
# - name: config-map-volume
|
43
|
+
# configMap:
|
44
|
+
# name: demo-config-map
|
45
|
+
#
|
46
|
+
# Note: Wont work for case when there's are 2 matching wrapper_map keys,
|
47
|
+
# but don't think Kubernetes allows 2 matching wrapper_map keys.
|
48
|
+
# Example: This is invalid Kubernetes YAML.
|
49
|
+
#
|
50
|
+
# volumes:
|
51
|
+
# - name: config-map-volume
|
52
|
+
# configMap:
|
53
|
+
# name: demo-config-map
|
54
|
+
# secretRef:
|
55
|
+
# name: demo-seret
|
56
|
+
def wrapper_key
|
57
|
+
@item.keys.find { |k| wrapper_map.keys.include?(k) } # this key used for map[wrapper_key]
|
39
58
|
end
|
40
59
|
|
41
60
|
# wrapper element to key that stores the hashable value
|
42
|
-
def
|
61
|
+
def wrapper_map
|
43
62
|
{
|
44
|
-
'configMapRef' => 'name',
|
45
|
-
'configMapKeyRef' => 'name',
|
46
|
-
'configMap' => 'name',
|
47
|
-
'secretRef' => 'name',
|
48
|
-
'secretKeyRef' => 'name',
|
49
|
-
'secret' => 'secretName',
|
50
|
-
'tls' => 'secretName',
|
63
|
+
'configMapRef' => 'name', # containers.env.envFrom.configMapRef.name
|
64
|
+
'configMapKeyRef' => 'name', # containers.env.valueFrom.configMapKeyRef.name
|
65
|
+
'configMap' => 'name', # containers.env.envFrom.configMapRef.name
|
66
|
+
'secretRef' => 'name', # containers.env.envFrom.secretRef.name
|
67
|
+
'secretKeyRef' => 'name', # containers.env.valueFrom.secretKeyRef.name
|
68
|
+
'secret' => 'secretName', # volumes.secret.secretName
|
69
|
+
'tls' => 'secretName', # tls.secretName
|
51
70
|
}
|
52
71
|
end
|
53
72
|
end
|
@@ -16,12 +16,12 @@ module Kubes::Compiler::Decorator
|
|
16
16
|
# hashable set from previous stack call
|
17
17
|
if options[:hashable_field] && item.is_a?(Hash)
|
18
18
|
field = options[:hashable_field]
|
19
|
-
value_without_md5 = item[field.
|
19
|
+
value_without_md5 = item[field.target_key]
|
20
20
|
@reset_hashable_field = true unless value_without_md5
|
21
21
|
if field.hashable? && value_without_md5
|
22
22
|
md5 = Hashable::Storage.fetch(field.kind, value_without_md5)
|
23
23
|
v = [value_without_md5, md5].compact.join('-')
|
24
|
-
item[field.
|
24
|
+
item[field.target_key] = v
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -29,10 +29,10 @@ module Kubes::Compiler::Decorator
|
|
29
29
|
# Pretty tricky case. Given:
|
30
30
|
#
|
31
31
|
# envFrom:
|
32
|
-
# - secretRef:
|
33
|
-
# name: demo-secret
|
34
|
-
# - configMapRef:
|
35
|
-
# name: demo-config-map
|
32
|
+
# - secretRef: <--- wrapper_key
|
33
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
34
|
+
# - configMapRef: <--- wrapper_key
|
35
|
+
# name: demo-config-map <--- target_key is 'name' from wrapper_map[wrapper_key]
|
36
36
|
#
|
37
37
|
# Need to reset the stored hashable_field in the call stack.
|
38
38
|
# Else the field.kind is cached and the md5 look is incorrect
|
@@ -52,19 +52,19 @@ module Kubes::Compiler::Decorator
|
|
52
52
|
#
|
53
53
|
# 1. envFrom example
|
54
54
|
# envFrom:
|
55
|
-
# - secretRef:
|
56
|
-
# name: demo-secret
|
55
|
+
# - secretRef: <--- wrapper_key
|
56
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
57
57
|
#
|
58
58
|
# 2. valueFrom example
|
59
59
|
# valueFrom:
|
60
|
-
# secretKeyRef:
|
61
|
-
# name: demo-secret
|
60
|
+
# secretKeyRef: <--- wrapper_key
|
61
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
62
62
|
# key: password
|
63
63
|
#
|
64
64
|
# 3. volumes example
|
65
65
|
# volumes:
|
66
|
-
# - secret:
|
67
|
-
# secretName: demo-secret
|
66
|
+
# - secret: <--- wrapper_key
|
67
|
+
# secretName: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
68
68
|
#
|
69
69
|
# This is useful to capture for the next level of the stack call
|
70
70
|
#
|
data/lib/kubes/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
# apiVersion: apps/v1
|
3
|
+
# kind: Deployment
|
4
|
+
# spec:
|
5
|
+
# template:
|
6
|
+
# spec:
|
7
|
+
# only including structure needed for spec
|
8
|
+
volumes:
|
9
|
+
- name: config-map-volume
|
10
|
+
configMap:
|
11
|
+
name: demo-config-map
|
12
|
+
items:
|
13
|
+
- key: k1
|
14
|
+
path: config-map.conf
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
# apiVersion: apps/v1
|
3
|
+
# kind: Deployment
|
4
|
+
# spec:
|
5
|
+
# template:
|
6
|
+
# spec:
|
7
|
+
# only including structure needed for spec
|
8
|
+
volumes:
|
9
|
+
- configMap:
|
10
|
+
name: demo-config-map
|
11
|
+
items:
|
12
|
+
- key: k1
|
13
|
+
path: config-map.conf
|
14
|
+
name: config-map-volume
|
@@ -135,4 +135,29 @@ describe Kubes::Compiler::Decorator::Post do
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
138
|
+
|
139
|
+
context "order" do
|
140
|
+
# spec to fix issue TODO: add issue number
|
141
|
+
describe "name first" do
|
142
|
+
let(:data) { fixture("configMap/volumes-name-first") }
|
143
|
+
it "run" do
|
144
|
+
decorator.run
|
145
|
+
data = decorator.data
|
146
|
+
volumes = data['volumes']
|
147
|
+
name = volumes[0]['configMap']['name']
|
148
|
+
expect(name).to eq("demo-config-map-fakehash-config")
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe "name second" do
|
153
|
+
let(:data) { fixture("configMap/volumes-name-second") }
|
154
|
+
it "run" do
|
155
|
+
decorator.run
|
156
|
+
data = decorator.data
|
157
|
+
volumes = data['volumes']
|
158
|
+
name = volumes[0]['configMap']['name']
|
159
|
+
expect(name).to eq("demo-config-map-fakehash-config")
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
138
163
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
describe Kubes::Compiler::Decorator::Post do
|
2
|
+
let(:decorator) { described_class.new(data) }
|
3
|
+
|
4
|
+
def fixture(name)
|
5
|
+
YAML.load_file("spec/fixtures/decorators/ingress/#{name}.yaml")
|
6
|
+
end
|
7
|
+
before(:each) do
|
8
|
+
allow(Kubes::Compiler::Decorator::Hashable::Storage).to receive(:fetch).and_return("fakehash")
|
9
|
+
end
|
10
|
+
|
11
|
+
context "ingress" do
|
12
|
+
describe "tls" do
|
13
|
+
let(:data) { fixture("tls") }
|
14
|
+
it "run" do
|
15
|
+
decorator.run
|
16
|
+
data = decorator.data
|
17
|
+
name = data['spec']['tls'][0]['secretName']
|
18
|
+
expect(name).to eq("tls-secret-fakehash")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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.
|
4
|
+
version: 0.7.8
|
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-
|
11
|
+
date: 2021-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -732,10 +732,13 @@ files:
|
|
732
732
|
- spec/fixtures/decorators/deployment/both/volumes.yaml
|
733
733
|
- spec/fixtures/decorators/deployment/configMap/envFrom.yaml
|
734
734
|
- spec/fixtures/decorators/deployment/configMap/valueFrom.yaml
|
735
|
+
- spec/fixtures/decorators/deployment/configMap/volumes-name-first.yaml
|
736
|
+
- spec/fixtures/decorators/deployment/configMap/volumes-name-second.yaml
|
735
737
|
- spec/fixtures/decorators/deployment/configMap/volumes.yaml
|
736
738
|
- spec/fixtures/decorators/deployment/secret/envFrom.yaml
|
737
739
|
- spec/fixtures/decorators/deployment/secret/valueFrom.yaml
|
738
740
|
- spec/fixtures/decorators/deployment/secret/volumes.yaml
|
741
|
+
- spec/fixtures/decorators/ingress/tls.yaml
|
739
742
|
- spec/fixtures/decorators/pod/configMap/envFrom.yaml
|
740
743
|
- spec/fixtures/decorators/pod/configMap/valueFrom.yaml
|
741
744
|
- spec/fixtures/decorators/pod/configMap/volumes.yaml
|
@@ -762,6 +765,7 @@ files:
|
|
762
765
|
- spec/fixtures/syntax/.kubes/resources/web/pod.rb
|
763
766
|
- spec/kubes/cli/prune_spec.rb
|
764
767
|
- spec/kubes/compiler/decorator/post/deployment_spec.rb
|
768
|
+
- spec/kubes/compiler/decorator/post/ingress_spec.rb
|
765
769
|
- spec/kubes/compiler/decorator/post/pod_spec.rb
|
766
770
|
- spec/kubes/compiler/strategy/dispatcher_spec.rb
|
767
771
|
- spec/kubes/compiler_spec.rb
|
@@ -807,10 +811,13 @@ test_files:
|
|
807
811
|
- spec/fixtures/decorators/deployment/both/volumes.yaml
|
808
812
|
- spec/fixtures/decorators/deployment/configMap/envFrom.yaml
|
809
813
|
- spec/fixtures/decorators/deployment/configMap/valueFrom.yaml
|
814
|
+
- spec/fixtures/decorators/deployment/configMap/volumes-name-first.yaml
|
815
|
+
- spec/fixtures/decorators/deployment/configMap/volumes-name-second.yaml
|
810
816
|
- spec/fixtures/decorators/deployment/configMap/volumes.yaml
|
811
817
|
- spec/fixtures/decorators/deployment/secret/envFrom.yaml
|
812
818
|
- spec/fixtures/decorators/deployment/secret/valueFrom.yaml
|
813
819
|
- spec/fixtures/decorators/deployment/secret/volumes.yaml
|
820
|
+
- spec/fixtures/decorators/ingress/tls.yaml
|
814
821
|
- spec/fixtures/decorators/pod/configMap/envFrom.yaml
|
815
822
|
- spec/fixtures/decorators/pod/configMap/valueFrom.yaml
|
816
823
|
- spec/fixtures/decorators/pod/configMap/volumes.yaml
|
@@ -837,6 +844,7 @@ test_files:
|
|
837
844
|
- spec/fixtures/syntax/.kubes/resources/web/pod.rb
|
838
845
|
- spec/kubes/cli/prune_spec.rb
|
839
846
|
- spec/kubes/compiler/decorator/post/deployment_spec.rb
|
847
|
+
- spec/kubes/compiler/decorator/post/ingress_spec.rb
|
840
848
|
- spec/kubes/compiler/decorator/post/pod_spec.rb
|
841
849
|
- spec/kubes/compiler/strategy/dispatcher_spec.rb
|
842
850
|
- spec/kubes/compiler_spec.rb
|