kubes 0.2.4 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/docs/_docs/auto-context.md +4 -4
  4. data/docs/_docs/config/builder.md +46 -0
  5. data/docs/_docs/config/env.md +3 -3
  6. data/docs/_docs/dsl/resources/service.md +21 -5
  7. data/docs/_docs/learn/dsl/deploy.md +2 -0
  8. data/docs/_docs/learn/dsl/new-project.md +1 -2
  9. data/docs/_docs/learn/yaml/deploy.md +2 -0
  10. data/docs/_docs/learn/yaml/new-project.md +1 -2
  11. data/docs/_includes/intro/install.md +5 -1
  12. data/docs/_includes/learn/cluster.md +21 -4
  13. data/docs/_includes/learn/repo +0 -0
  14. data/docs/_includes/learn/repos.md +10 -0
  15. data/docs/_includes/learn/review.md +2 -2
  16. data/docs/_includes/sidebar.html +1 -0
  17. data/docs/_reference/kubes-apply.md +2 -2
  18. data/docs/_reference/kubes-delete.md +1 -1
  19. data/docs/_reference/kubes-deploy.md +1 -1
  20. data/docs/_reference/kubes-describe.md +24 -0
  21. data/docs/_reference/kubes-exec.md +42 -0
  22. data/docs/_reference/kubes-get.md +27 -0
  23. data/docs/_reference/kubes-init.md +1 -1
  24. data/docs/_reference/kubes-logs.md +26 -0
  25. data/docs/_sass/theme.scss +2 -1
  26. data/docs/bin/web +1 -1
  27. data/docs/img/logos/kubes-white.png +0 -0
  28. data/docs/index.html +2 -2
  29. data/docs/reference.md +4 -0
  30. data/lib/kubes/cli.rb +22 -0
  31. data/lib/kubes/cli/apply.rb +1 -1
  32. data/lib/kubes/cli/base.rb +4 -0
  33. data/lib/kubes/cli/build.rb +2 -2
  34. data/lib/kubes/cli/delete.rb +7 -2
  35. data/lib/kubes/cli/describe.rb +1 -1
  36. data/lib/kubes/cli/docker.rb +2 -2
  37. data/lib/kubes/cli/exec.rb +34 -0
  38. data/lib/kubes/cli/get.rb +3 -1
  39. data/lib/kubes/cli/help/exec.md +24 -0
  40. data/lib/kubes/cli/logs.rb +15 -0
  41. data/lib/kubes/compiler/dsl/syntax/deployment.rb +85 -2
  42. data/lib/kubes/compiler/dsl/syntax/service.rb +11 -0
  43. data/lib/kubes/config.rb +2 -0
  44. data/lib/kubes/docker.rb +19 -0
  45. data/lib/kubes/docker/strategy/build/base.rb +24 -0
  46. data/lib/kubes/docker/strategy/build/docker.rb +11 -0
  47. data/lib/kubes/docker/strategy/build/gcloud.rb +10 -0
  48. data/lib/kubes/docker/strategy/hooks.rb +9 -0
  49. data/lib/kubes/docker/{base.rb → strategy/image_name.rb} +19 -32
  50. data/lib/kubes/docker/strategy/push/base.rb +9 -0
  51. data/lib/kubes/docker/{push.rb → strategy/push/docker.rb} +2 -5
  52. data/lib/kubes/docker/strategy/push/gcloud.rb +9 -0
  53. data/lib/kubes/docker/strategy/utils.rb +9 -0
  54. data/lib/kubes/hooks/builder.rb +2 -1
  55. data/lib/kubes/kubectl.rb +15 -3
  56. data/lib/kubes/kubectl/batch.rb +8 -1
  57. data/lib/kubes/kubectl/fetch/base.rb +24 -0
  58. data/lib/kubes/kubectl/fetch/deployment.rb +34 -0
  59. data/lib/kubes/kubectl/fetch/pods.rb +21 -0
  60. data/lib/kubes/util/sh.rb +1 -0
  61. data/lib/kubes/version.rb +1 -1
  62. data/lib/templates/dsl/.kubes/resources/web/deployment.rb +2 -1
  63. data/lib/templates/dsl/.kubes/resources/web/service.rb +1 -1
  64. metadata +26 -5
  65. data/lib/kubes/docker/build.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d2e75bd0d156b889fcbd5a55389d335e4509e2c27bc667940bfd87155b3d9a0
