kubes 0.4.6 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -0
  3. data/README.md +54 -1
  4. data/docs/_docs/config/reference.md +1 -0
  5. data/docs/_docs/config/skip.md +1 -1
  6. data/docs/_docs/dsl/multiple-resources.md +3 -3
  7. data/docs/_docs/dsl/resources/job.md +62 -0
  8. data/docs/_docs/dsl/resources/secret.md +19 -2
  9. data/docs/_docs/extra-env/dsl.md +2 -2
  10. data/docs/_docs/extra-env/yaml.md +1 -1
  11. data/docs/_docs/generators.md +41 -0
  12. data/docs/_docs/helpers.md +17 -3
  13. data/docs/_docs/helpers/aws.md +1 -0
  14. data/docs/_docs/helpers/aws/advanced.md +10 -0
  15. data/docs/_docs/helpers/aws/advanced/secrets.md +131 -0
  16. data/docs/_docs/helpers/aws/advanced/ssm.md +78 -0
  17. data/docs/_docs/helpers/aws/secrets.md +18 -88
  18. data/docs/_docs/helpers/aws/ssm.md +20 -38
  19. data/docs/_docs/helpers/google.md +1 -1
  20. data/docs/_docs/helpers/google/advanced.md +10 -0
  21. data/docs/_docs/helpers/google/advanced/secrets.md +78 -0
  22. data/docs/_docs/helpers/google/secrets.md +18 -27
  23. data/docs/_docs/helpers/google/service-account.md +8 -0
  24. data/docs/_docs/intro.md +2 -9
  25. data/docs/_docs/intro/docker-image.md +66 -0
  26. data/docs/_docs/intro/how-kubes-works.md +7 -11
  27. data/docs/_docs/layering.md +2 -0
  28. data/docs/_docs/layering/merge.md +1 -1
  29. data/docs/_docs/layering/mix.md +99 -0
  30. data/docs/_docs/learn/dsl/delete.md +10 -2
  31. data/docs/_docs/learn/dsl/review-project.md +2 -2
  32. data/docs/_docs/learn/yaml/delete.md +10 -2
  33. data/docs/_docs/learn/yaml/review-project.md +2 -2
  34. data/docs/_docs/patterns/clock-web-worker.md +3 -3
  35. data/docs/_docs/patterns/migrations.md +1 -1
  36. data/docs/_docs/patterns/multiple-envs.md +55 -0
  37. data/docs/_docs/patterns/secrets.md +0 -2
  38. data/docs/_docs/variables.md +23 -0
  39. data/docs/_docs/variables/advanced.md +62 -0
  40. data/docs/_docs/variables/basic.md +137 -0
  41. data/docs/_docs/vs.md +10 -0
  42. data/docs/_docs/vs/custom.md +109 -0
  43. data/docs/_docs/vs/helm.md +243 -0
  44. data/docs/_docs/vs/kustomize.md +167 -0
  45. data/docs/_docs/yaml.md +2 -2
  46. data/docs/_includes/commands.html +2 -2
  47. data/docs/_includes/intro/features.md +11 -0
  48. data/docs/_includes/layering/layers.md +2 -4
  49. data/docs/_includes/sidebar.html +41 -0
  50. data/docs/_includes/vs/article.md +1 -0
  51. data/docs/_includes/vs/kubes/layering.md +10 -0
  52. data/docs/_includes/vs/kubes/structure.md +24 -0
  53. data/docs/_reference/kubes-delete.md +1 -1
  54. data/docs/_reference/kubes-exec.md +17 -1
  55. data/docs/_reference/kubes-init.md +2 -2
  56. data/docs/_reference/kubes-logs.md +2 -1
  57. data/docs/_reference/kubes-new-help.md +15 -0
  58. data/docs/_reference/kubes-new-helper.md +25 -0
  59. data/docs/_reference/kubes-new-resource.md +56 -0
  60. data/docs/_reference/kubes-new-variable.md +20 -0
  61. data/docs/_reference/kubes-new.md +26 -0
  62. data/docs/_reference/kubes-prune.md +22 -0
  63. data/docs/reference.md +2 -0
  64. data/kubes.gemspec +2 -2
  65. data/lib/kubes.rb +5 -3
  66. data/lib/kubes/auth.rb +4 -1
  67. data/lib/kubes/auth/base.rb +21 -0
  68. data/lib/kubes/auth/ecr.rb +1 -15
  69. data/lib/kubes/auth/gcr.rb +24 -0
  70. data/lib/kubes/cli.rb +9 -1
  71. data/lib/kubes/cli/build.rb +6 -0
  72. data/lib/kubes/cli/compile.rb +7 -0
  73. data/lib/kubes/cli/deploy.rb +1 -6
  74. data/lib/kubes/cli/exec.rb +5 -1
  75. data/lib/kubes/cli/help/exec.md +15 -0
  76. data/lib/kubes/cli/help/new/helper.md +4 -0
  77. data/lib/kubes/cli/help/new/resource.md +30 -0
  78. data/lib/kubes/cli/init.rb +1 -1
  79. data/lib/kubes/cli/new.rb +15 -0
  80. data/lib/kubes/cli/new/helper.rb +24 -0
  81. data/lib/kubes/cli/new/resource.rb +97 -0
  82. data/lib/kubes/cli/new/variable.rb +16 -0
  83. data/lib/kubes/cli/sequence.rb +1 -0
  84. data/lib/kubes/command.rb +7 -0
  85. data/lib/kubes/compiler.rb +19 -21
  86. data/lib/kubes/compiler/decorator/base.rb +1 -1
  87. data/lib/kubes/compiler/dsl/core/base.rb +6 -9
  88. data/lib/kubes/compiler/dsl/syntax/job.rb +217 -0
  89. data/lib/kubes/compiler/layering.rb +21 -7
  90. data/lib/kubes/compiler/shared/custom_variables.rb +38 -0
  91. data/lib/kubes/compiler/shared/helpers.rb +11 -2
  92. data/lib/kubes/compiler/shared/helpers/deprecated.rb +37 -0
  93. data/lib/kubes/compiler/shared/plugin_helpers.rb +14 -0
  94. data/lib/kubes/compiler/strategy.rb +7 -6
  95. data/lib/kubes/compiler/strategy/base.rb +59 -2
  96. data/lib/kubes/compiler/strategy/dsl.rb +0 -29
  97. data/lib/kubes/compiler/strategy/erb.rb +10 -22
  98. data/lib/kubes/compiler/util/normalize.rb +6 -3
  99. data/lib/kubes/compiler/util/yaml_dump.rb +4 -4
  100. data/lib/kubes/config.rb +1 -1
  101. data/lib/kubes/core.rb +6 -0
  102. data/lib/kubes/docker/strategy/image_name.rb +1 -1
  103. data/lib/kubes/kubectl.rb +5 -23
  104. data/lib/kubes/kubectl/batch.rb +27 -33
  105. data/lib/kubes/kubectl/ordering.rb +42 -0
  106. data/lib/kubes/plugin.rb +14 -0
  107. data/lib/kubes/util/sh.rb +1 -1
  108. data/lib/kubes/version.rb +1 -1
  109. data/lib/templates/base/.kubes/config.rb.tt +1 -1
  110. data/lib/templates/base/.kubes/config/env/dev.rb +1 -1
  111. data/lib/templates/base/.kubes/config/env/prod.rb +1 -1
  112. data/lib/templates/dsl/.kubes/resources/web/deployment.rb +1 -1
  113. data/lib/templates/new/helper/file.rb +2 -0
  114. data/lib/templates/new/resource/dsl/backend_config.rb +10 -0
  115. data/lib/templates/new/resource/dsl/config_map.rb +5 -0
  116. data/lib/templates/new/resource/dsl/daemon_set.rb +11 -0
  117. data/lib/templates/new/resource/dsl/deployment.rb +4 -0
  118. data/lib/templates/new/resource/dsl/ingress.rb +3 -0
  119. data/lib/templates/new/resource/dsl/job.rb +2 -0
  120. data/lib/templates/new/resource/dsl/managed_certificate.rb +2 -0
  121. data/lib/templates/new/resource/dsl/namespace.rb +2 -0
  122. data/lib/templates/new/resource/dsl/network_policy.rb +7 -0
  123. data/lib/templates/new/resource/dsl/pod.rb +6 -0
  124. data/lib/templates/new/resource/dsl/role.rb +4 -0
  125. data/lib/templates/new/resource/dsl/role_binding.rb +7 -0
  126. data/lib/templates/new/resource/dsl/secret.rb +5 -0
  127. data/lib/templates/new/resource/dsl/service.rb +2 -0
  128. data/lib/templates/new/resource/dsl/service_account.rb +1 -0
  129. data/lib/templates/new/resource/yaml/backend_config.yaml +10 -0
  130. data/lib/templates/new/resource/yaml/config_map.yaml +9 -0
  131. data/lib/templates/new/resource/yaml/daemon_set.yaml +11 -0
  132. data/lib/templates/new/resource/yaml/deployment.yaml +19 -0
  133. data/lib/templates/new/resource/yaml/ingress.yaml +12 -0
  134. data/lib/templates/new/resource/yaml/job.yaml +19 -0
  135. data/lib/templates/new/resource/yaml/managed_certificate.yaml +7 -0
  136. data/lib/templates/new/resource/yaml/namespace.yaml +6 -0
  137. data/lib/templates/new/resource/yaml/network_policy.yaml +20 -0
  138. data/lib/templates/new/resource/yaml/pod.yaml +11 -0
  139. data/lib/templates/new/resource/yaml/role.yaml +13 -0
  140. data/lib/templates/new/resource/yaml/role_binding.yaml +11 -0
  141. data/lib/templates/new/resource/yaml/secret.yaml +9 -0
  142. data/lib/templates/new/resource/yaml/service.yaml +14 -0
  143. data/lib/templates/new/resource/yaml/service_account.yaml +4 -0
  144. data/lib/templates/new/variable/file.rb +1 -0
  145. data/lib/templates/yaml/.kubes/resources/base/all.yaml.tt +2 -0
  146. data/lib/templates/yaml/.kubes/resources/web/deployment.yaml.tt +1 -1
  147. data/spec/fixtures/multiple-files/{deployment-1.rb → .kubes/resources/web/deployment-1.rb} +0 -0
  148. data/spec/fixtures/multiple-files/{deployment-2.rb → .kubes/resources/web/deployment-2.rb} +0 -0
  149. data/spec/fixtures/project/.kubes/resources/{deployment.rb → web/deployment.rb} +0 -0
  150. data/spec/fixtures/project/.kubes/resources/{foobar.rb → web/empty.rb} +0 -0
  151. data/spec/fixtures/project/.kubes/resources/{service.rb → web/service.rb} +1 -1
  152. data/spec/fixtures/syntax/{network_policy.rb → .kubes/resources/web/network_policy.rb} +0 -0
  153. data/spec/fixtures/syntax/{pod.rb → .kubes/resources/web/pod.rb} +0 -0
  154. data/spec/kubes/cli/prune_spec.rb +1 -0
  155. data/spec/kubes/compiler/strategy/dsl_spec.rb +2 -2
  156. data/spec/kubes/compiler_spec.rb +6 -2
  157. data/spec/kubes/dsl/network_policy_spec.rb +1 -1
  158. data/spec/kubes/dsl/pod_spec.rb +1 -1
  159. metadata +97 -25
