kubes 0.3.4 → 0.3.5

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: c14d045b8c029e76e1c001f26a0b77c97ecdabc45ddc964660372f2170f95690
4
- data.tar.gz: 36a0b622a75cc18e74d78537a2a3f421e15de150cb89978434a58d31c37b799b
3
+ metadata.gz: d239ce306b5a9eea427cab3ec5ca5f753f0eae3d1822fce65017c23172779562
4
+ data.tar.gz: 3d97c8d85e6f5bfd02babaf14140f186ebd22c3981fa8eed76ddcdbe7f24958d
5
5
  SHA512:
6
- metadata.gz: cd0f40a09c2909be4820c0575d6a8ef850b1977e21cd5d040cb82cb11411500a136608035635f743cb1a967116913856fc5e7997f3fef511b5c07d94d5fe4458
7
- data.tar.gz: 9f29e9bf7a4615bb2a9864b9acdc9aa83b70583b5743decd5e8c6bac1b85b49bfc90a724403765afe2a86fa1cd1819cccedc53b7b91d6e858a20ececf2630f6a
6
+ metadata.gz: 74b0ad9bc27e15f1b8742d26f6b2c09e11e990a69623a7e0b54d12565dc08e3dec5d0c640bfd4f5457aa09f0069c0010a78d39dedc18bd9a2223ebdb34be9c31
7
+ data.tar.gz: 7f3508f0d3650677a48f1f0069f71b1801ddd0a760f052f725a81f564fd144b6eecbd8c08e79fd2e9ec571a0ada2308d4f84bdfbc6971f66a80a20eec8ffbaae
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.3.5]
7
+ - #25 small fixes: show pod and fetch items nil
8
+
6
9
  ## [0.3.4]
7
10
  - #24 fix namespace newline and logs for single container
8
11
  - #23 init namespace option
@@ -38,6 +38,8 @@ options:
38
38
  substitution_option: 'ALLOW_LOOSE'
39
39
  ```
40
40
 
41
+ Make sure to replace the substitutions with your own values. IE: _GCP_REGION, _GKE_CLUSTER, _KUBES_ENV, etc.
42
+
41
43
  ## Run CloudBuild
42
44
 
43
45
  Run cloudbuild with:
@@ -55,4 +55,4 @@ Kubes.configure do |config|
55
55
  end
56
56
  ```
57
57
 
58
- For more details refer to the [Auto Context Docs]({% link _docs/auto-context.md %}).
58
+ For more details refer to the [Auto Context Docs]({% link _docs/misc/auto-context.md %}).
@@ -1,61 +1,10 @@
1
1
  ---
2
- title: Kubectl Config
2
+ title: Kubectl Customizations
3
3
  ---
4
4
 
5
5
  ## General
6
6
 
7
7
  Kubes calls out the `kubectl` command. You can customize the command.
8
8
 
