kubes 0.2.4 → 0.2.5
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/CHANGELOG.md +3 -0
- data/docs/_docs/config/build-strategy.md +46 -0
- data/docs/_includes/sidebar.html +1 -0
- data/lib/kubes/cli/build.rb +2 -2
- data/lib/kubes/cli/docker.rb +2 -2
- 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/version.rb +1 -1
- metadata +13 -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: 658324c3828bd9f6ee60ad1fd925eb47ff9706fe08256b791e180b0daf3cfba0
|
|
4
|
+
data.tar.gz: 5a2cc328105e6ac7dd7847f4d92697db98827e81b214b7dc3f6b353bf78e224f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 307badb633d97365c4072a7e089c5a36b2abb81e761aa3a5abb46e4aaa4e3da2878023edb12cf203b817ee6aa4484b4d2d758e6f4a20b1e571fdaec75bf61ddc
|
|
7
|
+
data.tar.gz: e5d6f7434c93a73bc996fc661d026f5c601a4bd7c6680c14f0219af4561f1f7ac362370123efe381fac0538021ccb151adc308658b1f3f70c0dbff58334fed9d
|
data/CHANGELOG.md
CHANGED
|
@@ -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.2.5]
|
|
7
|
+
- #17 cloudbuild build strategy
|
|
8
|
+
|
|
6
9
|
## [0.2.4]
|
|
7
10
|
- #16 google cloudbuild support & docs: add Dockerfile for kubes as a docker entrypoint
|
|
8
11
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Build Strategy
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Kubes uses the `docker` to build the docker image by default. Kubes can also support an additional build strategy: gcloud.
|
|
6
|
+
|
|
7
|
+
## Gcloud Build Strategy
|
|
8
|
+
|
|
9
|
+
With the gcloud build strategy, 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 build strategy 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.build_strategy = "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 strategy 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/_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/build-strategy.md %}">Build Strategy</a></li>
|
|
59
60
|
</ul>
|
|
60
61
|
</li>
|
|
61
62
|
<li><a href="{% link _docs/yaml.md %}">YAML</a></li>
|
data/lib/kubes/cli/build.rb
CHANGED
data/lib/kubes/cli/docker.rb
CHANGED
|
@@ -4,7 +4,7 @@ class Kubes::CLI
|
|
|
4
4
|
long_desc Help.text("docker:build")
|
|
5
5
|
option :push, type: :boolean, default: false
|
|
6
6
|
def build
|
|
7
|
-
builder = Kubes::Docker
|
|
7
|
+
builder = Kubes::Docker.new(options, "build")
|
|
8
8
|
builder.run
|
|
9
9
|
push if options[:push]
|
|
10
10
|
end
|
|
@@ -13,7 +13,7 @@ class Kubes::CLI
|
|
|
13
13
|
long_desc Help.text("docker:push")
|
|
14
14
|
option :push, type: :boolean, default: false
|
|
15
15
|
def push
|
|
16
|
-
pusher = Kubes::Docker
|
|
16
|
+
pusher = Kubes::Docker.new(options, "push")
|
|
17
17
|
pusher.run
|
|
18
18
|
end
|
|
19
19
|
end
|
data/lib/kubes/config.rb
CHANGED
data/lib/kubes/docker.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Kubes
|
|
2
|
+
class Docker
|
|
3
|
+
def initialize(options, name)
|
|
4
|
+
@options = options
|
|
5
|
+
@name = name
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def run
|
|
9
|
+
strategy = strategy_class.new(@options, @name) # @name: docker or push
|
|
10
|
+
strategy.run
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def strategy_class
|
|
14
|
+
strategy = Kubes.config.build_strategy.to_s.camelize # IE: Docker or Gcloud
|
|
15
|
+
klass_name = "Kubes::Docker::Strategy::#{@name.camelize}::#{strategy}"
|
|
16
|
+
klass_name.constantize
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Kubes::Docker::Strategy::Build
|
|
2
|
+
class Base
|
|
3
|
+
extend Memoist
|
|
4
|
+
include Kubes::Docker::Strategy::Utils
|
|
5
|
+
|
|
6
|
+
def initialize(options, name)
|
|
7
|
+
@options, @name = options, name
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def run
|
|
11
|
+
reserve_image_name
|
|
12
|
+
check_dockerfile!
|
|
13
|
+
perform
|
|
14
|
+
store_image_name
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def check_dockerfile!
|
|
18
|
+
# Dockerfile is also used in args/default.rb, will have to combine if Dockerfile is made configurable
|
|
19
|
+
return if File.exist?("Dockerfile")
|
|
20
|
+
logger.error "ERROR: The Dockerfile does not exist. Cannot build the docker image without a Dockerfile".color(:red)
|
|
21
|
+
exit 1
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -1,36 +1,6 @@
|
|
|
1
|
-
module Kubes::Docker
|
|
2
|
-
|
|
1
|
+
module Kubes::Docker::Strategy
|
|
2
|
+
module ImageName
|
|
3
3
|
extend Memoist
|
|
4
|
-
include Kubes::Logging
|
|
5
|
-
include Kubes::Util::Sh
|
|
6
|
-
|
|
7
|
-
def initialize(options={})
|
|
8
|
-
@options = options
|
|
9
|
-
@name = self.class.name.split('::').last.underscore
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def run_hooks(name, &block)
|
|
13
|
-
hooks = Kubes::Hooks::Builder.new(name, "#{Kubes.root}/.kubes/config/docker/hooks.rb")
|
|
14
|
-
hooks.build # build hooks
|
|
15
|
-
hooks.run_hooks(&block)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def args
|
|
19
|
-
# base at end in case of redirection. IE: command > /path
|
|
20
|
-
custom.args + default.args
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def custom
|
|
24
|
-
custom = Kubes::Args::Custom.new(@name, "#{Kubes.root}/.kubes/config/docker/args.rb")
|
|
25
|
-
custom.build
|
|
26
|
-
custom
|
|
27
|
-
end
|
|
28
|
-
memoize :custom
|
|
29
|
-
|
|
30
|
-
def default
|
|
31
|
-
Args::Default.new(@name, image_name, @options)
|
|
32
|
-
end
|
|
33
|
-
memoize :default
|
|
34
4
|
|
|
35
5
|
@@image_name = nil
|
|
36
6
|
def reserve_image_name
|
|
@@ -84,5 +54,22 @@ module Kubes::Docker
|
|
|
84
54
|
@git_sha = `cd #{Kubes.root} && git rev-parse --short HEAD`
|
|
85
55
|
@git_sha.strip!
|
|
86
56
|
end
|
|
57
|
+
|
|
58
|
+
def args
|
|
59
|
+
# base at end in case of redirection. IE: command > /path
|
|
60
|
+
custom.args + default.args
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def custom
|
|
64
|
+
custom = Kubes::Args::Custom.new(@name, "#{Kubes.root}/.kubes/config/docker/args.rb")
|
|
65
|
+
custom.build
|
|
66
|
+
custom
|
|
67
|
+
end
|
|
68
|
+
memoize :custom
|
|
69
|
+
|
|
70
|
+
def default
|
|
71
|
+
Kubes::Docker::Args::Default.new(@name, image_name, @options)
|
|
72
|
+
end
|
|
73
|
+
memoize :default
|
|
87
74
|
end
|
|
88
75
|
end
|
data/lib/kubes/version.rb
CHANGED
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.2.
|
|
4
|
+
version: 0.2.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-07-
|
|
11
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -235,6 +235,7 @@ files:
|
|
|
235
235
|
- docs/_docs/auto-context.md
|
|
236
236
|
- docs/_docs/ci/cloudbuild.md
|
|
237
237
|
- docs/_docs/config.md
|
|
238
|
+
- docs/_docs/config/build-strategy.md
|
|
238
239
|
- docs/_docs/config/docker.md
|
|
239
240
|
- docs/_docs/config/env.md
|
|
240
241
|
- docs/_docs/config/kubectl.md
|
|
@@ -513,10 +514,17 @@ files:
|
|
|
513
514
|
- lib/kubes/completer/script.sh
|
|
514
515
|
- lib/kubes/config.rb
|
|
515
516
|
- lib/kubes/core.rb
|
|
517
|
+
- lib/kubes/docker.rb
|
|
516
518
|
- lib/kubes/docker/args/default.rb
|
|
517
|
-
- lib/kubes/docker/base.rb
|
|
518
|
-
- lib/kubes/docker/build.rb
|
|
519
|
-
- lib/kubes/docker/
|
|
519
|
+
- lib/kubes/docker/strategy/build/base.rb
|
|
520
|
+
- lib/kubes/docker/strategy/build/docker.rb
|
|
521
|
+
- lib/kubes/docker/strategy/build/gcloud.rb
|
|
522
|
+
- lib/kubes/docker/strategy/hooks.rb
|
|
523
|
+
- lib/kubes/docker/strategy/image_name.rb
|
|
524
|
+
- lib/kubes/docker/strategy/push/base.rb
|
|
525
|
+
- lib/kubes/docker/strategy/push/docker.rb
|
|
526
|
+
- lib/kubes/docker/strategy/push/gcloud.rb
|
|
527
|
+
- lib/kubes/docker/strategy/utils.rb
|
|
520
528
|
- lib/kubes/hooks/builder.rb
|
|
521
529
|
- lib/kubes/hooks/dsl.rb
|
|
522
530
|
- lib/kubes/kubectl.rb
|
data/lib/kubes/docker/build.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Kubes::Docker
|
|
2
|
-
class Build < Base
|
|
3
|
-
def run
|
|
4
|
-
reserve_image_name
|
|
5
|
-
build
|
|
6
|
-
store_image_name
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def build
|
|
10
|
-
# Dockerfile is also used in args/default.rb, will have to combine if Dockerfile is made configurable
|
|
11
|
-
unless File.exist?("Dockerfile")
|
|
12
|
-
logger.error "ERROR: The Dockerfile does not exist. Cannot build the docker image without a Dockerfile".color(:red)
|
|
13
|
-
exit 1
|
|
14
|
-
end
|
|
15
|
-
params = args.flatten.join(' ')
|
|
16
|
-
command = "docker build #{params}"
|
|
17
|
-
run_hooks "build" do
|
|
18
|
-
sh(command)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|