@@ -41,6 +41,8 @@ metadata:
41
41
 
42
42
  The role permissions are currently always added to the existing permissions. So removing roles that were previously added does not remove them.
43
43
 
44
+ ## Variables
45
+
44
46
  ServiceAccount#initialize options:
45
47
 
46
48
  Variable | Description | Default
@@ -50,3 +52,9 @@ gsa | The Google Service Account name. The conventional name is APP-ENV. IE: dem
50
52
  ksa | The Kubernetes Service Account name. The conventional name is APP. IE: demo | APP
51
53
  namespace | The Kubernetes namespace. Defaults to the APP-ENV. IE: demo-dev. | APP-ENV
52
54
  roles | Google IAM roles to add. This adds permissions to the Google service account. | []
55
+
56
+ Relevant environment variables:
57
+
58
+ Name | Description
59
+ ---|---
60
+ GOOGLE_PROJECT | Google project id. This is required as it's used to build the full service account name.
@@ -6,13 +6,6 @@ title: What is Kubes?
6
6
 
7
7
  <div class="video-box"><div class="video-container"><iframe src="https://www.youtube.com/embed/M4zHL0mfKNU" frameborder="0" allowfullscreen=""></iframe></div></div>
8
8
 
9
- ## Features:
9
+ ## Features
10
10
 