9
- ## Args
10
-
11
- Here are some examples of customizing the kubectl args.
12
-
13
- .kubes/config/kubectl/args.rb
14
-
15
- ```ruby
16
- command("apply",
17
- args: ["--validate=true"],
18
- )
19
-
20
- command("delete",
21
- args: ["--grace-period=-1"],
22
- )
23
- ```
24
-
25
- ## Hooks
26
-
27
- Here are some examples of running custom hooks before and after the kubectl commands.
28
-
29
- .kubes/config/kubectl/hooks.rb
30
-
31
- ```ruby
32
- before("apply",
33
- execute: "kubectl apply -f .kubes/shared/namespace.yaml",
34
- )
35
-
36
- after("delete",
37
- execute: "echo 'delete hook',
38
- )
39
- ```
40
-
41
- You can use hooks to do things that may not make sense to do in the `.kubes/resources` definition. Here's an example of automatically creating the namespace.
42
-
43
- .kubes/shared/namespace.yaml
44
-
45
- ```yaml
46
- apiVersion: v1
47
- kind: Namespace
48
- metadata:
49
- name: demo
50
- ```
51
-
52
- ### exit on fail
53
-
54
- By default, if the hook commands fail, then terraspace will exit with the original hook error code. You can change this behavior with the `exit_on_fail` option.
55
-
56
- ```ruby
57
- before("apply"
58
- execute: "/command/will/fail/but/will/continue",
59
- exit_on_fail: false,
60
- )
61
- ```
9
+ * [Args]({% link _docs/config/kubectl/args.md %}): Customize the CLI args.
10
+ * [Hooks]({% link _docs/config/kubectl/hooks.md %}): Run hooks before and after the kubectl commands.
@@ -0,0 +1,17 @@
1
+ ---
2
+ title: Kubectl Args
3
+ ---
4
+
5
+ Here are some examples of customizing the kubectl args.
6
+
7
+ .kubes/config/kubectl/args.rb
8
+
9
+ ```ruby
10
+ command("apply",
11
+ args: ["--validate=true"],
12
+ )
13
+
14
+ command("delete",
15
+ args: ["--grace-period=-1"],
16
+ )
17
+ ```
@@ -0,0 +1,39 @@
1
+ ---
2
+ title: Kubectl Hooks
3
+ ---
4
+
5
+ Here are some examples of running custom hooks before and after the kubectl commands.
6
+
7
+ .kubes/config/kubectl/hooks.rb
8
+
9
+ ```ruby
10
+ before("apply",
11
+ execute: "kubectl apply -f .kubes/shared/namespace.yaml",
12
+ )
13
+
14
+ after("delete",
15
+ execute: "echo 'delete hook',
16
+ )
17
+ ```
18
+
19
+ You can use hooks to do things that may not make sense to do in the `.kubes/resources` definition. Here's an example of automatically creating the namespace.
20
+
21
+ .kubes/shared/namespace.yaml
22
+
23
+ ```yaml
24
+ apiVersion: v1
25
+ kind: Namespace
26
+ metadata:
27
+ name: demo
28
+ ```
29
+
30
+ ### exit on fail
31
+
32
+ By default, if the hook commands fail, then terraspace will exit with the original hook error code. You can change this behavior with the `exit_on_fail` option.
33
+
34
+ ```ruby
35
+ before("apply"
36
+ execute: "/command/will/fail/but/will/continue",
37
+ exit_on_fail: false,
38
+ )
39
+ ```
@@ -3,7 +3,7 @@ title: BackendConfig
3
3
  categories: dsl
4
4
  ---
5
5
 
6
- A BackendConfig is [custom resource definitions (CRDs)](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) that allow you to further customize the load balancer.
6
+ A [BackendConfig](https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-features#create_backendconfig) is [custom resource definitions (CRDs)](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) that allow you to further customize the load balancer.
7
7
 
8
8
  Here's an example of a BackendConfig.
9
9
 
@@ -9,7 +9,8 @@ title: What is Kubes?
9
9
  * Automation: [Builds the Docker image]({% link _docs/config/docker.md %}) and updates the compiled YAML files
10
10
  * 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.
11
11
  * Layering: Use the same Kubernetes YAML to build multiple environments like dev and prod with [layering]({% link _docs/layering.md %}).
12
- * CLI Customizations: You can customize the [cli args]({% link _docs/config/kubectl.md %}). You can also run hooks before and after kubectl commands.
12
+ * CLI Customizations: You can customize the [cli args]({% link _docs/config/kubectl/args.md %}). You can also run [hooks]({% link _docs/config/kubectl/hooks.md %}) before and after kubectl commands.
13
13
  * 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.
14
- * Kustomize Support: If you’re a kustomization user, you can use it with Kubes. More details in [Kustomize Support Docs]({% link _docs/kustomize.md %}).
15
- * 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/auto-context.md %}).
14
+ * 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 %}).
15
+ * 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 %}).
16
+ * 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 %}).
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: Separate Steps
3
+ ---
4
+
5
+ Sometimes you may want to run the 3 separate kubes steps directly. This may be useful if you are setting up CI/CD and need more control over the build process. Here are the 3 main steps:
6
+
7
+ To build and push the docker image:
8
+
9
+ kubes docker build
10
+ kubes docker push
11
+
12
+ Note, you must run a `kubes docker build` at least once. As the build step will store the image name in a `.kubes/state/docker_image.txt ` file for later use.
13
+
14
+ To compile the Kubernetes YAML files.
15
+
16
+ kubes compile
17
+
18
+ To apply the Kubernetes YAML files in the correct order and create resources on the cluster:
19
+
20
+ kubes apply
21
+
@@ -55,7 +55,12 @@
55
55
  <ul>
