kubes 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.dockerignore +4 -0
- data/CHANGELOG.md +18 -1
- data/Dockerfile +14 -0
- data/docs/_docs/auto-context.md +4 -4
- data/docs/_docs/ci/cloudbuild.md +69 -0
- data/docs/_docs/config/builder.md +46 -0
- data/docs/_docs/config/env.md +3 -3
- data/docs/_docs/dsl/resources/deployment.md +0 -5
- data/docs/_docs/dsl/resources/network_policy.md +1 -1
- data/docs/_docs/dsl/resources/service.md +21 -5
- data/docs/_docs/helpers.md +2 -2
- data/docs/_docs/learn/dsl/deploy.md +2 -0
- data/docs/_docs/learn/dsl/new-project.md +1 -2
- data/docs/_docs/learn/yaml/deploy.md +2 -0
- data/docs/_docs/learn/yaml/new-project.md +1 -1
- data/docs/_docs/learn/yaml/review-project.md +0 -5
- data/docs/_docs/yaml.md +0 -5
- data/docs/_includes/intro/install.md +5 -1
- data/docs/_includes/learn/cluster.md +21 -4
- data/docs/_includes/learn/repo +0 -0
- data/docs/_includes/learn/repos.md +10 -0
- data/docs/_includes/learn/review.md +2 -2
- data/docs/_includes/sidebar.html +6 -0
- data/docs/_reference/kubes-apply.md +2 -2
- data/docs/_reference/kubes-delete.md +1 -1
- data/docs/_reference/kubes-deploy.md +1 -1
- data/docs/_reference/kubes-describe.md +24 -0
- data/docs/_reference/kubes-exec.md +42 -0
- data/docs/_reference/kubes-get.md +27 -0
- data/docs/_reference/kubes-init.md +1 -1
- data/docs/_reference/kubes-logs.md +26 -0
- data/docs/bin/web +1 -1
- data/docs/reference.md +4 -0
- data/lib/kubes/cli.rb +21 -0
- data/lib/kubes/cli/apply.rb +1 -1
- data/lib/kubes/cli/base.rb +4 -0
- data/lib/kubes/cli/build.rb +2 -2
- data/lib/kubes/cli/delete.rb +7 -2
- data/lib/kubes/cli/describe.rb +1 -1
- data/lib/kubes/cli/docker.rb +2 -2
- data/lib/kubes/cli/exec.rb +33 -0
- data/lib/kubes/cli/get.rb +3 -1
- data/lib/kubes/cli/help/exec.md +17 -0
- data/lib/kubes/cli/logs.rb +13 -0
- data/lib/kubes/compiler/dsl/syntax/deployment.rb +77 -10
- data/lib/kubes/compiler/dsl/syntax/service.rb +11 -0
- data/lib/kubes/compiler/shared/helpers.rb +2 -1
- data/lib/kubes/config.rb +2 -0
- data/lib/kubes/docker.rb +19 -0
- data/lib/kubes/docker/strategy/build/base.rb +24 -0
- data/lib/kubes/docker/strategy/build/docker.rb +11 -0
- data/lib/kubes/docker/strategy/build/gcloud.rb +10 -0
- data/lib/kubes/docker/strategy/hooks.rb +9 -0
- data/lib/kubes/docker/{base.rb → strategy/image_name.rb} +19 -32
- data/lib/kubes/docker/strategy/push/base.rb +9 -0
- data/lib/kubes/docker/{push.rb → strategy/push/docker.rb} +2 -5
- data/lib/kubes/docker/strategy/push/gcloud.rb +9 -0
- data/lib/kubes/docker/strategy/utils.rb +9 -0
- data/lib/kubes/hooks/builder.rb +2 -1
- data/lib/kubes/kubectl.rb +15 -3
- data/lib/kubes/kubectl/batch.rb +8 -1
- data/lib/kubes/kubectl/fetch/base.rb +24 -0
- data/lib/kubes/kubectl/fetch/deployment.rb +34 -0
- data/lib/kubes/kubectl/fetch/pods.rb +21 -0
- data/lib/kubes/util/sh.rb +1 -0
- data/lib/kubes/version.rb +1 -1
- data/lib/templates/dsl/.kubes/resources/web/deployment.rb +3 -1
- data/lib/templates/dsl/.kubes/resources/web/service.rb +1 -1
- data/lib/templates/yaml/.kubes/resources/web/deployment.yaml.tt +0 -5
- metadata +28 -5
- data/lib/kubes/docker/build.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6a93c63c1e8d4aeea46969a491b3065c97e9a1a290bfd871286e794c35cb0d6
|
4
|
+
data.tar.gz: d8dbb91a1214bf8c42a5c9dd1e591dfcf6c41ffee6feb36af0af2f7b3a519ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfc13591d144fb99837297c4c766354ceed410df631e505e54517e9759b9b44b03ce9adb7738db167b55c877d7f47bbd644f1bb832df38c4213651243fcbe668
|
7
|
+
data.tar.gz: 9ed84b118c29ec8531407f4b069840d1c576eb6f120f58ead3a8560242af44b62ca3b6339f4949a5433c64fc966003d65f2871134b0ed17984cc2f461b9537bd
|
data/.dockerignore
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# Changelog
|
2
2
|
|
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.0]
|
7
|
+
- #19 new commands: exec, logs
|
8
|
+
- delete preview
|
9
|
+
- show pods as part of get
|
10
|
+
|
11
|
+
## [0.2.6]
|
12
|
+
- #18 gcloud builder. change to config.builder
|
13
|
+
|
14
|
+
## [0.2.5]
|
15
|
+
- #17 cloudbuild build strategy
|
16
|
+
|
17
|
+
## [0.2.4]
|
18
|
+
- #16 google cloudbuild support & docs: add Dockerfile for kubes as a docker entrypoint
|
19
|
+
|
20
|
+
## [0.2.3]
|
21
|
+
- #15 use kubernetes default deployment strategy instead
|
22
|
+
|
6
23
|
## [0.2.2]
|
7
24
|
- #14 init template updates, dockerfile_port helper
|
8
25
|
|
data/Dockerfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
FROM ruby:2.7-alpine
|
2
|
+
|
3
|
+
RUN apk add --no-cache docker
|
4
|
+
RUN apk add --no-cache build-base ruby ruby-dev
|
5
|
+
|
6
|
+
RUN wget https://storage.googleapis.com/kubernetes-release/release/v1.18.6/bin/linux/amd64/kubectl
|
7
|
+
RUN chmod u+x kubectl && mv kubectl /bin/kubectl
|
8
|
+
|
9
|
+
WORKDIR /app
|
10
|
+
ADD . /app
|
11
|
+
RUN bundle install
|
12
|
+
RUN rake install
|
13
|
+
|
14
|
+
ENTRYPOINT ["/usr/local/bundle/bin/kubes"]
|
data/docs/_docs/auto-context.md
CHANGED
@@ -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-
|
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-
|
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-
|
43
|
-
KUBES_ENV=prod kubes deploy # to prod-
|
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,69 @@
|
|
1
|
+
---
|
2
|
+
title: CloudBuild
|
3
|
+
---
|
4
|
+
|
5
|
+
To build kubes as a Docker image entrypoint for [Google CloudBuild Custom Builder](https://cloud.google.com/cloud-build/docs/configuring-builds/use-community-and-custom-builders).
|
6
|
+
|
7
|
+
git clone http://github.com/boltops-tools/kubes
|
8
|
+
cd kubes
|
9
|
+
gcloud builds submit --tag gcr.io/$GOOGLE_PROJECT/kubes
|
10
|
+
|
11
|
+
Be sure to set GOOGLE_PROJECT to your own project id.
|
12
|
+
|
13
|
+
## Example Codebuild YAML
|
14
|
+
|
15
|
+
cloudbuild.yaml:
|
16
|
+
|
17
|
+
```yaml
|
18
|
+
steps:
|
19
|
+
# Simply calling kubectl version with the CLOUDSDK_* vars will auth to the GKE cluster. Unsure why.
|
20
|
+
- name: gcr.io/cloud-builders/kubectl
|
21
|
+
args: ['version']
|
22
|
+
env:
|
23
|
+
- 'CLOUDSDK_COMPUTE_REGION=$_GCP_REGION'
|
24
|
+
- 'CLOUDSDK_CONTAINER_CLUSTER=$_GKE_CLUSTER'
|
25
|
+
- name: 'gcr.io/$PROJECT_ID/kubes'
|
26
|
+
args: ["deploy"]
|
27
|
+
env:
|
28
|
+
- 'GOOGLE_PROJECT=$PROJECT_ID' # .kubes/config.rb: config.repo
|
29
|
+
- 'KUBES_ENV=$_KUBES_ENV'
|
30
|
+
- 'KUBES_EXTRA=$_KUBES_EXTRA'
|
31
|
+
|
32
|
+
substitutions:
|
33
|
+
_GCP_REGION: us-central1
|
34
|
+
_GKE_CLUSTER: dev-cluster
|
35
|
+
_KUBES_ENV: dev
|
36
|
+
_KUBES_EXTRA: ''
|
37
|
+
options:
|
38
|
+
substitution_option: 'ALLOW_LOOSE'
|
39
|
+
```
|
40
|
+
|
41
|
+
## Run CloudBuild
|
42
|
+
|
43
|
+
Run cloudbuild with:
|
44
|
+
|
45
|
+
gcloud builds submit --config cloudbuild.yaml
|
46
|
+
|
47
|
+
Example with output:
|
48
|
+
|
49
|
+
$ gcloud builds submit --config cloudbuild.yaml
|
50
|
+
Starting Step #1
|
51
|
+
Step #1: => docker build -t gcr.io/tung-275700/demo:kubes-2020-07-25T21-13-59 -f Dockerfile .
|
52
|
+
Step #1: Pushed gcr.io/tung-275700/demo:kubes-2020-07-25T21-13-59 docker image.
|
53
|
+
Step #1: Docker push took 2s.
|
54
|
+
Step #1: Compiled .kubes/resources files to .kubes/output
|
55
|
+
Step #1: Deploying kubes resources
|
56
|
+
Step #1: => kubectl apply -f .kubes/output/shared/namespace.yaml
|
57
|
+
Step #1: namespace/demo unchanged
|
58
|
+
Step #1: => kubectl apply -f .kubes/output/web/service.yaml
|
59
|
+
Step #1: service/web unchanged
|
60
|
+
Step #1: => kubectl apply -f .kubes/output/web/deployment.yaml
|
61
|
+
Step #1: deployment.apps/web configured
|
62
|
+
$
|
63
|
+
|
64
|
+
## Create Extra Environments
|
65
|
+
|
66
|
+
If you are using the [with_extra helper]({% link _docs/extra-env.md %}), you can create additional environments of the same app like so:
|
67
|
+
|
68
|
+
gcloud builds submit --config cloudbuild.yaml --substitutions=_KUBES_EXTRA=2
|
69
|
+
gcloud builds submit --config cloudbuild.yaml --substitutions=_KUBES_EXTRA=3
|
@@ -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
|
+
|
data/docs/_docs/config/env.md
CHANGED
@@ -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-
|
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-
|
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-
|
37
|
+
config.kubectl.context = "prod-cluster"
|
38
38
|
end
|
39
39
|
```
|
40
40
|
|
@@ -50,7 +50,7 @@ Note, the behavior of the from is an *or* since the namespaceSelector and podSel
|
|
50
50
|
|
51
51
|
## Example 2
|
52
52
|
|
53
|
-
If you need more control over the ingress selectors you can use the from method.
|
53
|
+
If you need more control over the ingress selectors, you can use the `from` method. Here's an example:
|
54
54
|
|
55
55
|
.kubes/resources/web/network_policy.rb
|
56
56
|
|
@@ -46,15 +46,31 @@ spec:
|
|
46
46
|
|
47
47
|
## DSL Methods
|
48
48
|
|
49
|
-
Here's a list of
|
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" %}
|
data/docs/_docs/helpers.md
CHANGED
@@ -8,8 +8,8 @@ Helper | Description
|
|
8
8
|
--- | ---
|
9
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
10
|
dockerfile_port | Exposed port extracted from the Dockerfile of the project.
|
11
|
-
extra | The `
|
12
|
-
with_extra | Appends the `
|
11
|
+
extra | The `KUBES_EXTRA` value.
|
12
|
+
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 %}).
|
13
13
|
|
14
14
|
Here's also the source code with the helpers: [helpers.rb](https://github.com/boltops-tools/kubes/blob/master/lib/kubes/compiler/shared/helpers.rb).
|
15
15
|
|
@@ -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
|
-
|
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
|
data/docs/_docs/yaml.md
CHANGED
@@ -4,7 +4,7 @@ Install kubes via RubyGems.
|
|
4
4
|
|
5
5
|
gem install kubes
|
6
6
|
|
7
|
-
Ruby 2.7 and
|
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
|
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
|
-
|
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-
|
10
|
+
# config.kubectl.context = "dev-cluster"
|
11
11
|
end
|
12
12
|
```
|
13
13
|
|