11
- * Automation: [Builds the Docker image]({% link _docs/config/docker.md %}) and updates the compiled YAML files
12
- * Syntactic Sugar: Use an [ERB/YAML]({% link _docs/yaml.md %}) or a [DSL]({% link _docs/dsl.md %}) to write your Kubernetes YAML files. You can use a mix of DSL and YAML definitions in the `.kubes/resources` folder.
13
- * Layering: Use the same Kubernetes YAML to build multiple environments like dev and prod with [layering]({% link _docs/layering.md %}).
14
- * CLI Customizations: You can customize the [cli args]({% link _docs/config/args/kubectl.md %}). You can also run [hooks]({% link _docs/config/hooks/kubectl.md %}) before and after kubectl commands.
15
- * Automated Suffix Hashes: Automatically appends a suffix hash to ConfigMap and Secret resources. More details in [ConfigMap]({% link _docs/dsl/resources/config_map.md %}) and [Secret]({% link _docs/dsl/resources/secret.md %}) docs.
16
- * Kustomize Support: If you’re a kustomization user, you can use it with Kubes. More details in [Kustomize Support Docs]({% link _docs/misc/kustomize.md %}).
17
- * Auto Context Switching: Map dev to a specific kubectl context and prod to another kubectl context and Kubes can switch them automatically so you won't have to remember. More details in [Auto Context Docs]({% link _docs/misc/auto-context.md %}).
18
- * Ordering: Kubes run kubectl apply to create resources in the [correct order]({% link _docs/intro/ordering.md %}). For deleting, it kubes will run `kubectl delete` in the correct reverse order. The order is also [customizable]({% link _docs/intro/ordering/custom.md %}).
11
+ {% include intro/features.md %}
@@ -0,0 +1,66 @@
1
+ ---
2
+ title: Docker Image
3
+ ---
4
+
5
+ With Kubes, you can use the `docker_image` helper method to select which image to use. It can use images from these sources:
6
+
7
+ 1. CLI Option: The `--image` option specified with the CLI command
8
+ 2. Kubes Config: Specified by `config.image` in the `.kubes/config.rb`
9
+ 3. Built Docker Image: The image built from Dockerfile
10
+
11
+ The CLI option has the highest precedence, and the Built Docker image has the lowest precedence.
12
+
13
+ ## 1. CLI Option
14
+
15
+ Kubes uses the image from the `--image` option if specified. It's a quick way to override the Docker image used by Kubes. Example:
16
+
17
+ kubes deploy --image repo/image:tag
18
+
19
+ When the `--image` option is set, Kubes skips the Docker build phase.
20
+
21
+ ## 2. Kubes Config
22
+
23
+ If you set the `config.image` in the Kubes config, Kubes will use this prebuilt Docker image instead. Example:
24
+
25
+ .kubes/config.rb:
26
+
27
+ ```ruby
28
+ Kubes.configure do |config|
29
+ config.image = "nginx"
30
+ end
31
+ ```
32
+
33
+ When `config.image` is set, Kubes skips the Docker build phase.
34
+
35
+ ## 3. Built Docker Image
36
+
37
+ Kubes can use a Docker image built from your Dockerfile. This is the default behavior of Kubes, as long as the CLI Option and the Kubes Config option is not set.
38
+
39
+ ## Template Example
40
+
41
+ Here's an example usage of the `docker_image` helper.
42
+
43
+ .kubes/resources/web/deployment.yaml
44
+
45
+ ```yaml
46
+ apiVersion: apps/v1
47
+ kind: Deployment
48
+ metadata:
49
+ name: web
50
+ labels:
51
+ role: web
52
+ spec:
53
+ selector:
54
+ matchLabels:
55
+ role: web
56
+ template:
57
+ metadata:
58
+ labels:
59
+ role: web
60
+ spec:
61
+ containers:
62
+ - name: web
63
+ image: <%= docker_image %>
64
+ ```
65
+
66
+ When running `kubes deploy`, Kubes will replace `<%= docker_image %>` with the Docker image from one of the sources described above.
@@ -10,20 +10,16 @@ In fact, you can use Kubes to build the files first, and then run `kubectl` dire
10
10
  kubes docker push