56
56
  <li><a href="{% link _docs/config/docker.md %}">Docker</a></li>
57
57
  <li><a href="{% link _docs/config/env.md %}">Env</a></li>
58
- <li><a href="{% link _docs/config/kubectl.md %}">Kubectl</a></li>
58
+ <li><a href="{% link _docs/config/kubectl.md %}">Kubectl</a>
59
+ <ul>
60
+ <li><a href="{% link _docs/config/kubectl/args.md %}">Args</a></li>
61
+ <li><a href="{% link _docs/config/kubectl/hooks.md %}">Hooks</a></li>
62
+ </ul>
63
+ </li>
59
64
  <li><a href="{% link _docs/config/builder.md %}">Builder</a></li>
60
65
  </ul>
61
66
  </li>
@@ -92,8 +97,12 @@
92
97
  <li><a href="{% link _docs/extra-env/dsl.md %}">DSL</a></li>
93
98
  </ul>
94
99
  </li>
95
- <li><a href="{% link _docs/kustomize.md %}">Kustomize Support</a></li>
96
- <li><a href="{% link _docs/auto-context.md %}">Auto Context</a></li>
100
+ <li>Misc
101
+ <ul>
102
+ <li><a href="{% link _docs/misc/kustomize.md %}">Kustomize Support</a></li>
103
+ <li><a href="{% link _docs/misc/separate-steps.md %}">Separate Steps</a></li>
104
+ <li><a href="{% link _docs/misc/auto-context.md %}">Auto Context</a></li>
105
+ </ul>
97
106
  <li>CI/CD
98
107
  <ul>
99
108
  <li><a href="{% link _docs/ci/cloudbuild.md %}">CloudBuild</a></li>
@@ -21,13 +21,20 @@ The exec command finds the latest pod from the deployment and runs `kubectl exec
21
21
 
22
22
  ## Multiple Deployments
23
23
 
24
- If you have have multiple deployments in your `.kubes/resources` then the command will use the first deployment by default. You can specify the specfic deployment with the `--name` option. Examples:
24
+ If you have have multiple deployments in your `.kubes/resources` then the command will use the first deployment by default. You can specify the specfic deployment with the `--name` or `-n` option. Examples:
25
25
 
26
- kubes exec --name demo-web
27
- kubes exec --name demo-clock
28
- kubes exec --name demo-worker
29
- kubes exec --name demo-web sh
30
- kubes exec --name demo-web ls -l
26
+ kubes exec --name web
27
+ kubes exec -n web
28
+ kubes exec -n clock
29
+ kubes exec -n worker
30
+ kubes exec -n web sh
31
+ kubes exec -n web ls -l
32
+
33
+ ## Multiple Pod Containers
34
+
35
+ If you have have multiple containers in your pod. You can specify the specfic container with the `--container` or `-c` option. Examples:
36
+
37
+ kubes exec --name web
31
38
 
32
39
 
33
40
  ## Options
@@ -36,6 +43,7 @@ If you have have multiple deployments in your `.kubes/resources` then the comman
36
43
  [--compile], [--no-compile] # whether or not to compile the .kube/resources
37
44
  # Default: true
38
45
  n, [--name=NAME] # deployment name to use. IE: demo-web
46
+ c, [--container=CONTAINER] # Container name. If omitted, the first container in the pod will be chosen
39
47
  [--verbose], [--no-verbose]
40
48
  [--noop], [--no-noop]
41
49
  ```
@@ -20,6 +20,7 @@ a, --app=APP # Docker repo name. Example: web. Generates .ku
20
20
  t, [--type=TYPE] # Type: dsl or yaml
21
21
  # Default: yaml
22
22
  --repo=REPO # Docker repo name. Example: user/repo. Configures .kubes/config.rb
