Class: Kuby::Kubernetes::Plugins::RailsApp::MySQL
Instance Attribute Summary collapse
Instance Method Summary
collapse
#after_deploy, #after_setup, #before_deploy, #before_setup, #configure, #setup
Constructor Details
#initialize(definition, environment, configs) ⇒ MySQL
Returns a new instance of MySQL.
11
12
13
14
15
16
17
18
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 11
def initialize(definition, environment, configs)
@definition = definition
@environment = environment
@configs = configs
user(config['username'])
password(config['password'])
end
|
Instance Attribute Details
#configs ⇒ Object
Returns the value of attribute configs.
9
10
11
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 9
def configs
@configs
end
|
#definition ⇒ Object
Returns the value of attribute definition.
9
10
11
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 9
def definition
@definition
end
|
#environment ⇒ Object
Returns the value of attribute environment.
9
10
11
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 9
def environment
@environment
end
|
Instance Method Details
#after_configuration ⇒ Object
24
25
26
27
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 24
def after_configuration
definition.docker.package_phase.add(:mysql_dev)
definition.docker.package_phase.add(:mysql_client)
end
|
#app ⇒ Object
119
120
121
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 119
def app
definition.app
end
|
#base_name ⇒ Object
111
112
113
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 111
def base_name
@base_name ||= "#{kubernetes.selector_app}-#{environment}"
end
|
#database(&block) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 73
def database(&block)
context = self
@database ||= Kuby::KubeDB.my_sql do
api_version 'kubedb.com/v1alpha1'
metadata do
name "#{context.base_name}-mysql"
namespace context.kubernetes.namespace.metadata.name
end
spec do
database_secret do
secret_name context.secret.metadata.name
end
version '5.7-v2'
storage_type 'Durable'
storage do
storage_class_name context.kubernetes.provider.storage_class_name
access_modes ['ReadWriteOnce']
resources do
requests do
add :storage, '10Gi'
end
end
end
termination_policy 'DoNotTerminate'
end
end
@database.instance_eval(&block) if block
@database
end
|
#host ⇒ Object
29
30
31
32
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 29
def host
@host ||= database.metadata.name
end
|
#kubernetes ⇒ Object
115
116
117
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 115
def kubernetes
definition.kubernetes
end
|
#password(password) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 49
def password(password)
secret do
data do
set :password, password
end
end
end
|
#resources ⇒ Object
20
21
22
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 20
def resources
@resources ||= [secret, database]
end
|
#rewritten_configs ⇒ Object
34
35
36
37
38
39
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 34
def rewritten_configs
@rewritten_configs ||= Marshal.load(Marshal.dump(configs)).tap do |new_configs|
new_configs[environment]['host'] = host
end
end
|
#secret(&block) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 57
def secret(&block)
context = self
@secret ||= KubeDSL.secret do
metadata do
name "#{context.base_name}-mysql-secret"
namespace context.kubernetes.namespace.metadata.name
end
type 'Opaque'
end
@secret.instance_eval(&block) if block
@secret
end
|
#user(user) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/kuby/kubernetes/plugins/rails_app/mysql.rb', line 41
def user(user)
secret do
data do
set :user, user
end
end
end
|