11
11
  kubes compile # compiles the .kubes/resources files to .kubes/output
12
12
 
13
- Now, use `kubectl` directly. This will apply all the files:
13
+ Now, use `kubectl` directly and apply them in the proper order:
14
14
 
15
- kubectl apply --recursive -f .kubes/output
16
-
17
- You can also selectively apply specific files:
18
-
19
- kubectl apply -f .kubes/output/web/deployment.yaml
15
+ kubectl apply -f .kubes/output/shared/namespace.yaml
20
16
  kubectl apply -f .kubes/output/web/service.yaml
17
+ kubectl apply -f .kubes/output/web/deployment.yaml
21
18
 
22
- You can also apply with kubes. This will compile the files automatically also.
23
-
24
- kubes apply
25
-
26
- The deploy command, does all 3 steps: builds the docker image, compiles the `.kubes/resources` files, and runs kubectl apply.
19
+ The deploy command simpifily does all 3 steps: build, compile, and apply.
27
20
 
28
21
  kubes deploy
29
22
 
23
+ You can also run the `kubectl apply` only. The `kube apply` command compiles but will skip the docker build stage if it's already been built.
24
+
25
+ kubes apply
@@ -6,3 +6,5 @@ Kubes supports layering files together so you can use the same Kubernetes files
6
6
 
