kubes 0.4.7 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -0
  3. data/README.md +54 -8
  4. data/docs/_docs/config/hooks/kubes.md +1 -0
  5. data/docs/_docs/config/reference.md +1 -0
  6. data/docs/_docs/config/skip.md +1 -1
  7. data/docs/_docs/dsl/multiple-resources.md +6 -4
  8. data/docs/_docs/dsl/resources/job.md +62 -0
  9. data/docs/_docs/dsl/resources/secret.md +19 -2
  10. data/docs/_docs/extra-env/dsl.md +2 -2
  11. data/docs/_docs/extra-env/yaml.md +1 -1
  12. data/docs/_docs/generators.md +41 -0
  13. data/docs/_docs/helpers.md +17 -3
  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/advanced.md +10 -0
  20. data/docs/_docs/helpers/google/advanced/secrets.md +78 -0
  21. data/docs/_docs/helpers/google/gke.md +33 -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/variables.md +23 -0
  38. data/docs/_docs/variables/advanced.md +62 -0
  39. data/docs/_docs/variables/basic.md +137 -0
  40. data/docs/_docs/vs.md +10 -0
  41. data/docs/_docs/vs/custom.md +109 -0
  42. data/docs/_docs/vs/helm.md +243 -0
  43. data/docs/_docs/vs/kustomize.md +167 -0
  44. data/docs/_docs/yaml.md +2 -2
  45. data/docs/_includes/commands.html +2 -2
  46. data/docs/_includes/intro/features.md +11 -0
  47. data/docs/_includes/layering/layers.md +2 -4
  48. data/docs/_includes/sidebar.html +41 -0
  49. data/docs/_includes/vs/article.md +1 -0
  50. data/docs/_includes/vs/kubes/layering.md +10 -0
  51. data/docs/_includes/vs/kubes/structure.md +24 -0
  52. data/docs/_reference/kubes-delete.md +1 -1
  53. data/docs/_reference/kubes-exec.md +17 -1
  54. data/docs/_reference/kubes-init.md +2 -2
  55. data/docs/_reference/kubes-logs.md +2 -1
  56. data/docs/_reference/kubes-new-help.md +15 -0
  57. data/docs/_reference/kubes-new-helper.md +25 -0
  58. data/docs/_reference/kubes-new-resource.md +56 -0
  59. data/docs/_reference/kubes-new-variable.md +20 -0
  60. data/docs/_reference/kubes-new.md +26 -0
  61. data/docs/_reference/kubes-prune.md +22 -0
  62. data/docs/reference.md +2 -0
  63. data/kubes.gemspec +2 -2
  64. data/lib/kubes.rb +5 -3
  65. data/lib/kubes/auth.rb +4 -1
  66. data/lib/kubes/auth/base.rb +21 -0
  67. data/lib/kubes/auth/ecr.rb +1 -15
  68. data/lib/kubes/auth/gcr.rb +24 -0
  69. data/lib/kubes/cli.rb +9 -1
  70. data/lib/kubes/cli/apply.rb +0 -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/prune.rb +4 -2
  84. data/lib/kubes/cli/sequence.rb +1 -0
  85. data/lib/kubes/command.rb +7 -0
  86. data/lib/kubes/compiler.rb +19 -21
  87. data/lib/kubes/compiler/decorator/base.rb +1 -1
  88. data/lib/kubes/compiler/dsl/core/base.rb +6 -9
  89. data/lib/kubes/compiler/dsl/syntax/job.rb +217 -0
  90. data/lib/kubes/compiler/layering.rb +21 -7
  91. data/lib/kubes/compiler/shared/custom_variables.rb +38 -0
  92. data/lib/kubes/compiler/shared/helpers.rb +11 -2
  93. data/lib/kubes/compiler/shared/helpers/deprecated.rb +37 -0
  94. data/lib/kubes/compiler/shared/plugin_helpers.rb +14 -0
  95. data/lib/kubes/compiler/strategy.rb +7 -6
  96. data/lib/kubes/compiler/strategy/base.rb +59 -2
  97. data/lib/kubes/compiler/strategy/dsl.rb +0 -29
  98. data/lib/kubes/compiler/strategy/erb.rb +10 -22
  99. data/lib/kubes/compiler/util/normalize.rb +6 -3
  100. data/lib/kubes/compiler/util/yaml_dump.rb +4 -4
  101. data/lib/kubes/config.rb +14 -1
  102. data/lib/kubes/core.rb +6 -0
  103. data/lib/kubes/docker/strategy/image_name.rb +1 -1
  104. data/lib/kubes/hooks/builder.rb +20 -4
  105. data/lib/kubes/hooks/concern.rb +1 -1
  106. data/lib/kubes/kubectl/batch.rb +7 -33
  107. data/lib/kubes/kubectl/ordering.rb +42 -0
  108. data/lib/kubes/plugin.rb +14 -0
  109. data/lib/kubes/util/sh.rb +1 -1
  110. data/lib/kubes/version.rb +1 -1
  111. data/lib/templates/base/.kubes/config.rb.tt +1 -1
  112. data/lib/templates/base/.kubes/config/env/dev.rb +1 -1
  113. data/lib/templates/base/.kubes/config/env/prod.rb +1 -1
  114. data/lib/templates/dsl/.kubes/resources/web/deployment.rb +1 -1
  115. data/lib/templates/new/helper/file.rb +2 -0
  116. data/lib/templates/new/resource/dsl/backend_config.rb +10 -0
  117. data/lib/templates/new/resource/dsl/config_map.rb +5 -0
  118. data/lib/templates/new/resource/dsl/daemon_set.rb +11 -0
  119. data/lib/templates/new/resource/dsl/deployment.rb +4 -0
  120. data/lib/templates/new/resource/dsl/ingress.rb +3 -0
  121. data/lib/templates/new/resource/dsl/job.rb +2 -0
  122. data/lib/templates/new/resource/dsl/managed_certificate.rb +2 -0
  123. data/lib/templates/new/resource/dsl/namespace.rb +2 -0
  124. data/lib/templates/new/resource/dsl/network_policy.rb +7 -0
  125. data/lib/templates/new/resource/dsl/pod.rb +6 -0
  126. data/lib/templates/new/resource/dsl/role.rb +4 -0
  127. data/lib/templates/new/resource/dsl/role_binding.rb +7 -0
  128. data/lib/templates/new/resource/dsl/secret.rb +5 -0
  129. data/lib/templates/new/resource/dsl/service.rb +2 -0
  130. data/lib/templates/new/resource/dsl/service_account.rb +1 -0
  131. data/lib/templates/new/resource/yaml/backend_config.yaml +10 -0
  132. data/lib/templates/new/resource/yaml/config_map.yaml +9 -0
  133. data/lib/templates/new/resource/yaml/daemon_set.yaml +11 -0
  134. data/lib/templates/new/resource/yaml/deployment.yaml +19 -0
  135. data/lib/templates/new/resource/yaml/ingress.yaml +12 -0
  136. data/lib/templates/new/resource/yaml/job.yaml +19 -0
  137. data/lib/templates/new/resource/yaml/managed_certificate.yaml +7 -0
  138. data/lib/templates/new/resource/yaml/namespace.yaml +6 -0
  139. data/lib/templates/new/resource/yaml/network_policy.yaml +20 -0
  140. data/lib/templates/new/resource/yaml/pod.yaml +11 -0
  141. data/lib/templates/new/resource/yaml/role.yaml +13 -0
  142. data/lib/templates/new/resource/yaml/role_binding.yaml +11 -0
  143. data/lib/templates/new/resource/yaml/secret.yaml +9 -0
  144. data/lib/templates/new/resource/yaml/service.yaml +14 -0
  145. data/lib/templates/new/resource/yaml/service_account.yaml +4 -0
  146. data/lib/templates/new/variable/file.rb +1 -0
  147. data/lib/templates/yaml/.kubes/resources/base/all.yaml.tt +2 -0
  148. data/lib/templates/yaml/.kubes/resources/web/deployment.yaml.tt +1 -1
  149. data/spec/fixtures/multiple-files/{deployment-1.rb → .kubes/resources/web/deployment-1.rb} +0 -0
  150. data/spec/fixtures/multiple-files/{deployment-2.rb → .kubes/resources/web/deployment-2.rb} +0 -0
  151. data/spec/fixtures/project/.kubes/resources/{deployment.rb → web/deployment.rb} +0 -0
  152. data/spec/fixtures/project/.kubes/resources/{foobar.rb → web/empty.rb} +0 -0
  153. data/spec/fixtures/project/.kubes/resources/{service.rb → web/service.rb} +1 -1
  154. data/spec/fixtures/syntax/{network_policy.rb → .kubes/resources/web/network_policy.rb} +0 -0
  155. data/spec/fixtures/syntax/{pod.rb → .kubes/resources/web/pod.rb} +0 -0
  156. data/spec/kubes/cli/prune_spec.rb +1 -0
  157. data/spec/kubes/compiler/strategy/dsl_spec.rb +2 -2
  158. data/spec/kubes/compiler_spec.rb +6 -2
  159. data/spec/kubes/dsl/network_policy_spec.rb +1 -1
  160. data/spec/kubes/dsl/pod_spec.rb +1 -1
  161. metadata +98 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b2e59aafa5ea2023bdf23dc43ba38c5279dcd719c3db793eca0abf24c8e1da2