4
- data.tar.gz: f13237e1d8fa442d2b1a1ed07d7e209b3054cf3cdfee8f68dab20e3358352add
3
+ metadata.gz: 717e82d009d9109cbd891aa3881a0ab645fca4388a0268b979bd80b6c65b4b5a
4
+ data.tar.gz: bf0fa4160bcc4592e8ec04e4aa408f36797c0486fe2265ee9aee2406b152502a
5
5
  SHA512:
6
- metadata.gz: '09576784450fc73c4846f7803c375542de5ed1f37bda86cd8cd8e61cf53dfa774192b8648d9b207180b9681a4e787ea0ade6211d02eedcd63a11051c694bb0a1'
7
- data.tar.gz: 13219946a970eb6e476902b09971ae832b47a8cddf0ebc73ab68a079de2d7a67e50a539b8784731d67cf5037c677c811408db6e3cbb8b7eea528bec5588784a4
6
+ metadata.gz: 459680ca83a280070c044ada5ff57a12c960e92d6c5d4a4c27f1fed9aca27047e6eb31fef3d24697be9f5f30cb745fac450062d7e0d5cdafbb37997c41f7b91f
7
+ data.tar.gz: 8530622fe5dd61e41c20213b11b296964c14dd5ef7a7510a5df5e6bbe51d4dc3be6dae763bac4faa3784fea1530f4680d2fb24806ed8fc08e283595b315be553
@@ -3,6 +3,23 @@
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.2]
7
+ - #21 add namespace to logs command
8
+
9
+ ## [0.3.1]
10
+ - #20 improve sidecar support. kubes exec -c option also
11
+
12
+ ## [0.3.0]
13
+ - #19 new commands: exec, logs
14
+ - delete preview
15
+ - show pods as part of get
16
+
17
+ ## [0.2.6]
18
+ - #18 gcloud builder. change to config.builder
19
+
20
+ ## [0.2.5]
21
+ - #17 cloudbuild build strategy
22
+
6
23
  ## [0.2.4]
7
24
  - #16 google cloudbuild support & docs: add Dockerfile for kubes as a docker entrypoint
8
25
 
@@ -22,7 +22,7 @@ You can override configs on a per-env basis with `config/env` files. Examples:
22
22
  ```ruby
23
23
  Kubes.configure do |config|
24
24
  config.repo = "222222222222.dkr.ecr.us-west-2.amazonaws.com/demo"
25
- config.kubectl.context = "dev-services"
25
+ config.kubectl.context = "dev-cluster"
26
26
  end
27
27
  ```
28
28
 
@@ -31,7 +31,7 @@ end
31
31
  ```ruby
32
32
  Kubes.configure do |config|
33
33
  config.repo = "333333333333.dkr.ecr.us-west-2.amazonaws.com/demo"
34
- config.kubectl.context = "prod-services"
34
+ config.kubectl.context = "prod-cluster"
35
35
  end
36
36
  ```
37
37
 
@@ -39,8 +39,8 @@ end
39
39
 
40
40
  With this setup, when you deploy with kubes, it will automatically switch the kubectl context based on `KUBES_ENV`. Example:
41
41
 
42
- KUBES_ENV=dev kubes deploy # to dev-services context
43
- KUBES_ENV=prod kubes deploy # to prod-services context
42
+ KUBES_ENV=dev kubes deploy # to dev-cluster context
43
+ KUBES_ENV=prod kubes deploy # to prod-cluster context
44
44
 
45
45
  ## context_keep Option
46
46
 