7
7
  * [YAML Layering]({% link _docs/layering/yaml.md %})
8
8
  * [DSL Layering]({% link _docs/layering/dsl.md %})
9
+ * [Mix Layering]({% link _docs/layering/mix.md %})
10
+ * [Merge Behavior]({% link _docs/layering/merge.md %})
@@ -67,7 +67,7 @@ The merging of simple String is a straightforward replacement.
67
67
  .kubes/resources/web/deployment.rb
68
68
 
69
69
  ```ruby
70
- image built_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
70
+ image docker_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
71
71
  # ...
72
72
  ```
73
73
 
@@ -0,0 +1,99 @@
1
+ ---
2
+ title: Mixed Layering
3
+ ---
4
+
5
+ You can mix and match the YAML and DSL forms together and layering still works.
6
+
7
+ ## Project Structure
8
+
9
+ Here's an example structure, so we can understand how layering works.
10
+
11
+ .kubes/resources/
12
+ ├── base
13
+ │ ├── all.yaml
14
+ │ └── deployment.yaml
15
+ └── web
16
+ ├── deployment
17
+ │ ├── dev.yaml
18
+ │ └── prod.yaml
19
+ ├── deployment.rb
20
+ └── service.yaml
21
+
22
+ Notice, how deployment.rb is defined as a DSL. The layers will still be merged like so:
23
+
24
+ .kubes/resources/base/all.yaml
25
+ .kubes/resources/base/deployment.yaml
26
+ .kubes/resources/web/deployment.rb
27
+ .kubes/resources/web/deployment/dev.rb
28
+
29
+ ## Resources Files
30
+
31
+ .kubes/resources/base/all.yaml
32
+
33
+ ```yaml
34
+ metadata:
35
+ namespace: demo-<%= Kubes.env %>
36
+ labels:
37
+ app: demo
38
+ ```
39
+
40
+ .kubes/resources/base/deployment.yaml
41
+
42
+ ```yaml
43
+ metadata:
44
+ labels:
45
+ app: demo
46
+ spec:
47
+ selector:
48
+ matchLabels:
49
+ app: demo
50
+ template:
51
+ metadata:
52
+ labels:
53
+ app: demo
54
+ ```
55
+
56
+ .kubes/resources/web/deployment.rb
57
+
58
+ ```ruby
59
+ name "web"
60
+ labels(role: "web")
61
+ image "nginx"
62
+ ```
63
+
64
+ .kubes/resources/web/deployment/dev.yaml
65
+
66
+ ```yaml
67
+ spec:
68
+ replicas: 2
69
+ ```
70
+
71
+ ## Output
72
+
73
+ The result is the merge layered files.
74
+
75
+ ```yaml
76
+ metadata:
77
+ namespace: demo-dev
78
+ labels:
79
+ app: demo
80
+ role: web
81
+ name: web
82
+ spec:
83
+ selector:
84
+ matchLabels:
85
+ app: demo
86
+ role: web
87
+ template:
88
+ metadata:
89
+ labels:
90
+ app: demo
91
+ role: web
92
+ spec:
93
+ containers:
94
+ - image: nginx
95
+ name: web
96
+ replicas: 2
97
+ apiVersion: apps/v1
98
+ kind: Deployment
99
+ ```
@@ -6,11 +6,19 @@ Let's now delete the app and clean up:
6
6
 