23
+ n, [--namespace=NAMESPACE] # Namespace to use, defaults to the app option
23
24
  [--verbose], [--no-verbose]
24
25
  [--noop], [--no-noop]
25
26
  ```
@@ -18,6 +18,7 @@ logs from all deployment pods
18
18
  [--compile], [--no-compile] # whether or not to compile the .kube/resources
19
19
  # Default: true
20
20
  n, [--name=NAME] # deployment name to use. IE: demo-web
21
+ c, [--container=CONTAINER] # Container name. If omitted, the first container in the pod will be chosen
21
22
  f, [--follow], [--no-follow] # Follow logs
22
23
  # Default: true
23
24
  [--verbose], [--no-verbose]
@@ -3,8 +3,9 @@ class Kubes::CLI
3
3
  def run
4
4
  compile
5
5
  Kubes::Kubectl.run(:get, @options)
6
+ return unless @options[:show_pods]
6
7
  pods = Kubes::Kubectl::Fetch::Pods.new(@options)
7
- pods.show if @options[:show_pods]
8
+ pods.show
8
9
  end
9
10
  end
10
11
  end
@@ -18,7 +18,7 @@ module Kubes::Kubectl::Fetch
18
18
  kubectl = Kubes::Kubectl.new(:get, @options.merge(o)) # kubes get -f .kubes/output
19
19
  resp = kubectl.run
20
20
  data = JSON.load(resp)
21
- data['items']
21
+ data['items'] || [] # Note: When fetching only 1 resource, items is not part of structure
22
22
  end
23
23
  end
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module Kubes
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  name "web"
2
2
  labels(role: "web")
3
3
 
4
- replicas 1
4
+ replicas 1 # overridden on a env basis
5
5
  image built_image # IE: user/<%= app %>:kubes-2020-06-13T19-55-16-43afc6e
6
6
 
7
7
  # revisionHistoryLimit 1 # uncomment to reduce old ReplicaSets, default is 10 https://bit.ly/3hqrzyP
@@ -5,7 +5,7 @@ metadata:
5
5
  labels:
6
6
  role: web
7
7
  spec:
8
- replicas: 1
8
+ replicas: 1 # overridden on a env basis
9
9
  selector:
10
10
  matchLabels:
11
11
  role: web
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.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-11 00:00:00.000000000 Z
11
+ date: 2020-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -232,13 +232,14 @@ files:
232
232
  - docs/README.md
233
233
  - docs/Rakefile
234
234
  - docs/_config.yml
235
- - docs/_docs/auto-context.md
236
235
  - docs/_docs/ci/cloudbuild.md
237
236
  - docs/_docs/config.md
238
237
  - docs/_docs/config/builder.md
239
238
  - docs/_docs/config/docker.md
240
239
  - docs/_docs/config/env.md
241
240
  - docs/_docs/config/kubectl.md
241
+ - docs/_docs/config/kubectl/args.md
242
+ - docs/_docs/config/kubectl/hooks.md
242
243
  - docs/_docs/contributing.md
243
244
  - docs/_docs/dsl.md
244
245
  - docs/_docs/dsl/multiple-resources.md
@@ -269,7 +270,6 @@ files:
269
270
  - docs/_docs/intro/ordering.md
270
271
  - docs/_docs/intro/ordering/custom.md
271
272
  - docs/_docs/intro/structure.md
272
- - docs/_docs/kustomize.md
273
273
  - docs/_docs/layering.md
274
274
  - docs/_docs/layering/dsl.md
275
275
  - docs/_docs/layering/merge.md
@@ -294,6 +294,9 @@ files:
294
294
  - docs/_docs/learn/yaml/next-steps.md
295
295
  - docs/_docs/learn/yaml/review-project.md
296
296
  - docs/_docs/learn/yaml/update.md
297
+ - docs/_docs/misc/auto-context.md
298
+ - docs/_docs/misc/kustomize.md
299
+ - docs/_docs/misc/separate-steps.md
297
300
  - docs/_docs/next-steps.md
298
301
  - docs/_docs/patterns.md
299
302
  - docs/_docs/patterns/clock-web-worker.md