kuby-core 0.1.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +60 -0
- data/Gemfile +0 -4
- data/README.md +3 -160
- data/kuby-core.gemspec +6 -5
- data/lib/ext/krane/kubernetes_resource.rb +16 -0
- data/lib/kuby.rb +32 -17
- data/lib/kuby/definition.rb +22 -16
- data/lib/kuby/docker.rb +2 -1
- data/lib/kuby/docker/alpine.rb +0 -1
- data/lib/kuby/docker/assets_phase.rb +1 -1
- data/lib/kuby/docker/bundler_phase.rb +4 -2
- data/lib/kuby/docker/copy_phase.rb +1 -1
- data/lib/kuby/docker/inline_layer.rb +15 -0
- data/lib/kuby/docker/{phase.rb → layer.rb} +6 -5
- data/lib/kuby/docker/layer_stack.rb +30 -4
- data/lib/kuby/docker/metadata.rb +27 -1
- data/lib/kuby/docker/package_phase.rb +1 -1
- data/lib/kuby/docker/packages.rb +5 -4
- data/lib/kuby/docker/packages/simple_managed_package.rb +25 -0
- data/lib/kuby/docker/setup_phase.rb +1 -1
- data/lib/kuby/docker/spec.rb +4 -4
- data/lib/kuby/docker/tags.rb +18 -0
- data/lib/kuby/docker/webserver_phase.rb +1 -1
- data/lib/kuby/docker/yarn_phase.rb +1 -1
- data/lib/kuby/environment.rb +22 -0
- data/lib/kuby/kubernetes.rb +1 -0
- data/lib/kuby/kubernetes/deploy_task.rb +33 -0
- data/lib/kuby/kubernetes/deployer.rb +1 -2
- data/lib/kuby/kubernetes/errors.rb +0 -12
- data/lib/kuby/kubernetes/minikube_provider.rb +5 -5
- data/lib/kuby/kubernetes/plugins/nginx_ingress.rb +12 -0
- data/lib/kuby/kubernetes/plugins/rails_app/database.rb +30 -9
- data/lib/kuby/kubernetes/plugins/rails_app/generators/kuby.rb +83 -0
- data/lib/kuby/kubernetes/plugins/rails_app/mysql.rb +17 -5
- data/lib/kuby/kubernetes/plugins/rails_app/plugin.rb +28 -42
- data/lib/kuby/kubernetes/plugins/rails_app/postgres.rb +132 -0
- data/lib/kuby/kubernetes/plugins/rails_app/sqlite.rb +20 -0
- data/lib/kuby/kubernetes/plugins/rails_app/tasks.rake +9 -4
- data/lib/kuby/kubernetes/spec.rb +52 -37
- data/lib/kuby/railtie.rb +0 -4
- data/lib/kuby/tasks.rb +18 -0
- data/lib/kuby/tasks/kuby.rake +24 -17
- data/lib/kuby/version.rb +1 -1
- metadata +25 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfe201dc901e8ae1b43121cb2652343f8db33893a6da69d783715cc7f320e2d2
|
4
|
+
data.tar.gz: 452b7119e76ee461f93729aa70999d51a5b1f77bc7b3af5c4935ebd863f2e526
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2944a9ea28ee31b4763d2cbbe2db04cc9009526919ef8a25b8513fbf2fdfbf72e5356ee94969b4623fc208e3b7bc527d1423e68d39447e500c0a2bd8b93867ca
|
7
|
+
data.tar.gz: 6259dd452e62337c01d1d301a0adc0fedb394c6a667e7f51a5cece1cf5464654708ba9ca56783aed610067e6b6a86131f8d7cb9371de51202e0f867610d66f15
|
data/CHANGELOG.md
CHANGED
@@ -1,2 +1,62 @@
|
|
1
|
+
## 0.6.0
|
2
|
+
* Don't load the Rails environment when running Kuby's rake tasks.
|
3
|
+
- Kuby's gems are still part of the bundle, but config has been moved out of the initializer and into kuby.rb in the Rails root directory.
|
4
|
+
- Internal classes no longer retain a reference to `Rails.application`.
|
5
|
+
- Kuby config now requires `environment` blocks:
|
6
|
+
```ruby
|
7
|
+
Kuby.define('my-app') do
|
8
|
+
environment(:production) do
|
9
|
+
...
|
10
|
+
end
|
11
|
+
|
12
|
+
environment(:staging) do
|
13
|
+
...
|
14
|
+
end
|
15
|
+
end
|
16
|
+
```
|
17
|
+
* Fix `MissingDistroError` caused by not setting a default distro.
|
18
|
+
* Create a .dockerignore file when running the Rails generator.
|
19
|
+
* Add ability to insert inline Docker layers without having to create a separate class, eg:
|
20
|
+
```ruby
|
21
|
+
insert :hello, before: :bundler_phase do |dockerfile|
|
22
|
+
dockerfile.run('echo "hello, world"')
|
23
|
+
end
|
24
|
+
```
|
25
|
+
* Add Postgres database support.
|
26
|
+
* Don't install sqlite libs by default.
|
27
|
+
* Modify Rails generator
|
28
|
+
- Require kuby and load config safely.
|
29
|
+
- Provide manual access to credentials via `ActiveSupport::EncryptedConfiguration`, which is necessary now that our rake tasks don't load the Rails environment.
|
30
|
+
* Add a convenience method for requesting the amount of block storage for the database.
|
31
|
+
* Add the ability to entirely disable database management via `manage_database false`.
|
32
|
+
* Avoid deploying nginx-ingress if it's already deployed.
|
33
|
+
* Add rake task for running arbitrary `kubectl` commands.
|
34
|
+
|
35
|
+
## 0.5.0
|
36
|
+
* Fix Rails generators issue causing crash at startup.
|
37
|
+
* Add rake task to run arbitrary kubectl commands.
|
38
|
+
|
39
|
+
## 0.4.0
|
40
|
+
* Introduce simple managed package.
|
41
|
+
* Refactor deploy task into its own class.
|
42
|
+
|
43
|
+
## 0.3.0
|
44
|
+
* Fix Krane issue causing incorrect constant lookup and therefore deploy failures.
|
45
|
+
- See: https://github.com/Shopify/krane/pull/720
|
46
|
+
- Fixed via monkeypatch in lib/ext/krane/kubernetes_resource.rb
|
47
|
+
* Move Docker timestamp tag logic into the `Tags` class.
|
48
|
+
* Refactor Docker timestamp tag logic.
|
49
|
+
* Change deployment names so they're more descriptive of the role (i.e. web, worker, etc)
|
50
|
+
- Rails app deployment changes from [app_name]-deployment to [app_name]-web.
|
51
|
+
- Database deployment changes from [app_name]-[environment]-[adapter] to [app-name]-web-[adapter].
|
52
|
+
* Add shortcut for specifying number of Rails app replicas.
|
53
|
+
* Move registry secret from the `rails_app` plugin to the Kubernetes spec.
|
54
|
+
* Fix rollback functionality.
|
55
|
+
|
56
|
+
## 0.2.0
|
57
|
+
* Move Kubernetes CLI error classes into kubernetes-cli gem.
|
58
|
+
* Update README to indicate Kuby supports Rails 5.1 and up.
|
59
|
+
* Depend on railties >= 5.1.
|
60
|
+
|
1
61
|
## 0.1.0
|
2
62
|
* Birthday!
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,170 +8,13 @@ At its core, Kuby is a set of tools and smart defaults that encapsulate and codi
|
|
8
8
|
|
9
9
|
Under the hood, Kuby leverages the power of Docker and Kubernetes. It tries to make these technologies accessible to the average Rails dev without requiring a devops black belt.
|
10
10
|
|
11
|
-
## Raison d'etre
|
12
|
-
|
13
|
-
One of Rails' most notorious mantras is "convention over configuration," i.e. sane defaults that limit the cognitive overhead of application development. Rails has survived for as long as it has precisely because it makes so many decisions for you, especially compared to other web application frameworks. It's easy to learn and easy to build with. The development experience is fantastic... right up until the point you want to deploy your app to production. It's at that point that the hand-holding stops. Like the Roadrunner, Rails stops right before the cliff and lets you, Wile E. Coyote, sail over the edge.
|
14
|
-
|
15
|
-
![Wile E. Coytote](coyote.jpg)
|
16
|
-
|
17
|
-
Perhaps [Stefan Wintermeyer](https://twitter.com/wintermeyer) said it best during his appearance on the Ruby Rogues podcast, [episode 403](https://devchat.tv/ruby-rogues/rr-403-rails-needs-active-deployment-with-stefan-wintermeyer/):
|
18
|
-
|
19
|
-
> "In my experience, deployment is one of the major problems of normal Rails users. It is a big pain to set up a deployment system for a Rails application, and I don't see anything out there that makes it easier. [...] I believe that we lose quite a lot of companies and new developers on this step. Because everything else [is] so much easier with Rails. But that last step - and it's a super important step - is still super complicated."
|
20
|
-
|
21
|
-
## Docker and Kubernetes
|
22
|
-
|
23
|
-
Why bet the farm on Docker and Kubernetes?
|
24
|
-
|
25
|
-
### Docker
|
26
|
-
|
27
|
-
When Docker came on the scene in 2013 it was seen as a game-changer. Applications that used to be deployed onto hand-provisioned servers can now be bundled up into neat little packages and transferred between computers in their entirety. Since the whole application - dependencies, operating system components, assets, code, etc - can be passed around as a single artifact, Docker images curtail the need for manually provisioned servers and eliminate a whole class of "works on my machine" problems.
|
28
|
-
|
29
|
-
### Kubernetes
|
30
|
-
|
31
|
-
Kubernetes has taken the ops world by storm. It's resilient to failure, portable across a variety of cloud providers, and backed by industry-leading organizations like the CNCF. Kubernetes configuration is portable enough to be used, without modification, on just about any Kubernetes cluster, making migrations not only feasible, but easy. Many cloud providers like Google GCP, Amazon AWS, Microsoft Azure, DigitalOcean, and Linode support Kubernetes. Most of these providers will manage the Kubernetes cluster for you, and in some cases will even provide it free of charge (you pay only for the compute resources).
|
32
|
-
|
33
11
|
## Getting Started
|
34
12
|
|
35
|
-
|
36
|
-
|
37
|
-
### Choosing a Provider
|
38
|
-
|
39
|
-
The first step in deploying your app is to choose a hosting provider. At the time of this writing, Kuby supports DigitalOcean and Linode, but support for more providers is coming soon. Use your provider's dashboard to spin up a Kubernetes cluster. In most cases, this shouldn't involve more than a few button clicks.
|
40
|
-
|
41
|
-
### The Container Registry
|
42
|
-
|
43
|
-
Kuby uses Docker to package up your application into a Docker _image_. Images are then pushed (i.e. uploaded) to something called a "container registry." Container registries host Docker images so they can be pulled (i.e. downloaded) later.
|
44
|
-
|
45
|
-
Although there are a number of container registries available (some free and some paid), consider using the Gitlab registry. Gitlab's registry is free and unlimited. You don't have to host your code on Gitlab to take advantage of the registry, but they're great for that too.
|
46
|
-
|
47
|
-
### Integrating Kuby
|
48
|
-
|
49
|
-
Kuby configuration is done via a [DSL](https://en.wikipedia.org/wiki/Domain-specific_language). There are two main sections, one for Docker and one for Kubernetes. Put the config into a Rails initializer, eg. config/initializers/kuby.rb.
|
50
|
-
|
51
|
-
Here's what a complete config looks like:
|
52
|
-
|
53
|
-
```ruby
|
54
|
-
Kuby.define(:production) do
|
55
|
-
docker do
|
56
|
-
credentials do
|
57
|
-
username ENV['DOCKER_USERNAME']
|
58
|
-
password ENV['DOCKER_PASSWORD']
|
59
|
-
email ENV['DOCKER_EMAIL']
|
60
|
-
end
|
61
|
-
|
62
|
-
image_url 'registry.gitlab.com/username/repo'
|
63
|
-
end
|
64
|
-
|
65
|
-
kubernetes do
|
66
|
-
provider :digitalocean do
|
67
|
-
access_token ENV['DIGITALOCEAN_ACCESS_TOKEN']
|
68
|
-
cluster_id 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
|
69
|
-
end
|
70
|
-
|
71
|
-
add_plugin :rails_app do
|
72
|
-
hostname 'mywebsite.com'
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
```
|
77
|
-
|
78
|
-
Let's go over this config in detail.
|
79
|
-
|
80
|
-
### Deploy Environments
|
81
|
-
|
82
|
-
The first line defines the _deploy environment_:
|
83
|
-
|
84
|
-
```ruby
|
85
|
-
Kuby.define(:production)
|
86
|
-
```
|
87
|
-
|
88
|
-
Deploy environments usually closely mirror your Rails environments. For example, you might create a new Rails environment called "staging" or "preprod" that's used to test production changes before they go live. You'll want to create a "staging" Kuby deploy environment as well.
|
89
|
-
|
90
|
-
If you're a small shop or hobbyist though, chances are the "production" deploy environment is all you need.
|
91
|
-
|
92
|
-
### Configuring Docker
|
93
|
-
|
94
|
-
Kuby can automatically "dockerize" your application. You just need to tell it where to push images and provide some credentials:
|
95
|
-
|
96
|
-
```ruby
|
97
|
-
docker do
|
98
|
-
credentials do
|
99
|
-
username ENV['DOCKER_USERNAME']
|
100
|
-
password ENV['DOCKER_PASSWORD']
|
101
|
-
email ENV['DOCKER_EMAIL']
|
102
|
-
end
|
103
|
-
|
104
|
-
image_url 'registry.gitlab.com/username/repo'
|
105
|
-
end
|
106
|
-
```
|
107
|
-
|
108
|
-
The username, password, and email fields are used to authenticate with the Docker registry that hosts your images. For Gitlab, you'll need to create a [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) instead of your password. The `image_url` field is the full URL to your image, including the registry's domain.
|
109
|
-
|
110
|
-
In the example above, the username, password, and email are all provided as environment variables. **NEVER** hard-code sensitive information like this in your Kuby config or check it into source control (i.e. git). Consider using a tool like [dotenv](https://github.com/bkeepers/dotenv) to automatically load the variables from a file when your app starts (NOTE: don't check the .env file into git either!)
|
111
|
-
|
112
|
-
### Configuring Kubernetes
|
113
|
-
|
114
|
-
Now that your app can be packaged up into a Docker image, it's time to use Kubernetes to run it. There are two top-level concerns in the Kubernetes section of your Kuby config: providers and plugins.
|
115
|
-
|
116
|
-
#### Providers
|
117
|
-
|
118
|
-
Each Kubernetes definition must have a provider configured. Providers correspond to the hosting provider you chose earlier. For example, you'll need to add the `:digitalocean` provider to deploy to a managed DigitalOcean Kubernetes cluster.
|
119
|
-
|
120
|
-
```ruby
|
121
|
-
kubernetes do
|
122
|
-
provider :digitalocean do
|
123
|
-
access_token ENV['DIGITALOCEAN_ACCESS_TOKEN']
|
124
|
-
cluster_id 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
|
125
|
-
end
|
126
|
-
end
|
127
|
-
```
|
128
|
-
|
129
|
-
Kuby providers are distributed as individual rubygems. Add the one you need to your Gemfile, for example:
|
130
|
-
|
131
|
-
```ruby
|
132
|
-
gem 'kuby-digitalocean', '~> 0.1'
|
133
|
-
```
|
134
|
-
|
135
|
-
Providers can have different config options, so make sure you consult the gem's README for the provider you've chosen.
|
136
|
-
|
137
|
-
#### Plugins
|
138
|
-
|
139
|
-
Nearly all Kuby's functionality is provided via plugins. For example, simply add the `:rails_app` plugin to get your Rails app ready to deploy:
|
140
|
-
|
141
|
-
```ruby
|
142
|
-
add_plugin :rails_app
|
143
|
-
```
|
144
|
-
|
145
|
-
To indicate your app exists behind a particular domain name, specify the `hostname` option:
|
146
|
-
|
147
|
-
```ruby
|
148
|
-
add_plugin :rails_app do
|
149
|
-
hostname 'mywebsite.com'
|
150
|
-
end
|
151
|
-
```
|
152
|
-
|
153
|
-
Configuring DNS to point to your Kubernetes cluster is outside the scope of this README, but all the hosting providers should have tutorials. For example, [here's the one](https://www.digitalocean.com/community/tutorials/how-to-point-to-digitalocean-nameservers-from-common-domain-registrars) from DigitalOcean.
|
154
|
-
|
155
|
-
## Deploying
|
156
|
-
|
157
|
-
Now that Kuby is configured and your Kubernetes cluster is ready, it's time to deploy!
|
158
|
-
|
159
|
-
1. Build the Docker image
|
160
|
-
|
161
|
-
```sh
|
162
|
-
bundle exec rake kuby:build
|
163
|
-
```
|
164
|
-
1. Push the Docker image to the container registry
|
13
|
+
See the [Quick Start Guide](https://github.com/getkuby/kuby-core/wiki/Quick-Start-Guide)
|
165
14
|
|
166
|
-
|
167
|
-
bundle exec rake kuby:push
|
168
|
-
```
|
169
|
-
1. Deploy!
|
15
|
+
## More Info
|
170
16
|
|
171
|
-
|
172
|
-
bundle exec rake kuby:deploy
|
173
|
-
```
|
174
|
-
1. Rejoice
|
17
|
+
See the [wiki](https://github.com/getkuby/kuby-core/wiki).
|
175
18
|
|
176
19
|
## Running Tests
|
177
20
|
|
data/kuby-core.gemspec
CHANGED
@@ -15,13 +15,14 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_dependency 'colorize', '~> 0.8'
|
16
16
|
s.add_dependency 'docker-remote', '~> 0.1'
|
17
17
|
s.add_dependency 'krane', '~> 1.0'
|
18
|
-
s.add_dependency 'kuby-cert-manager', '~> 0.
|
19
|
-
s.add_dependency 'kube-dsl', '~> 0.
|
20
|
-
s.add_dependency 'kuby-kube-db', '~> 0.
|
21
|
-
s.add_dependency 'kubernetes-cli', '~> 0.
|
22
|
-
s.add_dependency 'railties', '
|
18
|
+
s.add_dependency 'kuby-cert-manager', '~> 0.2'
|
19
|
+
s.add_dependency 'kube-dsl', '~> 0.3'
|
20
|
+
s.add_dependency 'kuby-kube-db', '~> 0.4'
|
21
|
+
s.add_dependency 'kubernetes-cli', '~> 0.2'
|
22
|
+
s.add_dependency 'railties', '>= 5.1'
|
23
23
|
s.add_dependency 'rouge', '~> 3.0'
|
24
24
|
|
25
25
|
s.require_path = 'lib'
|
26
|
+
|
26
27
|
s.files = Dir['{lib,spec}/**/*', 'Gemfile', 'LICENSE', 'CHANGELOG.md', 'README.md', 'Rakefile', 'kuby-core.gemspec']
|
27
28
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'krane/kubernetes_resource'
|
2
|
+
|
3
|
+
# See: https://github.com/Shopify/krane/pull/720
|
4
|
+
module Krane
|
5
|
+
class KubernetesResource
|
6
|
+
class << self
|
7
|
+
def class_for_kind(kind)
|
8
|
+
if Krane.const_defined?(kind, false)
|
9
|
+
Krane.const_get(kind, false)
|
10
|
+
end
|
11
|
+
rescue NameError
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/kuby.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
require 'kuby/railtie'
|
2
2
|
|
3
|
+
begin
|
4
|
+
require 'kuby/kubernetes/plugins/rails_app/generators/kuby'
|
5
|
+
rescue NameError
|
6
|
+
end
|
7
|
+
|
3
8
|
module Kuby
|
4
9
|
autoload :BasicLogger, 'kuby/basic_logger'
|
5
10
|
autoload :CLIBase, 'kuby/cli_base'
|
6
11
|
autoload :Definition, 'kuby/definition'
|
7
12
|
autoload :Docker, 'kuby/docker'
|
13
|
+
autoload :Environment, 'kuby/environment'
|
8
14
|
autoload :Kubernetes, 'kuby/kubernetes'
|
9
15
|
autoload :Middleware, 'kuby/middleware'
|
10
16
|
autoload :Tasks, 'kuby/tasks'
|
@@ -14,19 +20,25 @@ module Kuby
|
|
14
20
|
|
15
21
|
class << self
|
16
22
|
attr_reader :definition
|
17
|
-
|
23
|
+
attr_writer :logger
|
18
24
|
|
19
|
-
def
|
20
|
-
|
21
|
-
definitions[environment] ||= Definition.new(environment, app, &block)
|
25
|
+
def load!
|
26
|
+
require ENV['KUBY_CONFIG'] || File.join('.', 'kuby.rb')
|
22
27
|
end
|
23
28
|
|
24
|
-
def
|
25
|
-
|
29
|
+
def define(name, &block)
|
30
|
+
raise 'Kuby is already configured' if @definition
|
31
|
+
|
32
|
+
@definition = Definition.new(name.to_s)
|
33
|
+
@definition.instance_eval(&block)
|
34
|
+
|
35
|
+
@definition.environments.each do |_, env|
|
36
|
+
env.kubernetes.after_configuration
|
37
|
+
end
|
26
38
|
end
|
27
39
|
|
28
|
-
def
|
29
|
-
|
40
|
+
def environment(name = env)
|
41
|
+
definition.environment(name.to_s) do
|
30
42
|
raise UndefinedEnvironmentError, "couldn't find a Kuby environment named "\
|
31
43
|
"'#{environment}'"
|
32
44
|
end
|
@@ -56,11 +68,19 @@ module Kuby
|
|
56
68
|
@plugins ||= {}
|
57
69
|
end
|
58
70
|
|
59
|
-
def
|
71
|
+
def logger
|
72
|
+
@logger ||= BasicLogger.new(STDERR)
|
73
|
+
end
|
74
|
+
|
75
|
+
def register_package(package_name, package_def = nil)
|
60
76
|
packages[package_name] = case package_def
|
77
|
+
when NilClass
|
78
|
+
Kuby::Docker::Packages::SimpleManagedPackage.new(
|
79
|
+
package_name
|
80
|
+
)
|
61
81
|
when String
|
62
|
-
Kuby::Docker::Packages::
|
63
|
-
|
82
|
+
Kuby::Docker::Packages::SimpleManagedPackage.new(
|
83
|
+
package_def
|
64
84
|
)
|
65
85
|
when Hash
|
66
86
|
Kuby::Docker::Packages::ManagedPackage.new(
|
@@ -77,7 +97,7 @@ module Kuby
|
|
77
97
|
|
78
98
|
def env
|
79
99
|
ENV.fetch('KUBY_ENV') do
|
80
|
-
(
|
100
|
+
(definition.environments.keys.first || Rails.env).to_s
|
81
101
|
end
|
82
102
|
end
|
83
103
|
end
|
@@ -105,8 +125,3 @@ Kuby.register_package(:c_toolchain,
|
|
105
125
|
debian: 'build-essential',
|
106
126
|
alpine: 'build-base'
|
107
127
|
)
|
108
|
-
|
109
|
-
Kuby.register_package(:sqlite_dev,
|
110
|
-
debian: 'libsqlite3-dev',
|
111
|
-
alpine: 'sqlite-dev'
|
112
|
-
)
|
data/lib/kuby/definition.rb
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
module Kuby
|
2
2
|
class Definition
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :app_name
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
|
5
|
+
def initialize(app_name, &block)
|
6
|
+
@app_name = app_name
|
7
|
+
end
|
8
|
+
|
9
|
+
def environment(name = Kuby.env, &block)
|
10
|
+
name = name.to_s
|
11
|
+
|
12
|
+
if name
|
13
|
+
environments[name] ||= Environment.new(name, self)
|
14
|
+
end
|
15
|
+
|
16
|
+
if block_given?
|
17
|
+
environments[name].instance_eval(&block)
|
18
|
+
end
|
8
19
|
|
9
|
-
|
10
|
-
kubernetes.after_configuration
|
20
|
+
environments[name]
|
11
21
|
end
|
12
22
|
|
13
|
-
def docker
|
14
|
-
|
15
|
-
@docker.instance_eval(&block) if block
|
16
|
-
@docker
|
23
|
+
def docker
|
24
|
+
environment.docker
|
17
25
|
end
|
18
26
|
|
19
|
-
def kubernetes
|
20
|
-
|
21
|
-
@kubernetes.instance_eval(&block) if block
|
22
|
-
@kubernetes
|
27
|
+
def kubernetes
|
28
|
+
environment.kubernetes
|
23
29
|
end
|
24
30
|
|
25
|
-
def
|
26
|
-
@
|
31
|
+
def environments
|
32
|
+
@environments ||= {}
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
data/lib/kuby/docker.rb
CHANGED
@@ -10,12 +10,13 @@ module Kuby
|
|
10
10
|
autoload :Credentials, 'kuby/docker/credentials'
|
11
11
|
autoload :Debian, 'kuby/docker/debian'
|
12
12
|
autoload :Dockerfile, 'kuby/docker/dockerfile'
|
13
|
+
autoload :InlineLayer, 'kuby/docker/inline_layer'
|
14
|
+
autoload :Layer, 'kuby/docker/layer'
|
13
15
|
autoload :LayerStack, 'kuby/docker/layer_stack'
|
14
16
|
autoload :LocalTags, 'kuby/docker/local_tags'
|
15
17
|
autoload :Metadata, 'kuby/docker/metadata'
|
16
18
|
autoload :Packages, 'kuby/docker/packages'
|
17
19
|
autoload :PackagePhase, 'kuby/docker/package_phase'
|
18
|
-
autoload :Phase, 'kuby/docker/phase'
|
19
20
|
autoload :RemoteTags, 'kuby/docker/remote_tags'
|
20
21
|
autoload :SetupPhase, 'kuby/docker/setup_phase'
|
21
22
|
autoload :Spec, 'kuby/docker/spec'
|