7
7
  kubes delete
8
8
 
9
- You will be prompted to confirm before deletion. Here's out the output looks like:
9
+ You will be prompted to confirm before deletion.
10
10
 
11
11
  $ kubes delete
12
+ Compiled .kubes/resources files to .kubes/output
13
+ Will run:
14
+ kubectl delete -f .kubes/output/web/deployment.yaml
15
+ kubectl delete -f .kubes/output/web/service.yaml
16
+ kubectl delete -f .kubes/output/shared/namespace.yaml
17
+ This will delete resources. Are you sure? (y/N)
18
+
19
+ Confirm to delete the resources:
20
+
12
21
  This will delete resources. Are you sure? (y/N) y
13
- Compiled .kubes/resources files
14
22
  => kubectl delete -f .kubes/output/web/service.yaml
15
23
  service "demo-web" deleted
16
24
  => kubectl delete -f .kubes/output/web/deployment.yaml
@@ -29,10 +29,10 @@ labels(role: "web")
29
29
  namespace "default"
30
30
 
31
31
  replicas 1
32
- image built_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
32
+ image docker_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
33
33
  ```
34
34
 
35
- The DSL form is more concise than the YAML form. Also, notice the use of the `built_image` helper. The `built_image` is a kubes helper method that refers to the latest Docker image built. This spares you from updating the image manually.
35
+ The DSL form is more concise than the YAML form. Also, notice the use of the `docker_image` helper. The `docker_image` is a kubes helper method that refers to the latest Docker image built. This spares you from updating the image manually.
36
36
 
37
37
  ## Base Folder
38
38
 
@@ -6,11 +6,19 @@ Let's now delete the app and clean up:
6
6
 
7
7
  kubes delete
8
8
 
9
- You will be prompted to confirm before deletion. Here's out the output looks like:
9
+ You will be prompted to confirm before deletion.
10
10
 
11
11
  $ kubes delete
12
+ Compiled .kubes/resources files to .kubes/output
13
+ Will run:
14
+ kubectl delete -f .kubes/output/web/deployment.yaml
15
+ kubectl delete -f .kubes/output/web/service.yaml
16
+ kubectl delete -f .kubes/output/shared/namespace.yaml
17
+ This will delete resources. Are you sure? (y/N)
18
+
19
+ Confirm to delete the resources:
20
+
12
21
  This will delete resources. Are you sure? (y/N) y
13
- Compiled .kubes/resources files
14
22
  => kubectl delete -f .kubes/output/web/service.yaml
15
23
  service "demo-web" deleted
16
24
  => kubectl delete -f .kubes/output/web/deployment.yaml
@@ -46,10 +46,10 @@ spec:
46
46
  spec:
47
47
  containers:
48
48
  - name: web
49
- image: <%= built_image %>
49
+ image: <%= docker_image %>
50
50
  ```
51
51
 
