kuby-core 0.7.2 → 0.10.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 +42 -0
- data/Gemfile +1 -0
- data/README.md +11 -1
- data/bin/kuby +4 -0
- data/kuby-core.gemspec +9 -4
- data/lib/kuby.rb +58 -19
- data/lib/kuby/basic_logger.rb +13 -0
- data/lib/kuby/cli_base.rb +81 -8
- data/lib/kuby/commands.rb +244 -0
- data/lib/kuby/definition.rb +1 -11
- data/lib/kuby/dev_setup.rb +255 -0
- data/lib/kuby/docker.rb +1 -0
- data/lib/kuby/docker/bundler_phase.rb +3 -3
- data/lib/kuby/docker/cli.rb +13 -1
- data/lib/kuby/docker/dev_spec.rb +131 -0
- data/lib/kuby/docker/dockerfile.rb +16 -1
- data/lib/kuby/docker/layer.rb +4 -4
- data/lib/kuby/docker/layer_stack.rb +4 -0
- data/lib/kuby/docker/local_tags.rb +4 -0
- data/lib/kuby/docker/metadata.rb +18 -38
- data/lib/kuby/docker/package_phase.rb +2 -2
- data/lib/kuby/docker/setup_phase.rb +3 -2
- data/lib/kuby/docker/spec.rb +42 -16
- data/lib/kuby/docker/timestamp_tag.rb +6 -0
- data/lib/kuby/environment.rb +15 -2
- data/lib/kuby/kubernetes.rb +9 -11
- data/lib/kuby/kubernetes/deploy_task.rb +4 -1
- data/lib/kuby/kubernetes/deployer.rb +70 -15
- data/lib/kuby/kubernetes/{minikube_provider.rb → docker_desktop_provider.rb} +8 -4
- data/lib/kuby/kubernetes/provider.rb +12 -8
- data/lib/kuby/kubernetes/spec.rb +30 -29
- data/lib/kuby/plugin.rb +59 -0
- data/lib/kuby/plugin_registry.rb +27 -0
- data/lib/kuby/plugins.rb +6 -0
- data/lib/kuby/plugins/nginx_ingress.rb +71 -0
- data/lib/kuby/plugins/rails_app.rb +18 -0
- data/lib/kuby/plugins/rails_app/asset_copy_task.rb +117 -0
- data/lib/kuby/plugins/rails_app/assets.rb +347 -0
- data/lib/kuby/plugins/rails_app/database.rb +74 -0
- data/lib/kuby/{kubernetes/plugins → plugins}/rails_app/generators/kuby.rb +14 -16
- data/lib/kuby/plugins/rails_app/mysql.rb +152 -0
- data/lib/kuby/plugins/rails_app/plugin.rb +593 -0
- data/lib/kuby/plugins/rails_app/postgres.rb +143 -0
- data/lib/kuby/plugins/rails_app/rewrite_db_config.rb +11 -0
- data/lib/kuby/plugins/rails_app/sqlite.rb +32 -0
- data/lib/kuby/plugins/rails_app/tasks.rake +36 -0
- data/lib/kuby/rails_commands.rb +89 -0
- data/lib/kuby/railtie.rb +0 -4
- data/lib/kuby/tasks.rb +85 -31
- data/lib/kuby/version.rb +1 -1
- data/spec/docker/metadata_spec.rb +84 -0
- data/spec/docker/spec_spec.rb +266 -0
- data/spec/docker/timestamp_tag_spec.rb +54 -4
- data/spec/dummy/Gemfile +54 -0
- data/spec/dummy/Gemfile.lock +223 -0
- data/spec/dummy/README.md +24 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/channels/consumer.js +6 -0
- data/spec/dummy/app/javascript/channels/index.js +5 -0
- data/spec/dummy/app/javascript/packs/application.js +17 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +114 -0
- data/spec/dummy/bin/rails +9 -0
- data/spec/dummy/bin/rake +9 -0
- data/spec/dummy/bin/setup +36 -0
- data/spec/dummy/bin/spring +17 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +19 -0
- data/spec/dummy/config/boot.rb +4 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/credentials.yml.enc +1 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +62 -0
- data/spec/dummy/config/environments/production.rb +112 -0
- data/spec/dummy/config/environments/test.rb +49 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +30 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/master.key +1 -0
- data/spec/dummy/config/puma.rb +38 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/package.json +11 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +1 -0
- data/spec/dummy/test/application_system_test_case.rb +5 -0
- data/spec/dummy/test/channels/application_cable/connection_test.rb +11 -0
- data/spec/dummy/test/test_helper.rb +13 -0
- data/spec/dummy/tmp/cache/bootsnap-load-path-cache +0 -0
- data/spec/spec_helper.rb +77 -2
- data/spec/support/docker/fake_cli.rb +54 -0
- data/spec/support/docker/remote/fake_client.rb +16 -0
- data/spec/trailing_hash_spec.rb +23 -0
- metadata +139 -30
- data/lib/ext/krane/kubernetes_resource.rb +0 -16
- data/lib/kuby/kubernetes/plugin.rb +0 -55
- data/lib/kuby/kubernetes/plugins.rb +0 -8
- data/lib/kuby/kubernetes/plugins/nginx_ingress.rb +0 -73
- data/lib/kuby/kubernetes/plugins/rails_app.rb +0 -16
- data/lib/kuby/kubernetes/plugins/rails_app/database.rb +0 -79
- data/lib/kuby/kubernetes/plugins/rails_app/mysql.rb +0 -154
- data/lib/kuby/kubernetes/plugins/rails_app/plugin.rb +0 -379
- data/lib/kuby/kubernetes/plugins/rails_app/postgres.rb +0 -142
- data/lib/kuby/kubernetes/plugins/rails_app/rewrite_db_config.rb +0 -13
- data/lib/kuby/kubernetes/plugins/rails_app/sqlite.rb +0 -30
- data/lib/kuby/kubernetes/plugins/rails_app/tasks.rake +0 -28
- data/lib/kuby/tasks/kuby.rake +0 -70
@@ -1,142 +0,0 @@
|
|
1
|
-
require 'kube-dsl'
|
2
|
-
require 'kuby/kube-db'
|
3
|
-
|
4
|
-
module Kuby
|
5
|
-
module Kubernetes
|
6
|
-
module Plugins
|
7
|
-
module RailsApp
|
8
|
-
class Postgres < Kuby::Kubernetes::Plugin
|
9
|
-
ROLE = 'web'.freeze
|
10
|
-
|
11
|
-
attr_reader :definition, :environment, :configs
|
12
|
-
|
13
|
-
def initialize(definition, environment, configs)
|
14
|
-
@definition = definition
|
15
|
-
@environment = environment
|
16
|
-
@configs = configs
|
17
|
-
|
18
|
-
user(config['username'])
|
19
|
-
password(config['password'])
|
20
|
-
end
|
21
|
-
|
22
|
-
def resources
|
23
|
-
@resources ||= [secret, database]
|
24
|
-
end
|
25
|
-
|
26
|
-
def after_configuration
|
27
|
-
definition.docker.package_phase.add(:postgres_dev)
|
28
|
-
definition.docker.package_phase.add(:postgres_client)
|
29
|
-
end
|
30
|
-
|
31
|
-
def host
|
32
|
-
# host is the same as the name thanks to k8s DNS
|
33
|
-
@host ||= database.metadata.name
|
34
|
-
end
|
35
|
-
|
36
|
-
def rewritten_configs
|
37
|
-
# deep dup
|
38
|
-
@rewritten_configs ||= Marshal.load(Marshal.dump(configs)).tap do |new_configs|
|
39
|
-
new_configs[environment]['host'] = host
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def user(user)
|
44
|
-
secret do
|
45
|
-
data do
|
46
|
-
set :POSTGRES_USER, user
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def password(password)
|
52
|
-
secret do
|
53
|
-
data do
|
54
|
-
set :POSTGRES_PASSWORD, password
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def secret(&block)
|
60
|
-
context = self
|
61
|
-
|
62
|
-
@secret ||= KubeDSL.secret do
|
63
|
-
metadata do
|
64
|
-
name "#{context.base_name}-postgres-secret"
|
65
|
-
namespace context.kubernetes.namespace.metadata.name
|
66
|
-
end
|
67
|
-
|
68
|
-
type 'Opaque'
|
69
|
-
end
|
70
|
-
|
71
|
-
@secret.instance_eval(&block) if block
|
72
|
-
@secret
|
73
|
-
end
|
74
|
-
|
75
|
-
def database(&block)
|
76
|
-
context = self
|
77
|
-
|
78
|
-
@database ||= Kuby::KubeDB.postgres do
|
79
|
-
api_version 'kubedb.com/v1alpha1'
|
80
|
-
|
81
|
-
metadata do
|
82
|
-
name "#{context.base_name}-postgres"
|
83
|
-
namespace context.kubernetes.namespace.metadata.name
|
84
|
-
end
|
85
|
-
|
86
|
-
spec do
|
87
|
-
database_secret do
|
88
|
-
secret_name context.secret.metadata.name
|
89
|
-
end
|
90
|
-
|
91
|
-
version '11.2'
|
92
|
-
standby_mode 'Hot'
|
93
|
-
streaming_mode 'asynchronous'
|
94
|
-
storage_type 'Durable'
|
95
|
-
|
96
|
-
storage do
|
97
|
-
storage_class_name context.kubernetes.provider.storage_class_name
|
98
|
-
access_modes ['ReadWriteOnce']
|
99
|
-
|
100
|
-
resources do
|
101
|
-
requests do
|
102
|
-
add :storage, '10Gi'
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
termination_policy 'DoNotTerminate'
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
@database.instance_eval(&block) if block
|
112
|
-
@database
|
113
|
-
end
|
114
|
-
|
115
|
-
def base_name
|
116
|
-
@base_name ||= "#{kubernetes.selector_app}-#{ROLE}"
|
117
|
-
end
|
118
|
-
|
119
|
-
def kubernetes
|
120
|
-
definition.kubernetes
|
121
|
-
end
|
122
|
-
|
123
|
-
private
|
124
|
-
|
125
|
-
def config
|
126
|
-
configs[environment]
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
Kuby.register_package(:postgres_dev,
|
135
|
-
debian: 'postgresql-client',
|
136
|
-
alpine: 'postgresql-dev'
|
137
|
-
)
|
138
|
-
|
139
|
-
Kuby.register_package(:postgres_client,
|
140
|
-
debian: 'postgresql-client',
|
141
|
-
alpine: 'postgresql-client'
|
142
|
-
)
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Kuby
|
2
|
-
module Kubernetes
|
3
|
-
module Plugins
|
4
|
-
module RailsApp
|
5
|
-
class Sqlite < Kuby::Kubernetes::Plugin
|
6
|
-
attr_reader :definition
|
7
|
-
|
8
|
-
def initialize(definition, *)
|
9
|
-
@definition = definition
|
10
|
-
end
|
11
|
-
|
12
|
-
def after_configuration
|
13
|
-
definition.docker.package_phase.add(:sqlite_dev)
|
14
|
-
definition.docker.package_phase.add(:sqlite_client)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
Kuby.register_package(:sqlite_dev,
|
23
|
-
debian: 'libsqlite3-dev',
|
24
|
-
alpine: 'sqlite-dev'
|
25
|
-
)
|
26
|
-
|
27
|
-
Kuby.register_package(:sqlite_client,
|
28
|
-
debian: 'sqlite3',
|
29
|
-
alpine: 'sqlite'
|
30
|
-
)
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
|
3
|
-
namespace :kuby do
|
4
|
-
namespace :rails_app do
|
5
|
-
namespace :db do
|
6
|
-
task :rewrite_config do
|
7
|
-
Kuby.load!
|
8
|
-
|
9
|
-
config_file = File.join(Kuby.definition.kubernetes.plugin(:rails_app).root, 'config', 'database.yml')
|
10
|
-
database = Kuby.definition.kubernetes.plugin(:rails_app).database
|
11
|
-
|
12
|
-
if database.respond_to?(:rewritten_configs)
|
13
|
-
File.write(config_file, YAML.dump(database.rewritten_configs))
|
14
|
-
Kuby.logger.info("Wrote #{config_file}")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
task :create_unless_exists do
|
19
|
-
begin
|
20
|
-
Rake::Task['environment'].invoke
|
21
|
-
ActiveRecord::Base.connection
|
22
|
-
rescue ActiveRecord::NoDatabaseError => e
|
23
|
-
Rake::Task['db:create'].invoke
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/kuby/tasks/kuby.rake
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'shellwords'
|
2
|
-
|
3
|
-
namespace :kuby do
|
4
|
-
def tasks
|
5
|
-
Kuby.load!
|
6
|
-
@tasks ||= Kuby::Tasks.new(Kuby.definition)
|
7
|
-
end
|
8
|
-
|
9
|
-
task :dockerfile do
|
10
|
-
tasks.print_dockerfile
|
11
|
-
end
|
12
|
-
|
13
|
-
task :build do
|
14
|
-
tasks.build
|
15
|
-
end
|
16
|
-
|
17
|
-
task :run do
|
18
|
-
tasks.run
|
19
|
-
end
|
20
|
-
|
21
|
-
task :push do
|
22
|
-
tasks.push
|
23
|
-
end
|
24
|
-
|
25
|
-
task :resources do
|
26
|
-
tasks.print_resources
|
27
|
-
end
|
28
|
-
|
29
|
-
task :kubectl, [:cmd] do |_, args|
|
30
|
-
tasks.kubectl(Shellwords.shellsplit(args[:cmd]))
|
31
|
-
end
|
32
|
-
|
33
|
-
task :deploy do
|
34
|
-
tasks.deploy
|
35
|
-
end
|
36
|
-
|
37
|
-
task :rollback do
|
38
|
-
tasks.rollback
|
39
|
-
end
|
40
|
-
|
41
|
-
task :kubeconfig do
|
42
|
-
tasks.print_kubeconfig
|
43
|
-
end
|
44
|
-
|
45
|
-
task :setup do
|
46
|
-
tasks.setup
|
47
|
-
end
|
48
|
-
|
49
|
-
namespace :remote do
|
50
|
-
task :logs do
|
51
|
-
tasks.remote_logs
|
52
|
-
end
|
53
|
-
|
54
|
-
task :status do
|
55
|
-
tasks.remote_status
|
56
|
-
end
|
57
|
-
|
58
|
-
task :shell do
|
59
|
-
tasks.remote_shell
|
60
|
-
end
|
61
|
-
|
62
|
-
task :console do
|
63
|
-
tasks.remote_console
|
64
|
-
end
|
65
|
-
|
66
|
-
task :dbconsole do
|
67
|
-
tasks.remote_dbconsole
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|