kubes 0.8.4 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f78e6b8aa9788c03dbc38391b936a5792353249c5d9e743d7ebf87fc52c74488
4
- data.tar.gz: a77d273302faaf434f751f36305cfafc9e7e5e7491db010f1468088d4806f8b7
3
+ metadata.gz: a2acdb3453d1240b7be08aa022731c41ffa227a9a0ca5e5fdf28774f2a9be6c6
4
+ data.tar.gz: 418fcd60375f6379c14e32432c8b202562ae87477dd93480987ef02a43e1d7a8
5
5
  SHA512:
6
- metadata.gz: 1241bd270d3212d96a04b5e1edbd1085efee439105fff63896ec2b06dc84520e02ffbe7fd0830db246979c201c279c63adfcd41332e809cfbc3997b205a0459b
7
- data.tar.gz: 6382b7380c842621e54f388e7d66fcf981e407a3952928996148be0037d0321e14779ea79a016991c0b5d0b0c5c02dccfe9de3ef77a62295a62fe549fa2a335c
6
+ metadata.gz: 471c5ef845fc8b904cfb3299ec42a08e68a5fb801639af39e683d379e9de20f5b0c89394d73bae34dc6cc06d0292ec5fd4216f7660c76bea2ba785048c5e86bb
7
+ data.tar.gz: a41933ec8b9f216fffd3022856e36cdf9e0555bdb460562e61525a2829e34546f50cfb01fc8ebe058bf4e6aeba49b22d5b256881c21ae92b6e94891a16e0496b
data/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
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.8.7] - 2022-06-21
7
+ - [#63](https://github.com/boltops-tools/kubes/pull/63) remove kubes meta from yaml
8
+ - adjust app layer. keep old layer also for now though
9
+
10
+ ## [0.8.6] - 2022-02-16
11
+ - [#62](https://github.com/boltops-tools/kubes/pull/62) config map files: add Kubes.app txt layer
12
+
13
+ ## [0.8.5] - 2022-02-16
14
+ - [#61](https://github.com/boltops-tools/kubes/pull/61) add erb support for config_map_files and generic_secret_data helpers
15
+
6
16
  ## [0.8.4] - 2022-02-16
7
17
  - bump kubes_aws and kubes_google dependencies
8
18
 
@@ -6,6 +6,13 @@ categories: hooks
6
6
 
7
7
  {% include config/hooks/generator.md type="docker" %}
8
8
 
9
+ ## Docker Hooks
10
+
11
+ Hook | Description
12
+ ---|---
13
+ build | When kubes builds Docker image.
14
+ push | When kubes pushes the Docker image.
15
+
9
16
  Here are some examples of running custom hooks before and after the docker commands.
10
17
 
11
18
  ## Build Hooks
@@ -17,7 +17,7 @@ apply | When kubes runs all the `kubectl apply` commands.
17
17
  delete | When kubes runs all the `kubectl delete` commands.
18
18
  prune | When kubes prunes. IE: To clean old secrets.
19
19
 
20
- ## Lifecycle At Kubes Level
20
+ ## Kubes Lifecyle Level
21
21
 
22
22
  These lifecycle points occur at a higher-level than the `kubectl` commands. Here's an example to help explain:
23
23
 
@@ -4,7 +4,7 @@ nav_text: Secrets Data
4
4
  categories: helpers-aws
5
5
  ---
6
6
 
7
- The `aws_secret_data` helper fetches secret data that is one single file from AWS Secrets.
7
+ The `aws_secret_data` helper fetches secret data that is designed to be in one single file from AWS Secrets.
8
8
 
9
9
  ## Example
10
10
 
@@ -53,11 +53,12 @@ data:
53
53
 
54
54
  ## Layering Details
55
55
 
56
- Layering for Config Map Files and also supports app-scoped layers.
56
+ Config Map Files also supports App-Scoped Layering.
57
57
 
58
58
  Name | Example
59
59
  --- | ---
60
60
  configmap root | .kubes/resources/shared/config_map/{base,dev}.txt
61
- configmap app-scoped | .kubes/resources/shared/config_map/app1/{base,dev}.txt
61
+ configmap app file | .kubes/resources/shared/config_map/app1.txt
62
+ configmap app folder | .kubes/resources/shared/config_map/app1/{base,dev}.txt
62
63
 
63
64
  So if `KUBES_APP=app1`, then the app-scoped layer is also used. This handles the [Central Deployer Pattern]({% link _docs/patterns/central-deployer.md %}).
@@ -4,7 +4,7 @@ nav_text: Secrets Data
4
4
  categories: helpers-google
5
5
  ---
6
6
 
7
- The `google_secret_data` helper fetches secret data that is one single file from Google Secrets.
7
+ The `google_secret_data` helper fetches secret data that is designed to be in one single file from Google Secrets.
8
8
 
9
9
  ## Example
10
10
 
@@ -16,7 +16,7 @@ Now, use `kubectl` directly and apply them in the proper order:
16
16
  kubectl apply -f .kubes/output/web/service.yaml
17
17
  kubectl apply -f .kubes/output/web/deployment.yaml
18
18
 
19
- The deploy command simpifily does all 3 steps: build, compile, and apply.
19
+ The deploy command simply does all 3 steps: build, compile, and apply.
20
20
 
21
21
  kubes deploy
22
22
 
@@ -9,7 +9,7 @@ If you already a project with an existing Dockerfile, you can use that. If you d
9
9
 
10
10
  {% include learn/repos.md %}
11
11
 
12
- Let's generate a starter project:
12
+ Let's initialize a starter kubes project. This is similar to a `git init`.
13
13
 
14
14
  $ kubes init --app demo --repo $REPO --type dsl
15
15
  create .kubes/config.rb
@@ -9,7 +9,7 @@ If you already a project with an existing Dockerfile, you can use that. If you d
9
9
 
10
10
  {% include learn/repos.md %}
11
11
 
12
- Let's generate a starter project:
12
+ Let's initialize a starter kubes project. This is similar to a `git init`.
13
13
 
14
14
  $ kubes init --app demo --repo $REPO
15
15
  create Dockerfile
@@ -1,11 +1,11 @@
1
- * Automation: [Builds the Docker image]({% link _docs/config/docker.md %}) and updates the compiled YAML files
2
- * 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.
3
- * Layering: Use the same Kubernetes YAML to build multiple environments like dev and prod with [layering]({% link _docs/layering.md %}).
4
- * Secrets: Use helpers like [aws_secret]({% link _docs/helpers/aws/secrets.md %}), [aws_ssm]({% link _docs/helpers/aws/ssm.md %}), and [google_secret]({% link _docs/helpers/google/secrets.md %}) to build Kubernetes secrets.yaml from secret providers designed for it.
5
- * Generators: Kubes ships with a few generators to help you get building with Kubernetes quickly. See: [Generator Docs]({% link _docs/generators.md %}).
6
- * CLI Customizations: You can customize the [cli args]({% link _docs/config/args/kubectl.md %}).
7
- * Hooks: You can also run [hooks]({% link _docs/config/hooks.md %}) before and after [kubes]({% link _docs/config/hooks/kubes.md %}) and [kubectl]({% link _docs/config/hooks/kubectl.md %}) commands.
8
- * 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.
9
- * 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 %}).
10
- * 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 %}).
11
- * 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 %}).
1
+ * **Automation**: [Builds the Docker image]({% link _docs/config/docker.md %}) and updates the compiled YAML files
2
+ * **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.
3
+ * **Layering**: Use the same Kubernetes YAML to build multiple environments like dev and prod with [layering]({% link _docs/layering.md %}).
4
+ * **Secrets**: Use helpers like [aws_secret]({% link _docs/helpers/aws/secrets.md %}), [aws_ssm]({% link _docs/helpers/aws/ssm.md %}), and [google_secret]({% link _docs/helpers/google/secrets.md %}) to build Kubernetes secrets.yaml from secret providers designed for it.
5
+ * **Generators**: Kubes ships with a few generators to help you get building with Kubernetes quickly. See: [Generator Docs]({% link _docs/generators.md %}).
6
+ * **CLI Customizations**: You can customize the [cli args]({% link _docs/config/args/kubectl.md %}).
7
+ * **Hooks**: You can also run [hooks]({% link _docs/config/hooks.md %}) before and after [kubes]({% link _docs/config/hooks/kubes.md %}) and [kubectl]({% link _docs/config/hooks/kubectl.md %}) commands.
8
+ * **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.
9
+ * **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 %}).
10
+ * **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 %}).
11
+ * **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 %}).
@@ -2,6 +2,8 @@
2
2
 