52
- Notice the `<%= built_image %>`. Kubes processes the YAML files with ERB templating and replaces these tags. The `built_image` is a kubes helper method that refers to the latest Docker image built by Kubes. This spares you updating the image manually.
52
+ Notice the `<%= docker_image %>`. Kubes processes the YAML files with ERB templating and replaces these tags. The `docker_image` is a kubes helper method that refers to the latest Docker image built by Kubes. This spares you updating the image manually.
53
53
 
54
54
  ## Base Folder
55
55
 
@@ -31,7 +31,7 @@ namespace "default"
31
31
  labels(role: "web")
32
32
 
33
33
  replicas 1
34
- image built_image # IE: user/demo-clock:kubes-2020-06-13T19-55-16-43afc6e
34
+ image docker_image # IE: user/demo-clock:kubes-2020-06-13T19-55-16-43afc6e
35
35
  command "bin/clock"
36
36
  ```
37
37
 
@@ -43,7 +43,7 @@ namespace "default"
43
43
  labels(role: "web")
44
44
 
45
45
  replicas 1
46
- image built_image # IE: user/demo-clock:kubes-2020-06-13T19-55-16-43afc6e
46
+ image docker_image # IE: user/demo-clock:kubes-2020-06-13T19-55-16-43afc6e
47
47
  ```
48
48
 
49
49
  .kubes/resources/demo-worker/deployment.rb
@@ -54,7 +54,7 @@ namespace "default"
54
54
  labels(role: "web")
55
55
 
56
56
  replicas 2
57
- image built_image # IE: user/demo-clock:kubes-2020-06-13T19-55-16-43afc6e
57
+ image docker_image # IE: user/demo-clock:kubes-2020-06-13T19-55-16-43afc6e
58
58
  command "bin/worker"
