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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4943b1a730b2ab6d80a6de3128d6a55182a02f75c6ed176ab5bdc2eef9e080a
4
- data.tar.gz: 0d30261fa44bb60fa61bc9d38ada888469caa27b42e09c19e59edbbed52ab190
3
+ metadata.gz: 68eb4fe2f49953dd133ed6d5baece88f47ff0078162576a0cc41238bf571b6fc
4
+ data.tar.gz: 29821780f33d80b168f20d2f42e38074776230ed7cde8fc474d947c70bc6f099
5
5
  SHA512:
6
- metadata.gz: 3a17f532fa0b257a92b79fd1975c6d83ba0d7fc6f4d56c7e01f0937d9f64b16bae2e3637364acc258027f0c3fe434f1732221dedc8461587c45a9fcaea4c873b
7
- data.tar.gz: 91e88038fcdfd9925567936c2a665d097ac739d2ebb17191526357bbd227336ffe57c389e946f44b6ce78ed27022901f2c78ee64f2aacdcbeda490a51d35e35a
6
+ metadata.gz: 0c6de28da8411c1a62cc6fb310e0057aaae12d4e219c14399002b81731f5ecc3f20b596247a367068a5c83695f7d25ffdb0583004e8e7b3812eaf57646b86709
7
+ data.tar.gz: 828253eb8e9943dd39218de79a73cb6ae2c6652b4f6e88e4aebe1b1ab5b6be44ff9aee199cee9208a8abc5f038608c5ad1ead7836799c57813df37f49ed5e0db
@@ -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.1]
7
+ - update gemspec dependency to plugins that provide the secrets helpers
8
+
9
+ ## [0.6.0]
10
+ - [#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/
11
+ - custom variables support: docs https://kubes.guru/docs/variables/basic/
12
+ - custom helpers support: docs https://kubes.guru/docs/helpers/custom/
13
+ - plugins helpers support
14
+ - generators: new resource, new helper, new variable
15
+ - setup autoloader earlier. removes need for shims
16
+ - auth login for gcr also
17
+ - fix cli -h when not within Kubes project
18
+
19
+ ## [0.5.1]
20
+ - fix deployment generator
21
+
22
+ ## [0.5.0]
23
+ - #34 Generators, docker_image helper, check project, also write full.yaml #34
24
+ - new generators: docs: https://kubes.guru/docs/generators/
25
+ - `docker_image` helper. deprecated `built_image`. `config.image` option support.
26
+ - check_project: check within a Kubes project
27
+ - job dsl
28
+ - kubes compile: auto run docker build and push when if needed
29
+ - also write .kubes/output/full.yaml
30
+
31
+ ## [0.4.7]
32
+ - #33 improve switch context: earlier and only when needed
33
+
6
34
  ## [0.4.6]
7
35
  - #32 custom helpers support
8
36
 
data/README.md CHANGED
@@ -44,8 +44,8 @@ In fact, you can use Kubes to build the files first, and then run `kubectl` dire
44
44
  Now, use `kubectl` directly in the proper order:
45
45
 
46
46
  kubectl apply -f .kubes/output/shared/namespace.yaml
47
- kubectl apply -f .kubes/output/web/deployment.yaml
48
47
  kubectl apply -f .kubes/output/web/service.yaml
48
+ kubectl apply -f .kubes/output/web/deployment.yaml
49
49
 
50
50
  You can also apply with kubes. This will compile the automatically files also.
51
51
 
@@ -55,10 +55,63 @@ The deploy command, does all 3 steps: builds the docker image, compiles the `.ku
55
55
 
56
56
  kubes deploy
57
57
 
58
+ ## Multiple Enviroments
59
+
60
+ You can easily create multiple environments with the same YAML configs. Example:
61
+
62
+ KUBES_ENV=dev kubes deploy
63
+ KUBES_ENV=prod kubes deploy
64
+
65
+ See: [Multiple Enviroments Pattern](https://kubes.guru/docs/patterns/multiple-envs/)
66
+
67
+ ## Generators: Stop Writing Boilerplate
68
+
69
+ Your time is precious. Why are we copying and pasting boilerplate structure in this day and age?
70
+
71
+ Kubes provides generators to help you get going right away.
72
+
73
+ Resources examples:
74
+
75
+ $ kubes new resource secret
76
+ create .kubes/resources/shared/secret.yaml
77
+ $ kubes new resource service_account
78
+ create .kubes/resources/shared/service_account.yaml
79
+
80
+ Kubes components examples:
81
+
82
+ $ kubes new helper
83
+ create .kubes/helpers/custom_helper.rb
84
+ $ kubes new variable
85
+ create .kubes/variables/dev.rb
86
+ $
87
+
88
+ ## Features
89
+
90
+ * Automation: [Builds the Docker image](https://kubes.guru/docs/config/docker/) and updates the compiled YAML files
91
+ * 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.
92
+ * Layering: Use the same Kubernetes YAML to build multiple environments like dev and prod with [layering](https://kubes.guru/docs/layering/).
93
+ * 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.
94
+ * Generators: Kubes ships with a few generators to help you get building with Kubernetes quickly. See: [Generator Docs](https://kubes.guru/docs/generators/).
95
+ * CLI Customizations: You can customize the [cli args](https://kubes.guru/docs/config/args/kubectl/).
96
+ * 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.
97
+ * 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.
98
+ * 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/).
99
+ * 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/).
100
+ * 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/).
101
+
58
102
  ## Installation
59
103
 
60
104
  Install with:
61
105
 
62
106
  gem install kubes
63
107
 
108
+ ## Comparison
109
+
110
+ Here are some useful comparisons to help you compare Kubes vs other tools in the ecosystem:
111
+
112
+ * 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)
113
+ * [Kubes vs Custom Solution](https://kubes.guru/docs/vs/custom/)
114
+ * [Kubes vs Helm](https://kubes.guru/docs/vs/helm/)
115
+ * [Kubes vs Kustomize](https://kubes.guru/docs/vs/kustomize/)
116
+
64
117
  For more info: [kubes.guru](https://kubes.guru)
@@ -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
  ```
@@ -51,13 +51,13 @@ You can also use a block form to create multiple resources. You name the resour
51
51
  deployment "demo-web" do
52
52
  labels(role: "web")
53
53
  replicas 1
54
- image built_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
54
+ image docker_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
55
55
  end
56
56
 
57
57
  deployment "demo-web-2" do
58
58
  labels(role: "web")
59
59
  replicas 1
60
- image built_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
60
+ image docker_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
61
61
  end
62
62
  ```
63
63
 
@@ -70,7 +70,7 @@ You can also mix and matched resources. When you use the block form, the file na
70
70
  deployment "demo-web" do
71
71
  labels(role: "web")
72
72
  replicas 1
73
- image built_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
73
+ image docker_image # IE: user/demo:kubes-2020-06-13T19-55-16-43afc6e
74
74
  end
75
75
 
76
76
  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
+ ```
@@ -12,3 +12,4 @@ List of AWS helpers:
12
12
  ## Notes
13
13
 
14
14
  * By default, `KubeGoogle.logger = Kubes.logger`. This means, you can set `logger.level = "debug"` in `.kubes/config.rb` to see more details.
15
+ * The AWS helpers are provided by the [boltops-tools/kubes_aws](https://github.com/boltops-tools/kubes_aws) library.
@@ -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 %}