3
3
  The `config.rb` is where you can configure Kubes settings.
4
4
 
5
+ .kubes/config.rb
6
+
5
7
  ```ruby
6
8
  Kubes.configure do |config|
7
9
  config.repo = "112233445566.dkr.ecr.us-west-2.amazonaws.com/demo" # may be gcr.io/project-123/demo
@@ -13,7 +15,7 @@ end
13
15
 
14
16
  This is where the `--repo` from `kubes init` got saved. The other options are covered in the [Env Config Docs]({% link _docs/config/env.md %}).
15
17
 
16
- ## Dockerfie
18
+ ## Dockerfile
17
19
 
18
20
  The `Dockerfile` is a simple starter example that just runs nginx
19
21
 
@@ -411,6 +411,7 @@ ul.toc {
411
411
  .learn {
412
412
  img {
413
413
  max-width: 600px;
414
+ max-width: 100%;
414
415
  }
415
416
  .note {
416
417
  font-size: 0.9em;
@@ -10,6 +10,7 @@ module Kubes::Compiler::Shared::Helpers
10
10
  ]
11
11
  if Kubes.app
12
12
  layers += [
13
+ [shared_config_map, "#{Kubes.app}.txt"],
13
14
  [shared_config_map, Kubes.app, "base.txt"],
14
15
  [shared_config_map, Kubes.app, "#{Kubes.env}.txt"],
15
16
  ]
@@ -18,9 +19,10 @@ module Kubes::Compiler::Shared::Helpers
18
19
  data = {}
19
20
  layers.each do |path|
20
21
  next unless File.exist?(path)
21
- lines = IO.readlines(path)
22
+ text = RenderMePretty.result(path, context: self)
23
+ lines = text.split("\n")
22
24
  lines.each do |line|
23
- key, value = line.split('=').map(&:strip)
25
+ key, value = parse_env_like_line(line)
24
26
  data[key] = value
25
27
  end
26
28
  end
@@ -6,17 +6,25 @@ module Kubes::Compiler::Shared::Helpers
6
6
  indent = options[:indent] || 2
7
7
  base64 = options[:base64].nil? ? true : options[:base64]
8
8
 
9
- full_data = send(plugin_secret_method, name, base64: false)
9
+ text = send(plugin_secret_method, name, base64: false)
10
+ path = create_generic_secret_data_temp_file(text)
11
+ text = RenderMePretty.result(path, context: self)
10
12
  spacing = " " * indent
11
- lines = full_data.split("\n")
13
+ lines = text.split("\n")
12
14
  new_lines = lines.map do |line|
13
- key, value = line.split('=')
15
+ key, value = parse_env_like_line(line)
14
16
  value = encode64(value) if base64
15
17
  "#{spacing}#{key}: #{value}"
16
18
  end
17
19
  new_lines.join("\n")
18
20
  end
19
21
 
22
+ def parse_env_like_line(line)
23
+ key, *rest = line.split('=')
24
+ value = rest.join('=')
25
+ [key, value]
26
+ end
27
+
20
28
  def encode64(v)
21
29
  Base64.strict_encode64(v.to_s).strip
22
30
  end
@@ -25,5 +33,13 @@ module Kubes::Compiler::Shared::Helpers
25
33
  def decode64(v)
26
34
  Base64.strict_decode64(v)
27
35
  end
36
+
37
+ private
38
+ def create_generic_secret_data_temp_file(text)
39
+ path = "/tmp/kubes/text.erb"
40
+ FileUtils.mkdir_p(File.dirname(path))
41
+ IO.write(path, text)
42
+ path
43
+ end
28
44
  end
29
45
  end
@@ -22,6 +22,7 @@ class Kubes::Compiler::Strategy
22
22
 
23
23
  def content
24
24
  data = filter_skip(@data)
25
+ data.each { |item| item.delete('kubes') }
25
26
  return if data.empty?
26
27
  result = data.size == 1 ? data.first : data
27
28
  yaml_dump(result)
data/lib/kubes/config.rb CHANGED
@@ -96,8 +96,12 @@ module Kubes
96
96
  evaluate_file(".kubes/config.rb")
97
97
  evaluate_file(".kubes/config/env/#{Kubes.env}.rb")
98
98
  if Kubes.app
99
+ # TODO: deprecate
99
100
  evaluate_file(".kubes/config/env/#{Kubes.app}.rb")
100
101
  evaluate_file(".kubes/config/env/#{Kubes.app}/#{Kubes.env}.rb")
102
+ # newer
103
+ evaluate_file(".kubes/config/app/#{Kubes.app}.rb")
104
+ evaluate_file(".kubes/config/app/#{Kubes.app}/#{Kubes.env}.rb")
101
105
  end
102
106
  Kubes::Plugin.plugins.each do |klass|
103
107
  # klass: IE: KubesAws, KubesGoogle
data/lib/kubes/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kubes
2
- VERSION = "0.8.4"
2
+ VERSION = "0.8.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-16 00:00:00.000000000 Z
11
+ date: 2022-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -851,7 +851,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
851
851
  - !ruby/object:Gem::Version
852
852
  version: '0'
853
853
  requirements: []
854
- rubygems_version: 3.2.32
854
+ rubygems_version: 3.3.12
855
855
  signing_key:
856
856
  specification_version: 4
857
857
  summary: 'Kubernetes Deployment Tool: build docker image, compile Kubernetes YAML