59
59
  ```
60
60
 
@@ -25,7 +25,7 @@ spec:
25
25
  spec:
26
26
  containers:
27
27
  - name: migrate
28
- image: <%= built_image %>
28
+ image: <%= docker_image %>
29
29
  command: ["bin/job/migrate.sh"]
30
30
  restartPolicy: Never
31
31
  backoffLimit: 4
@@ -0,0 +1,55 @@
1
+ ---
2
+ title: Multiple Enviroments with Layering
3
+ nav_text: Multiple Enviroments
4
+ categories: patterns
5
+ ---
6
+
7
+ You can use Kubes to easily create multiple enviroments with the same YAML configs. This is thanks to [Kubes Layering]({% link _docs/layering.md %}). We'll walk through an example to help understand how it works.
8
+
9
+ ## Creating Multiple Enviroments
10
+
11
+ To create multiple enviroments like dev and prod just change KUBES_ENV. Example:
12
+
13
+ KUBES_ENV=dev kubes deploy
14
+ KUBES_ENV=prod kubes deploy
15
+
16
+ Different env files will be layered and merged to produce YAML files specific to each environment.
17
+
18
+ ## Project Structure
19
+
20
+ Here's an example structure, so we can understand how layering works to create multiple enviroments.
21
+
22
+ .kubes/resources/
23
+ ├── base
24
+ │ ├── all.yaml
25
+ │ └── deployment.yaml
26
+ └── web
27
+ ├── deployment
28
+ │ ├── dev.yaml
29
+ │ └── prod.yaml
30
+ ├── deployment.yaml
31
+ └── service.yaml
32
+
33
+ ## Concrete Example
34
+
35
+ Let's look at a concrete web/deployment.yaml.
36
+
37
+ Here are the files that get layered when `KUBES_ENV=dev`:
38
+
39
+ .kubes/resources/base/all.yaml
40
+ .kubes/resources/base/deployment.yaml
41
+ .kubes/resources/web/deployment.yaml
42
+ .kubes/resources/web/deployment/dev.yaml
43
+
44
+ And when `KUBES_ENV=prod`:
45
+
46
+ .kubes/resources/base/all.yaml
47
+ .kubes/resources/base/deployment.yaml
48
+ .kubes/resources/web/deployment.yaml
49
+ .kubes/resources/web/deployment/prod.yaml
50
+
51
+ Layering allows us to have common settings that are processed before your main `.kubes/resources/web/deployment.yaml` YAML manifest. And then add **environment** specific YAML files that get merged.
52
+
53
+ ## Variables and Helpers
54
+
55
+ Additional, you can use variables and helpers to provide environment specific values.
@@ -78,5 +78,3 @@ upcase | Automatically upcase the Kubernetes secret data keys. | false
78
78
  prefix | Prefixed used to list and filter Google secrets. IE: `projects/686010496118/secrets/demo-dev-`. Can also be set with the `GCP_SECRET_PREFIX` env variable. The env variable takes the highest precedence. | nil
79
79
 
80
80
  Note, Kubernetes secrets are only base64 encoded. So users who have access to read Kubernetes secrets will be able to decode and get the value trivially. Depending on your security posture requirements, this may or may not suffice.
81
-
82
- The Google helpers are provided by the [boltops-tools/kubes_google](https://github.com/boltops-tools/kubes_google) library. For more details, check out its README.
@@ -0,0 +1,23 @@
1
+ ---
2
+ title: Variables
3
+ ---
4
+
5
+ You can set variables to be made available to the templates. Generally, it is recommended to use Basic layering.
6
+
7
+ {% assign docs = site.docs | where: "categories","variables" %}
8
+ {% for doc in docs -%}
9
+ * [{{ doc.title }}]({{ doc.url }})
10
+ {% endfor %}
11
+
12
+ ## Generator
13
+
14
+ To help you get started quickly, you can generate starter variable code.
15
+
16
+ $ kubes new variable
17
+ create .kubes/variables/dev.rb
18
+
19
+ .kubes/variables/dev.rb
20
+
21
+ ```ruby
22
+ @example = "dev-value"
23
+ ```
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: Advanced Variables
3
+ nav_text: Advanced
4
+ categories: variables
5
+ ---
6
+
7
+ Basic variables layering should provides enough flexibility and is generally recommended. This page covers more advanced variables layering.
8
+
9
+ ## Advanced Layering Example
10
+
11
+ Here's a more complex structure to demonstrate advanced layering.
12
+
13
+ .kubes/variables
14
+ ├── base
15
+ │ └── deployment.rb
16
+ ├── base.rb
17
+ ├── dev.rb
18
+ ├── prod.rb
19
+ └── web
20
+ ├── deployment
21
+ │ ├── dev.rb
22
+ │ └── prod.rb
23
+ └── deployment.rb
24
+
25
+ ## Concrete Example
26
+
27
+ Let's look at a concrete web/deployment.yaml.
28
+
29
+ Here are the files that get layered when `KUBES_ENV=dev`:
30
+
31
+ .kubes/variables/base.rb
32
+ .kubes/variables/dev.rb
33
+ .kubes/variables/base/deployment.rb
34
+ .kubes/variables/web/deployment.rb
35
+ .kubes/variables/web/deployment/dev.rb
36
+
37
+ And when `KUBES_ENV=prod`:
38
+
39
+ .kubes/variables/base.rb
40
+ .kubes/variables/prod.rb
41
+ .kubes/variables/base/deployment.rb
42
+ .kubes/variables/web/deployment.rb
43
+ .kubes/variables/web/deployment/prod.rb
44
+
45
+ With advanced layering you can target a specific role and kind. So variables are only scoped to the resources you want.
46
+
47
+ ## Full Layering Table
48
+
49
+ Here's a table showing the the full layering.
50
+
51
+ Folder/Pattern | Example
52
+ ------------------|--------------------------------------------
53
+ base.rb | base.rb
54
+ ENV.rb | dev.rb
55
+ base/all.rb | base/all.rb
56
+ base/all/ENV.rb | base/all/dev.rb
57
+ base/KIND.rb | base/deployment.rb
58
+ base/KIND/base.rb | base/deployment/base.rb
59
+ base/KIND/ENV.rb | base/deployment/dev.rb
60
+ ROLE/KIND.rb | web/deployment.rb
61
+ ROLE/KIND/base.rb | web/deployment/base.rb
62
+ ROLE/KIND/ENV.rb | web/deployment/dev.rb