4
- data.tar.gz: ed004f619cba70d0d6257ca9559b3fd1b1fa7cb6c48943c64c3abcb8cddf3d38
3
+ metadata.gz: 4068263aefa8212b17485e3a257813b806e0efc0617c01e7210db576759c2f27
4
+ data.tar.gz: e649b39644516f59a09c08ec33d05c9ceb9adde006c6bda386f370bec8e205d8
5
5
  SHA512:
6
- metadata.gz: 7be4d6f0bd67e15b9ba3e3594f1b98d36c3fb5a4cc68c67fd603a75a973e4b90f8800a0a8fddf68951d0f3f09291c154bae5066830ec792aa167eb8675f5acca
7
- data.tar.gz: 6187e6b6bc29e1a038f8c5a20530483a120cc6107854f718f8570648334f27cb7b4afb1a39d4d45ede4bb3cda97e8cc66d63c1cbbdde27a059997f65bd547704
6
+ metadata.gz: 0f65b2736c9967eee1a24b65513bed5bb79177c54f8870871e1428e4ba6ff4b2e2501e5d6a1a78ada9f2db971763a6b1f6d35b4818fcfaf76df95baa37aba049
7
+ data.tar.gz: cfb8c9a0371d7efd6e9a4d8deeb1c503a18c63fd291a0a89275b9bf84996fa7a6ce7f3dfc7c83e8ff98546fc94c80a65bf41f953121833b0f3614c5a635098de
@@ -3,6 +3,34 @@
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.6.2]
7
+ - [#36](https://github.com/boltops-tools/kubes/pull/36) add plugin hooks support
8
+
9
+ ## [0.6.1]
10
+ - update gemspec dependency to plugins that provide the secrets helpers
11
+
12
+ ## [0.6.0]
13
+ - [#35](https://github.com/boltops-tools/kubes/pull/35) mix layering support: evaluate DSL so layering can be mixed between YAML and DSL docs: https://kubes.guru/docs/layering/mix/
14
+ - custom variables support: docs https://kubes.guru/docs/variables/basic/
15
+ - custom helpers support: docs https://kubes.guru/docs/helpers/custom/
16
+ - plugins helpers support
17
+ - generators: new resource, new helper, new variable
18
+ - setup autoloader earlier. removes need for shims
19
+ - auth login for gcr also
20
+ - fix cli -h when not within Kubes project
21
+
22
+ ## [0.5.1]
23
+ - fix deployment generator
24
+
25
+ ## [0.5.0]
26
+ - #34 Generators, docker_image helper, check project, also write full.yaml #34
27
+ - new generators: docs: https://kubes.guru/docs/generators/
28
+ - `docker_image` helper. deprecated `built_image`. `config.image` option support.
29
+ - check_project: check within a Kubes project
30
+ - job dsl
31
+ - kubes compile: auto run docker build and push when if needed
32
+ - also write .kubes/output/full.yaml
33
+
6
34
  ## [0.4.7]
7
35
  - #33 improve switch context: earlier and only when needed
8
36
 
data/README.md CHANGED
@@ -18,13 +18,6 @@ Kubes will:
18
18
  2. Compile Kubernetes YAML files from YAML/ERB or a DSL and adjusts the Docker build image
19
19
  3. Deploy via kubectl apply on the compiled Kubernetes YAML files
20
20
 
21
- Features:
22
-
23
- * Automation: [Builds the Docker image](docs/docker.md) and updates the compiled YAML files
24
- * Syntactic Sugar: Use an optional [ERB/YAML](docs/yaml.md) or [DSL](docs/dsl.md) to write your Kubernetes YAML files. You can use a mix of DSL and YAML definitions in the `.kubes/resources` folder.
25
- * Layering: Use the same Kubernetes YAML to build multiple environments like dev and prod with [layering](docs/layering.md).
26
- * CLI Customizations: You can customize the [cli args](docs/kubectl.md). You can also run hooks before and after kubectl commands.
27
-
28
21
  ## Usage
29
22
 
30
23
  kubes init # creates .kubes structure
@@ -44,8 +37,8 @@ In fact, you can use Kubes to build the files first, and then run `kubectl` dire
44
37
  Now, use `kubectl` directly in the proper order:
45
38
 
46
39
  kubectl apply -f .kubes/output/shared/namespace.yaml
47
- kubectl apply -f .kubes/output/web/deployment.yaml
48
40
  kubectl apply -f .kubes/output/web/service.yaml
41
+ kubectl apply -f .kubes/output/web/deployment.yaml
49
42
 
50
43
  You can also apply with kubes. This will compile the automatically files also.
51
44
 
@@ -55,10 +48,63 @@ The deploy command, does all 3 steps: builds the docker image, compiles the `.ku
55
48
 
56
49
  kubes deploy
57
50
 
51
+ ## Multiple Enviroments
52
+
53
+ You can easily create multiple environments with the same YAML configs. Example:
54
+
55
+ KUBES_ENV=dev kubes deploy
56
+ KUBES_ENV=prod kubes deploy
57
+
58
+ See: [Multiple Enviroments Pattern](https://kubes.guru/docs/patterns/multiple-envs/)
59
+
60
+ ## Generators: Stop Writing Boilerplate
61
+
62
+ Your time is precious. Why are we copying and pasting boilerplate structure in this day and age?
63
+
64
+ Kubes provides generators to help you get going right away.
65
+
66
+ Resources examples:
67
+
68
+ $ kubes new resource secret
69
+ create .kubes/resources/shared/secret.yaml
70
+ $ kubes new resource service_account
71
+ create .kubes/resources/shared/service_account.yaml
72
+
73
+ Kubes components examples:
74
+
75
+ $ kubes new helper
76
+ create .kubes/helpers/custom_helper.rb
77
+ $ kubes new variable
78
+ create .kubes/variables/dev.rb
79
+ $
80
+
81
+ ## Features
82
+
83
+ * Automation: [Builds the Docker image](https://kubes.guru/docs/config/docker/) and updates the compiled YAML files
84
+ * Syntactic Sugar: Use an [ERB/YAML](https://kubes.guru/docs/yaml/) or a [DSL](https://kubes.guru/docs/dsl/) to write your Kubernetes YAML files. You can use a mix of DSL and YAML definitions in the `.kubes/resources` folder.
85
+ * Layering: Use the same Kubernetes YAML to build multiple environments like dev and prod with [layering](https://kubes.guru/docs/layering/).
86
+ * Secrets: Use helpers like [aws_secret](https://kubes.guru/docs/helpers/aws/secrets/), [aws_ssm](https://kubes.guru/docs/helpers/aws/ssm/), and [google_secret](https://kubes.guru/docs/helpers/google/secrets/) to build Kubernetes secrets.yaml from secret providers designed for it.
87
+ * Generators: Kubes ships with a few generators to help you get building with Kubernetes quickly. See: [Generator Docs](https://kubes.guru/docs/generators/).
88
+ * CLI Customizations: You can customize the [cli args](https://kubes.guru/docs/config/args/kubectl/).
89
+ * Hooks: You can also run [hooks](https://kubes.guru/docs/config/hooks/) before and after [kubes](https://kubes.guru/docs/config/hooks/kubes/) and [kubectl](https://kubes.guru/docs/config/hooks/kubectl/) commands.
90
+ * Automated Suffix Hashes: Automatically appends a suffix hash to ConfigMap and Secret resources. More details in [ConfigMap](https://kubes.guru/docs/dsl/resources/config_map/) and [Secret](https://kubes.guru/docs/dsl/resources/secret/) docs.
91
+ * Kustomize Support: If you're a kustomization user, you can use it with Kubes. More details in [Kustomize Support Docs](https://kubes.guru/docs/misc/kustomize/).
92
+ * 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](https://kubes.guru/docs/misc/auto-context/).
93
+ * Ordering: Kubes run kubectl apply to create resources in the [correct order](https://kubes.guru/docs/intro/ordering/). For deleting, it kubes will run `kubectl delete` in the correct reverse order. The order is also [customizable](https://kubes.guru/docs/intro/ordering/custom/).
94
+
58
95
  ## Installation
59
96
 
60
97
  Install with:
61
98
 
62
99
  gem install kubes
63
100
 
101
+ ## Comparison
102
+
103
+ Here are some useful comparisons to help you compare Kubes vs other tools in the ecosystem:
104
+
105
+ * Blog Post: [Kustomize vs Helm vs Kubes: Kubernetes Deploy Tools](https://blog.boltops.com/2020/11/05/kustomize-vs-helm-vs-kubes-kubernetes-deploy-tools)
106
+ * [Kubes vs Custom Solution](https://kubes.guru/docs/vs/custom/)
107
+ * [Kubes vs Helm](https://kubes.guru/docs/vs/helm/)
108
+ * [Kubes vs Kustomize](https://kubes.guru/docs/vs/kustomize/)
109
+
64
110
  For more info: [kubes.guru](https://kubes.guru)
@@ -13,6 +13,7 @@ Hook | Description
13
13
  compile | When kubes compiles the `.kubes/resources` to `.kubes/output`.
14
14
  apply | When kubes runs all the `kubectl apply` commands.
15
15
  delete | When kubes runs all the `kubectl delete` commands.
16
+ prune | When kubes prunes. IE: To clean old secrets.
16
17
 
17
18
  ## Lifecycle At Kubes Level
18
19
 
@@ -6,6 +6,7 @@ Name | Description | Default
6
6
  ---|---|---
7
7
  auto_prune | Prune and delete old hashed resources like Secret and ConfigMap. | true
8
8
  builder | What docker build command to use. Can use `docker` or `gcloud` to build the Docker image. | docker
9
+ image | Set a prebuilt Docker image to use. This is optional. Usually, you want to build an image from the Dockerfile. Setting this will change the `docker_image` helper to use a predefined image. See: [Docker Image]({% link _docs/intro/docker-image.md %}) | nil
9
10
  kubectl.context | What kubectl context to auto-switch to. | nil
10
11
  kubectl.context_keep | Whether or not to keep the context switched | true
11
12
  kubectl.exit_on_fail.apply | Whether or not continue if the `kubectl apply` fails. Note, can use `KUBES_EXIT_ON_FAIL=0` env var to set to false. | true
@@ -20,7 +20,7 @@ spec:
20
20
  spec:
21
21
  containers:
22
22
  - name: cleanup
23
- image: <%= built_image %>
23
+ image: <%= docker_image %>
24
24
  command: ["bin/cleanup.sh"]
25
25
  restartPolicy: Never
26
26
  ```
@@ -39,7 +39,9 @@ Using multiple files is the general recommended approach.
39
39
 
40
40
  ## Multiple Resources: Block Form
41
41
 
42
- You can also use a block form to create multiple resources. You name the resource files with plural names. An example helps explain:
42
+ You can also use a block form to create multiple resources. The multiple resources block form is an experimental feature.
43
+
44
+ You name the resource files with plural names. An example helps explain:
43
45
 
44
46
  .kubes
45
47
  └── resources
@@ -51,13 +53,13 @@ You can also use a block form to create multiple resources. You name the resour
51
53
  deployment "demo-web" do
52
54
  labels(role: "web")
53
55
  replicas 1
54
- image built_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
56
+ image docker_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
55
57
  end
56
58
 
57
59
  deployment "demo-web-2" do
58
60
  labels(role: "web")
59
61
  replicas 1
60
- image built_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
62
+ image docker_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
61
63
  end
62
64
  ```
63
65
 
@@ -70,7 +72,7 @@ You can also mix and matched resources. When you use the block form, the file na
70
72
  deployment "demo-web" do
71
73
  labels(role: "web")
72
74
  replicas 1
73
- image built_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
75
+ image docker_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
74
76
  end
75
77
 
76
78
  service "demo-web" do
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: Job
3
+ categories: dsl
4
+ ---
5
+
6
+ ## Example 1
7
+
8
+ Here's an example of an job.
9
+
10
+ .kubes/resources/migrate/job.rb
11
+
12
+ ```ruby
13
+ name "<%= app %>"
14
+ image(docker_image)
15
+ ```
16
+
17
+ Produces:
18
+
19
+ .kubes/output/migrate/job.yaml
20
+
21
+ ```yaml
22
+ ---
23
+ apiVersion: batch/v1
24
+ kind: Job
25
+ metadata:
26
+ name: demo
27
+ labels:
28
+ app: demo
29
+ namespace: demo-dev
30
+ spec:
31
+ template:
32
+ metadata:
33
+ labels:
34
+ app: demo
35
+ spec:
36
+ containers:
37
+ - image: 111111111111.dkr.ecr.us-west-2.amazonaws.com/demo:kubes-2020-10-26T20-25-43
38
+ name: demo
39
+ ```
40
+
41
+ ## DSL Methods
42
+
43
+ Here's a list of more common methods:
44
+
45
+ job.spec.template.spec.containers fields:
46
+
47
+ * args
48
+ * command
49
+ * env
50
+ * envFrom
51
+ * image
52
+ * imagePullPolicy
53
+ * lifecycle
54
+ * livenessProbe
55
+ * containerName
56
+ * ports
57
+ * readinessProbe
58
+ * volumeDevices
59
+ * volumeMounts
60
+ * workingDir
61
+
62
+ {% include dsl/methods.md name="job" %}
@@ -19,7 +19,7 @@ data(
19
19
 
20
20
  Produces:
21
21
 
22
- .kubes/output/shared/service.yaml
22
+ .kubes/output/shared/secret.yaml
23
23
 
24
24
  ```yaml
25
25
  apiVersion: v1
@@ -38,6 +38,23 @@ data:
38
38
 
39
39
  {% include dsl/rolling_deployment.md kind="Secret" %}
40
40
 
41
+ .kubes/resources/web/deployment.yaml:
42
+
43
+ ```yaml
44
+ # ..
45
+ spec:
46
+ template:
47
+ spec:
48
+ containers:
49
+ - name: demo
50
+ image: nginx
51
+ envFrom:
52
+ - secretRef:
53
+ name: demo-secret
54
+ ```
55
+
56
+ Produces:
57
+
41
58
  .kubes/output/web/deployment.yaml:
42
59
 
43
60
  ```yaml
@@ -46,7 +63,7 @@ spec:
46
63
  template:
47
64
  spec:
48
65
  containers:
49
- - name: demo-shared
66
+ - name: demo
50
67
  image: nginx
51
68
  envFrom:
52
69
  - secretRef:
@@ -14,7 +14,7 @@ labels(role: "web")
14
14
  namespace with_extra("default")
15
15
 
16
16
  replicas 1
17
- image built_image # IE: user/demo-web:kubes-2020-06-13T19-55-16-43afc6e
17
+ image docker_image # IE: user/demo-web:kubes-2020-06-13T19-55-16-43afc6e
18
18
  ```
19
19
 
20
20
  .kubes/resources/web/service.rb
@@ -50,7 +50,7 @@ labels(app: name, extra: extra)
50
50
  namespace "default"
51
51
 
52
52
  replicas 1
53
- image built_image # IE: user/demo-web:kubes-2020-06-13T19-55-16-43afc6e
53
+ image docker_image # IE: user/demo-web:kubes-2020-06-13T19-55-16-43afc6e
54
54
  ```
55
55
 
56
56
  .kubes/resources/web/service.rb
@@ -28,7 +28,7 @@ spec:
28
28
  app: demo
29
29
  spec:
30
30
  containers:
31
- - image: <%= built_image %>
31
+ - image: <%= docker_image %>
32
32
  name: demo-web
33
33
  ```
34
34
 
@@ -0,0 +1,41 @@
1
+ ---
2
+ title: Generators
3
+ ---
4
+
5
+ Kubes ships with a few generators to help you get building with Kubernetes quickly. The generated starter YAML should be modified and customized for your needs.
6
+
7
+ ## Examples
8
+
9
+ Here are a few examples:
10
+
11
+ $ kubes new resource ingress
12
+ create .kubes/resources/web/ingress.yaml
13
+ $ kubes new resource service_account
14
+ create .kubes/resources/shared/service_account.yaml
15
+ $
16
+
17
+ Use `-h` to see the cli options:
18
+
19
+ kubes new resource -h
20
+
21
+ ## Supported Resources
22
+
23
+ Here's a list of some of the supported resources.
24
+
25
+ backend_config
26
+ config_map
27
+ daemon_set
28
+ deployment
29
+ ingress
30
+ job
31
+ managed_certificate
32
+ namespace
33
+ network_policy
34
+ pod
35
+ role_binding
36
+ role
37
+ secret
38
+ service_account
39
+ service
40
+
41
+ Refer to the [source code](https://github.com/boltops-tools/kubes/blob/master/lib/templates/new/resource/yaml) to all the resources that the generator supports.
@@ -6,10 +6,10 @@ Kubes provides some helper methods to help write Kubernetes YAML files. Here's
6
6
 
7
7
  Helper | Description
8
8
  --- | ---
9
- built_image | Method refers to the latest Docker image built by Kubes. This spares you from having to update the image manually in the deployment resource.
10
- decode64 | Basey64d decode a string.
9
+ decode64 | Base64 decode a string.
10
+ docker_image | Method refers to the latest Docker image built by Kubes. This spares you from having to update the image manually in the deployment resource. Note, this can be overridden with the `--image` cli option or the `Kubes.config.image` setting. See: [Docker Image]({% link _docs/intro/docker-image.md %})
11
11
  dockerfile_port | Exposed port extracted from the Dockerfile of the project.
12
- encode64 | Basey64 encode a string. Also available as `base64` method.
12
+ encode64 | Base64 encode a string. Also available as `base64` method.
13
13
  extra | The `KUBES_EXTRA` value.
14
14
  with_extra | Appends the `KUBES_EXTRA` value to a string if it's set. It's covered in the [Extra Env Docs]({% link _docs/extra-env.md %}).
15
15
 
@@ -25,3 +25,17 @@ There are also provider-specific helpers:
25
25
 
26
26
  * [AWS Helpers]({% link _docs/helpers/aws.md %})
27
27
  * [Google Helpers]({% link _docs/helpers/google.md %})
28
+
29
+ ## Generator
30
+
31
+ To help you get started quickly, you can generate starter helper code.
32
+
33
+ $ kubes new helper custom
34
+ create .kubes/helpers/custom_helper.rb
35
+
36
+ .kubes/helpers/custom_helper.rb
37
+
38
+ ```ruby
39
+ module CustomHelper
40
+ end
41
+ ```
@@ -0,0 +1,10 @@
1
+ ---
2
+ title: Advanced AWS Helpers
3
+ nav_text: Advanced
4
+ categories: helpers-aws
5
+ ---
6
+
7
+ {% assign docs = site.docs | where: "categories","advanced-helpers-aws" %}
8
+ {% for doc in docs -%}
9
+ * [{{ doc.nav_text }}]({{ doc.url }})
10
+ {% endfor %}
@@ -0,0 +1,131 @@
1
+ ---
2
+ title: AWS Secrets Advanced
3
+ nav_text: Secrets
4
+ categories: advanced-helpers-aws
5
+ ---
6
+
7
+ This covers an advanced way so that Kubernetes Secrets are created from AWS Secrets Manager in a conventional way.
8
+
9
+ ## Simple Values
10
+
11
+ For example if you have these secret values:
12
+
13
+ $ aws secretsmanager get-secret-value --secret-id demo/dev/db_user | jq '.SecretString'
14
+ user
15
+ $ aws secretsmanager get-secret-value --secret-id demo/dev/db_pass | jq '.SecretString'
16
+ pass
17
+
18
+ Set up a [Kubes hook](https://kubes.guru/docs/config/hooks/kubes/).
19
+
20
+ .kubes/config/hooks/kubes.rb
21
+
22
+ ```ruby
23
+ secrets = KubesAws::Secrets.new(upcase: true, prefix: "demo/dev/")
24
+ before("compile",
25
+ label: "Get secrets from AWS Secrets Manager",
26
+ execute: secrets,
27
+ )
28
+ ```
29
+
30
+ Then set the secrets in the YAML:
31
+
32
+ .kubes/resources/shared/secret.yaml
33
+
34
+ ```yaml
35
+ apiVersion: v1
36
+ kind: Secret
37
+ metadata:
38
+ name: demo
39
+ labels:
40
+ app: demo
41
+ data:
42
+ <% KubesAws::Secrets.data.each do |k,v| -%>
43
+ <%= k %>: <%= base64(v) %>
44
+ <% end -%>
45
+ ```
46
+
47
+ This results in AWS secrets with the prefix the `demo/dev/` being added to the Kubernetes secret data. The values are automatically base64 encoded. Produces:
48
+
49
+ .kubes/output/shared/secret.yaml
50
+
51
+ ```yaml
52
+ metadata:
53
+ namespace: demo
54
+ name: demo-2a78a13682
55
+ labels:
56
+ app: demo
57
+ apiVersion: v1
58
+ kind: Secret
59
+ data:
60
+ db_pass: dGVzdDEK
61
+ db_user: dGVzdDIK
62
+ ```
63
+
64
+ ## JSON Values
65
+
66
+ For example if you have these secret values:
67
+
68
+ $ aws secretsmanager get-secret-value --secret-id demo/dev/k2 | jq '.SecretString'
69
+ {\"a\":1,\"b\":2}"
70
+
71
+ Set up a [Kubes hook](https://kubes.guru/docs/config/hooks/kubes/).
72
+
73
+ .kubes/config/hooks/kubes.rb
74
+
75
+ ```ruby
76
+ secrets = KubesAws::Secrets.new(prefix: "rails/dev/")
77
+ before("compile",
78
+ label: "Get secrets from AWS Secrets Manager",
79
+ execute: secrets,
80
+ )
81
+ ```
82
+
83
+ Then set the secrets in the YAML:
84
+
85
+ .kubes/resources/shared/secret.yaml
86
+
87
+ ```yaml
88
+ apiVersion: v1
89
+ kind: Secret
90
+ metadata:
91
+ name: demo
92
+ labels:
93
+ app: demo
94
+ data:
95
+ <% k2 = JSON.load(KubesAws::Secrets.data["k2"]) %>
96
+ a: <%= base64(k2["a"]) %>
97
+ b: <%= base64(k2["b"]) %>
98
+ ```
99
+
100
+ Produces:
101
+
102
+ ```yaml
103
+ metadata:
104
+ namespace: demo-dev
105
+ name: demo-a4cd604a95
106
+ labels:
107
+ app: demo
108
+ apiVersion: v1
109
+ kind: Secret
110
+ data:
111
+ a: MQ==
112
+ b: Mg==
113
+ ```
114
+
115
+ ## Variables
116
+
117
+ These environment variables can be set:
118
+
119
+ Name | Description
120
+ ---|---
121
+ AWS_SECRET_PREFIX | Prefixed used to list and filter AWS secrets. IE: `demo/dev/`.
122
+
123
+ Secrets#initialize options:
124
+
125
+ Variable | Description | Default
126
+ ---|---|---
127
+ base64 | Automatically base64 encode the values. | false
128
+ upcase | Automatically upcase the Kubernetes secret data keys. | false
129
+ prefix | Prefixed used to list and filter AWS secrets. IE: `demo/dev/`. Can also be set with the `AWS_SECRET_PREFIX` env variable. The env variable takes the highest precedence. | nil
130
+
131
+ {% include helpers/base64.md %}