kubes 0.2.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +4 -0
- data/CHANGELOG.md +17 -0
- 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/service.md +21 -5
- 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/_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 +22 -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 +34 -0
- data/lib/kubes/cli/get.rb +3 -1
- data/lib/kubes/cli/help/exec.md +24 -0
- data/lib/kubes/cli/logs.rb +13 -0
- data/lib/kubes/compiler/dsl/syntax/deployment.rb +85 -2
- 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 +2 -1
- data/lib/templates/dsl/.kubes/resources/web/service.rb +1 -1
- 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: d130212469e4bc5bd395cd0b12978199876a6c5b946caf80fa66a7e09608ccd5
|
4
|
+
data.tar.gz: b2fd2bfc17efa04772d69426e9895e3151c97c3628a573f245e7920824c9df9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd1c1f453efdc400a6056443fe95a92bf1e0443cea14df03373a650f4c538a3d152e0c1b49195801a99a578df7eb0aa5092b6e612078775cb7a2086daca0937f
|
7
|
+
data.tar.gz: 95c492b92ce1890e011c9d93ebc46b8a9248eaa372b9545721f5c0d64ac72b96f20c07705ad0f667b6b7e84a2440af662d9b26b0a12186a83c218c62315c01a7
|
data/.dockerignore
ADDED
data/CHANGELOG.md
CHANGED
@@ -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.1]
|
7
|
+
- #20 improve sidecar support. kubes exec -c option also
|
8
|
+
|
9
|
+
## [0.3.0]
|
10
|
+
- #19 new commands: exec, logs
|
11
|
+
- delete preview
|
12
|
+
- show pods as part of get
|
13
|
+
|
14
|
+
## [0.2.6]
|
15
|
+
- #18 gcloud builder. change to config.builder
|
16
|
+
|
17
|
+
## [0.2.5]
|
18
|
+
- #17 cloudbuild build strategy
|
19
|
+
|
20
|
+
## [0.2.4]
|
21
|
+
- #16 google cloudbuild support & docs: add Dockerfile for kubes as a docker entrypoint
|
22
|
+
|
6
23
|
## [0.2.3]
|
7
24
|
- #15 use kubernetes default deployment strategy instead
|
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
|
|
@@ -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" %}
|
@@ -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
|
@@ -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
|
|
data/docs/_includes/sidebar.html
CHANGED
@@ -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>
|
@@ -93,6 +94,11 @@
|
|
93
94
|
</li>
|
94
95
|
<li><a href="{% link _docs/kustomize.md %}">Kustomize Support</a></li>
|
95
96
|
<li><a href="{% link _docs/auto-context.md %}">Auto Context</a></li>
|
97
|
+
<li>CI/CD
|
98
|
+
<ul>
|
99
|
+
<li><a href="{% link _docs/ci/cloudbuild.md %}">CloudBuild</a></li>
|
100
|
+
</ul>
|
101
|
+
</li>
|
96
102
|
<li>More
|
97
103
|
<ul class="more">
|
98
104
|
<li><a href="{% link support.md %}">Support</a></li>
|
@@ -5,11 +5,11 @@ reference: true
|
|
5
5
|
|
6
6
|
## Usage
|
7
7
|
|
8
|
-
kubes apply [
|
8
|
+
kubes apply [ROLE] [RESOURCE]
|
9
9
|
|
10
10
|
## Description
|
11
11
|
|
12
|
-
Apply the Kubernetes YAML files without
|
12
|
+
Apply the Kubernetes YAML files without building docker image
|
13
13
|
|
14
14
|
|
15
15
|
## Options
|