kuby-core 0.6.0 → 0.8.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 +24 -0
- data/kuby-core.gemspec +7 -3
- data/lib/kuby.rb +9 -7
- data/lib/kuby/definition.rb +0 -8
- data/lib/kuby/docker/cli.rb +32 -0
- data/lib/kuby/docker/errors.rb +1 -0
- data/lib/kuby/docker/layer.rb +4 -4
- data/lib/kuby/docker/metadata.rb +11 -7
- data/lib/kuby/docker/package_phase.rb +2 -2
- data/lib/kuby/docker/spec.rb +11 -11
- data/lib/kuby/docker/timestamp_tag.rb +6 -3
- data/lib/kuby/environment.rb +6 -2
- data/lib/kuby/kubernetes.rb +0 -2
- data/lib/kuby/kubernetes/deploy_task.rb +0 -1
- data/lib/kuby/kubernetes/deployer.rb +7 -7
- data/lib/kuby/kubernetes/minikube_provider.rb +4 -0
- data/lib/kuby/kubernetes/provider.rb +5 -5
- data/lib/kuby/kubernetes/spec.rb +8 -8
- data/lib/kuby/plugin.rb +59 -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 +75 -0
- data/lib/kuby/{kubernetes/plugins → plugins}/rails_app/generators/kuby.rb +0 -0
- data/lib/kuby/plugins/rails_app/mysql.rb +155 -0
- data/lib/kuby/plugins/rails_app/plugin.rb +398 -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/{kubernetes/plugins → plugins}/rails_app/tasks.rake +10 -2
- data/lib/kuby/tasks.rb +28 -9
- data/lib/kuby/tasks/kuby.rake +1 -1
- data/lib/kuby/version.rb +1 -1
- data/spec/docker/timestamp_tag_spec.rb +11 -0
- data/spec/spec_helper.rb +102 -0
- metadata +50 -27
- 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
@@ -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
|
-
)
|