@@ -0,0 +1,46 @@
1
+ ---
2
+ title: Builder Strategy
3
+ ---
4
+
5
+ Kubes uses the `docker` command to build the docker image by default. Kubes can also support an additional builder: gcloud.
6
+
7
+ ## Gcloud Builder
8
+
9
+ With the gcloud builder, you do not need docker installed locally. Google CloudBuild is used to build and push the image to a GCR registry.
10
+
11
+ You must set up the [gcloud cli](https://cloud.google.com/sdk/gcloud/reference/builds/submit). Please refer to the [gcloud sdk install docs](https://cloud.google.com/sdk/install). Kubes will call out to `gcloud builds submit` to create the Docker image.
12
+
13
+ ## Configure
14
+
15
+ You configure gcloud as the builder like so:
16
+
17
+ ```ruby
18
+ Kubes.configure do |config|
19
+ config.repo = "gcr.io/#{ENV['GOOGLE_PROJECT']}/demo"
20
+ config.logger.level = "info"
21
+ config.builder = "gcloud" # <= changed to gcloud
22
+ end
23
+ ```
24
+
25
+ ## Commands
26
+
27
+ The kubes builds command will remain the same.
28
+
29
+ kubes docker build
30
+
31
+ There is no need to run the push command, as the build command with the gcloud builder will always push.
32
+
33
+ ## Deploy
34
+
35
+ The deploy commands remain the same. Example:
36
+
37
+ kubes deploy web
38
+
39
+ If you want to skip the `docker build` phase of the deploy, you can run:
40
+
41
+ kubes deploy web --no-build
42
+
43
+ Also, kubes apply another way to skip the docker build:
44
+
45
+ kubes apply web
46
+
@@ -11,7 +11,7 @@ Kubes.configure do |config|
11
11
  config.repo = "111111111111.dkr.ecr.us-west-2.amazonaws.com/demo"
12
12
  config.logger.level = "info"
13
13
  # auto-switching
14
- # config.kubectl.context = "dev-services"
14
+ # config.kubectl.context = "dev-cluster"
15
15
  # config.kubectl.context_keep = false
16
16
  end
17
17
  ```
@@ -25,7 +25,7 @@ You can override configs on a per-env basis with `config/env` files. Examples:
25
25
  ```ruby
26
26
  Kubes.configure do |config|
27
27
  config.repo = "222222222222.dkr.ecr.us-west-2.amazonaws.com/demo"
28
- config.kubectl.context = "dev-services"
28
+ config.kubectl.context = "dev-cluster"
29
29
  end
30
30
  ```
31
31
 
@@ -34,7 +34,7 @@ end
34
34
  ```ruby
35
35
  Kubes.configure do |config|
36
36
  config.repo = "333333333333.dkr.ecr.us-west-2.amazonaws.com/demo"
37
- config.kubectl.context = "prod-services"
37
+ config.kubectl.context = "prod-cluster"
38
38
  end
39
39
  ```
40
40
 
@@ -46,15 +46,31 @@ spec:
46
46
 
47
47
  ## DSL Methods
48
48
 
49
- Here's a list of more common methods:
49
+ Here's a list of some of the methods:
50
+
51
+ kubectl explain service.spec
52
+
53
+ * clusterIP
54
+ * externalIPs
55
+ * externalName
56
+ * externalTrafficPolicy
57
+ * healthCheckNodePort
58
+ * ipFamily
59
+ * loadBalancerIP
60
+ * loadBalancerSourceRanges
61
+ * ports
62
+ * publishNotReadyAddresses
63
+ * selector
64
+ * sessionAffinity
65
+ * sessionAffinityConfig
66
+ * type
67
+
68
+ kubectl explain service.spec.ports
50
69
 
51
70
  * nodePort
52
71
  * port
53
- * portName: Note this field doesn't match the original field name. It's more qualified.
54
- * ports
72
+ * portName: : Note this field doesn't match the original field name. It's more qualified.
55
73
  * protocol
56
- * selector
57
74
  * targetPort
58
- * type
59
75
 
60
76
  {% include dsl/methods.md name="service" %}
@@ -22,6 +22,8 @@ You'll see output like this:
22
22
  deployment.apps/demo-web created
23
23
  $
24
24
 
25
+ Note: Showing an AWS ECR repo, but it may be different if you're using another repo like Google GCR.
26
+
25
27
  What did Kubes do?
26
28
 
27
29
  {% include kubes-steps.md %}
@@ -7,11 +7,10 @@ If you already a project with an existing Dockerfile, you can use that. If you d
7
7
  mkdir demo
8
8
  cd demo
9
9
 
10
- For this tutorial, we'll use an ECR repo, though any repo will work.
10
+ {% include learn/repos.md %}
11
11
 
12
12
  Let's generate a starter project:
13
13
 
14
- $ REPO=$(aws ecr describe-repositories --repository-name demo | jq -r '.repositories[].repositoryUri')
15
14
  $ kubes init --app demo --repo $REPO --type dsl
16
15
  create .kubes/config.rb
17
16
  create .kubes/config/env/dev.rb
@@ -22,6 +22,8 @@ You'll see output like this:
22
22
  deployment.apps/demo-web created
23
23
  $
24
24
 
25
+ Note: Showing an AWS ECR repo, but it may be different if you're using another repo like Google GCR.
26
+
25
27
  What did Kubes do?
26
28
 
27
29
  {% include kubes-steps.md %}
@@ -7,11 +7,10 @@ If you already a project with an existing Dockerfile, you can use that. If you d
7
7
  mkdir demo
8
8
  cd demo
9
9
 
10
- For this tutorial, we'll use an ECR repo, though any repo will work.
10
+ {% include learn/repos.md %}
11
11
 
12
12
  Let's generate a starter project:
13
13
 
14
- $ REPO=$(aws ecr describe-repositories --repository-name demo | jq -r '.repositories[].repositoryUri')
15
14
  $ kubes init --app demo --repo $REPO
16
15
  create Dockerfile
17
16
  create .kubes/config.rb
@@ -4,7 +4,7 @@ Install kubes via RubyGems.
4
4
 
5
5
  gem install kubes
6
6
 
7
- Ruby 2.7 and patch variants of it is recommended.
7
+ Ruby 2.7 and above is recommended.
8
8
 
9
9
  ## kubectl
10
10
 
@@ -13,3 +13,7 @@ Kubes calls kubectl. Kubes has been tested with kubectl v1.15+. Generally, it sh
13
13
  ## docker
14
14
 
15
15
  Kubes calls docker. Kubes has been tested with docker 18.x-ce+. Generally, it should work with most versions of docker.
16
+
17
+ ## gcloud
18
+
19
+ If you are using the [gcloud builder](% link _docs/config/builder.md %), set up and configure the [gcloud cli](https://cloud.google.com/sdk/install).
@@ -1,12 +1,12 @@
1
- You'll need a Kubernetes cluster and a Docker repo to be able to push to. Setting up a Kubernetes cluster is a little bit out scope for this tutorial. We'll provide the docs and links though. We'll also use an AWS EKS cluster and ECR.
1
+ You'll need a Kubernetes cluster and a Docker repo to be able to push to. Setting up a Kubernetes cluster is a little bit out scope for this tutorial. We'll provide the docs and links though. We'll provide instructions for AWS and Google.
2
2
 
3
- ## Create an EKS cluster
3
+ ## AWS: Create an EKS cluster
4
4
 
5
5
  Here are the AWS docs to create an EKS cluster:
6
6
 
7
7
  * [Creating an Amazon EKS cluster](https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html)
8
8
 
9
- ## Create an ECR Repo
9
+ ## AWS: Create an ECR Repo
10
10
 
11
11
  Here are the AWS docs to create a repo:
12
12
 
@@ -19,4 +19,21 @@ Here are also the commands to create an ECR repo:
19
19
 
20
20
  We'll be using the `$REPO` variable for the rest of the tutorial.
21
21
 
22
- Note: Though we're using AWS here, Kubes works with any Cloud Provider. Please adjust your commands and the `$REPO` variable for your cloud provider.
22
+ ## Google: Create GKE Cluster
23
+
24
+ Here are the Google docs to create an GKE cluster:
25
+
26
+ * [Creating an Google GKE cluster](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-regional-cluster)
27
+
28
+ ## Google: GCR Repo
29
+
30
+ For google, you do not have to create a repo. You simply push to the right repo url. Example:
31
+
32
+ export GOOGLE_PROJECT=project-123
33
+ REPO=gcr.io/$GOOGLE_PROJECT/demo
34
+
35
+ ## Repo Variable
36
+
37
+ We'll be using the `$REPO` variable for the rest of the tutorial.
38
+
39
+ Note: Though we're using AWS and Google here, Kubes works with any Cloud Provider. Please adjust your commands and the `$REPO` variable for your cloud provider.
File without changes
@@ -0,0 +1,10 @@
1
+ For this tutorial, here are examples of AWS ECR and Google GCR repos, though any repo will work.
2
+
3
+ AWS:
4
+
5
+ REPO=$(aws ecr describe-repositories --repository-name demo | jq -r '.repositories[].repositoryUri')
6
+
7
+ Google:
8
+
9
+ export GOOGLE_PROJECT=project-123
10
+ REPO=gcr.io/$GOOGLE_PROJECT/demo
@@ -4,10 +4,10 @@ The `config.rb` is where you can configure Kubes settings.
4
4
 
5
5
  ```ruby
6
6
  Kubes.configure do |config|
7
- config.repo = "112233445566.dkr.ecr.us-west-2.amazonaws.com/demo"
7
+ config.repo = "112233445566.dkr.ecr.us-west-2.amazonaws.com/demo" # may be gcr.io/project-123/demo
8
8
  config.logger.level = "info"
9
9
  # auto-switching
10
- # config.kubectl.context = "dev-services"
10
+ # config.kubectl.context = "dev-cluster"
11
11
  end
12
12
  ```
13
13
 
@@ -56,6 +56,7 @@
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
58
  <li><a href="{% link _docs/config/kubectl.md %}">Kubectl</a></li>
59
+ <li><a href="{% link _docs/config/builder.md %}">Builder</a></li>
59
60
  </ul>
60
61
  </li>
61
62
  <li><a href="{% link _docs/yaml.md %}">YAML</a></li>
@@ -5,11 +5,11 @@ reference: true
5
5
 
6
6
  ## Usage
7
7
 
8
- kubes apply [APP] [RESOURCE]
8
+ kubes apply [ROLE] [RESOURCE]
9
9
 
10
10
  ## Description
11
11
 
12
- Apply the Kubernetes YAML files without changing them
12
+ Apply the Kubernetes YAML files without building docker image
13
13
 
14
14
 
15
15
  ## Options
@@ -5,7 +5,7 @@ reference: true
5
5
 
6
6
  ## Usage
7
7
 
8
- kubes delete [APP] [RESOURCE]
8
+ kubes delete [ROLE] [RESOURCE]
9
9
 
10
10
  ## Description
11
11
 
@@ -5,7 +5,7 @@ reference: true
5
5
 
6
6
  ## Usage
7
7
 
8
- kubes deploy [APP] [RESOURCE]
8
+ kubes deploy [ROLE] [RESOURCE]
9
9
 
10
10
  ## Description
11
11
 
@@ -0,0 +1,24 @@
1
+ ---
2
+ title: kubes describe
3
+ reference: true
4
+ ---
5
+
6
+ ## Usage
7
+
8
+ kubes describe [ROLE] [RESOURCE]
9
+
10
+ ## Description
11
+
12
+ Describe Kubernetes resource using the compiled YAML files
13
+
14
+
15
+ ## Options
16
+
17
+ ```
18
+ [--image=IMAGE] # override image
19
+ [--compile], [--no-compile] # whether or not to compile the .kube/resources
20
+ # Default: true
21
+ [--verbose], [--no-verbose]
22
+ [--noop], [--no-noop]
23
+ ```
24
+
@@ -0,0 +1,42 @@
1
+ ---
2
+ title: kubes exec
3
+ reference: true
4
+ ---
5
+
6
+ ## Usage
7
+
8
+ kubes exec
9
+
10
+ ## Description
11
+
12
+ Exec into the latest container from the deployment
13
+
14
+ The exec command finds the latest pod from the deployment and runs `kubectl exec -ti POD bash` to get you into it. It spares you from having to manually find and type it.
15
+
16
+ ## Examples
17
+
18
+ kubes exec
19
+ kubes exec sh
20
+ kubes exec ls -l
21
+
22
+ ## Multiple Deployments
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:
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
31
+
32
+
33
+ ## Options
34
+
35
+ ```
36
+ [--compile], [--no-compile] # whether or not to compile the .kube/resources
37
+ # Default: true
38
+ n, [--name=NAME] # deployment name to use. IE: demo-web
39
+ [--verbose], [--no-verbose]
40
+ [--noop], [--no-noop]
41
+ ```
42
+
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: kubes get
3
+ reference: true
4
+ ---
5
+
6
+ ## Usage
7
+
8
+ kubes get [ROLE] [RESOURCE]
9
+
10
+ ## Description
11
+
12
+ Get Kubernetes resource using the compiled YAML files
13
+
14
+
15
+ ## Options
16
+
17
+ ```
18
+ [--image=IMAGE] # override image
19
+ [--compile], [--no-compile] # whether or not to compile the .kube/resources
20
+ # Default: true
21
+ o, [--output=OUTPUT] # Output format: json|yaml|wide|name
22
+ [--show-pods], [--no-show-pods] # Also show pods from deployments
23
+ # Default: true
24
+ [--verbose], [--no-verbose]
25
+ [--noop], [--no-noop]
26
+ ```
27
+