souls 0.17.7 → 0.17.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/Gemfile.lock +22 -23
- data/LICENSE.txt +1 -1
- data/exe/souls +7 -15
- data/lib/souls.rb +1 -377
- data/lib/souls/init.rb +0 -210
- data/lib/souls/version.rb +1 -1
- data/souls.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9ec8b8cd3e1f7ed49262ff08bf985db04cf2971553fc0bce2830be53d908d4c
|
4
|
+
data.tar.gz: edec905bb1cdb4600788c7b9a6bb21cfe0769d186addd57840c46cf870bdbcda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90bf3257b5d2dd97cb568b7778dd28264fcfcdf66d9960127ebe31d07c8c282324b708d2efd409f794d5b3d23045232bc63ab119e6d94f9ebd0ecd539fb32646
|
7
|
+
data.tar.gz: c296af0062e756331e34466dda4a75e47f724ab1270209d7b00e8f4b9b747826bd323d7b3079b75f09af23bc4e70fd3376c95439803fe9e362211e0059d1df94
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
souls (0.17.
|
4
|
+
souls (0.17.7)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -13,30 +13,27 @@ GEM
|
|
13
13
|
tzinfo (~> 2.0)
|
14
14
|
zeitwerk (~> 2.3)
|
15
15
|
ast (2.4.2)
|
16
|
-
ast_utils (0.3.0)
|
17
|
-
parser (~> 2.4)
|
18
|
-
thor (>= 0.19)
|
19
16
|
concurrent-ruby (1.1.8)
|
20
17
|
diff-lcs (1.4.4)
|
21
|
-
ffi (1.
|
22
|
-
i18n (1.8.
|
18
|
+
ffi (1.15.0)
|
19
|
+
i18n (1.8.10)
|
23
20
|
concurrent-ruby (~> 1.0)
|
24
|
-
language_server-protocol (3.
|
25
|
-
listen (3.
|
21
|
+
language_server-protocol (3.16.0.0)
|
22
|
+
listen (3.5.1)
|
26
23
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
27
24
|
rb-inotify (~> 0.9, >= 0.9.10)
|
28
25
|
minitest (5.14.4)
|
29
26
|
parallel (1.20.1)
|
30
|
-
parser (
|
27
|
+
parser (3.0.0.0)
|
31
28
|
ast (~> 2.4.1)
|
32
29
|
rainbow (3.0.0)
|
33
30
|
rake (13.0.3)
|
34
31
|
rb-fsevent (0.10.4)
|
35
32
|
rb-inotify (0.10.1)
|
36
33
|
ffi (~> 1.0)
|
37
|
-
rbs (1.
|
34
|
+
rbs (1.1.1)
|
38
35
|
regexp_parser (2.1.1)
|
39
|
-
rexml (3.2.
|
36
|
+
rexml (3.2.5)
|
40
37
|
rspec (3.1.0)
|
41
38
|
rspec-core (~> 3.1.0)
|
42
39
|
rspec-expectations (~> 3.1.0)
|
@@ -49,43 +46,45 @@ GEM
|
|
49
46
|
rspec-mocks (3.1.3)
|
50
47
|
rspec-support (~> 3.1.0)
|
51
48
|
rspec-support (3.1.2)
|
52
|
-
rubocop (1.
|
49
|
+
rubocop (1.12.1)
|
53
50
|
parallel (~> 1.10)
|
54
|
-
parser (>=
|
51
|
+
parser (>= 3.0.0.0)
|
55
52
|
rainbow (>= 2.2.2, < 4.0)
|
56
53
|
regexp_parser (>= 1.8, < 3.0)
|
57
54
|
rexml
|
58
55
|
rubocop-ast (>= 1.2.0, < 2.0)
|
59
56
|
ruby-progressbar (~> 1.7)
|
60
|
-
unicode-display_width (>= 1.4.0, <
|
57
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
61
58
|
rubocop-ast (1.4.1)
|
62
59
|
parser (>= 2.7.1.5)
|
63
60
|
ruby-progressbar (1.11.0)
|
64
|
-
steep (0.
|
61
|
+
steep (0.43.1)
|
65
62
|
activesupport (>= 5.1)
|
66
|
-
|
67
|
-
language_server-protocol (~> 3.15.0.1)
|
63
|
+
language_server-protocol (>= 3.15, < 4.0)
|
68
64
|
listen (~> 3.0)
|
69
|
-
|
65
|
+
parallel (>= 1.0.0)
|
66
|
+
parser (>= 2.7)
|
70
67
|
rainbow (>= 2.2.2, < 4.0)
|
71
|
-
rbs (~> 1.
|
72
|
-
|
68
|
+
rbs (~> 1.1.0)
|
69
|
+
terminal-table (>= 2, < 4)
|
70
|
+
terminal-table (3.0.0)
|
71
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
73
72
|
tzinfo (2.0.4)
|
74
73
|
concurrent-ruby (~> 1.0)
|
75
74
|
unicode-display_width (1.7.0)
|
76
75
|
zeitwerk (2.4.2)
|
77
76
|
|
78
77
|
PLATFORMS
|
79
|
-
x86_64-darwin-20
|
80
78
|
x86_64-linux
|
81
79
|
|
82
80
|
DEPENDENCIES
|
83
81
|
activesupport (= 6.1.0)
|
82
|
+
parser (= 3.0.0)
|
84
83
|
rake (= 13.0.3)
|
85
84
|
rspec (= 3.1.0)
|
86
|
-
rubocop (= 1.
|
85
|
+
rubocop (= 1.12.1)
|
87
86
|
souls!
|
88
|
-
steep (= 0.
|
87
|
+
steep (= 0.43.1)
|
89
88
|
|
90
89
|
BUNDLED WITH
|
91
90
|
2.2.14
|
data/LICENSE.txt
CHANGED
@@ -52,7 +52,7 @@ You may add Your own copyright statement to Your modifications and may provide a
|
|
52
52
|
|
53
53
|
END OF TERMS AND CONDITIONS
|
54
54
|
|
55
|
-
Copyright
|
55
|
+
Copyright 2021 ELSOUL LABO B.V.
|
56
56
|
|
57
57
|
Licensed under the Apache License, Version 2.0 (the "License");
|
58
58
|
you may not use this file except in compliance with the License.
|
data/exe/souls
CHANGED
@@ -1,29 +1,24 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "souls"
|
3
|
-
|
3
|
+
STRAINS = ["graph", "worker", "media", "admin"]
|
4
4
|
begin
|
5
|
-
begin
|
6
|
-
require "./config/initializers/souls" unless ARGV[0] == "new" || ARGV[0] == "init"
|
7
|
-
rescue
|
8
|
-
Souls::Init.config_init
|
9
|
-
end
|
10
5
|
case ARGV[0]
|
11
6
|
when "new"
|
12
7
|
if ARGV[1].nil?
|
13
8
|
puts "you need to specify your app name \n `souls new app_name`"
|
14
9
|
exit
|
15
10
|
end
|
16
|
-
puts "Which framework: \n 1. SOULs GraphQL API \n 2. SOULs
|
11
|
+
puts "Which framework: \n 1. SOULs GraphQL API \n 2. SOULs Worker \n 3. SOULs Media Web \n 4. SOULs Admin Web \n Enter Number: "
|
17
12
|
strain = STDIN.gets.chomp.to_i
|
18
|
-
(1..
|
19
|
-
Souls::Init.
|
13
|
+
(1..4).include?(strain) ? puts("Generating SOULs.. \n") : raise(StandardError, "Choose Number 1..4")
|
14
|
+
Souls::Init.download_souls app_name: ARGV[1], repository_name: "souls_#{STRAINS[strain.to_i - 1]}"
|
20
15
|
when "s", "server"
|
21
16
|
strain = Souls.configuration.strain
|
22
17
|
case strain
|
23
18
|
when "media", "admin"
|
24
19
|
system "yarn dev"
|
25
|
-
when "
|
26
|
-
system "bundle exec
|
20
|
+
when "worker"
|
21
|
+
system "bundle exec puma -p 3000 -e development"
|
27
22
|
else
|
28
23
|
system "foreman start -f Procfile.dev"
|
29
24
|
end
|
@@ -42,8 +37,6 @@ begin
|
|
42
37
|
end
|
43
38
|
when "i", "infra"
|
44
39
|
Souls.send ARGV[1]
|
45
|
-
when "p", "proto"
|
46
|
-
Souls::Init.proto proto_package_name: "souls", service: ARGV[1]
|
47
40
|
when "init"
|
48
41
|
Souls::Init.config_init
|
49
42
|
when "-v", "--version"
|
@@ -141,8 +134,7 @@ begin
|
|
141
134
|
system "docker build . -t souls:latest"
|
142
135
|
system "docker run --rm -p 3000:3000 souls:latest"
|
143
136
|
when "deploy"
|
144
|
-
|
145
|
-
system "gcloud builds submit --config=cloudbuild.yml --project #{project_id}"
|
137
|
+
system "gcloud builds submit --config=cloudbuild.yml --project #{ARGV[1]}"
|
146
138
|
else
|
147
139
|
puts "Welcome to SOULs!"
|
148
140
|
end
|
data/lib/souls.rb
CHANGED
@@ -10,371 +10,6 @@ module Souls
|
|
10
10
|
class << self
|
11
11
|
attr_accessor :configuration
|
12
12
|
|
13
|
-
def delete_forwarding_rule forwarding_rule_name: "grpc-gke-forwarding-rule"
|
14
|
-
system "gcloud compute -q forwarding-rules delete #{forwarding_rule_name} --global"
|
15
|
-
end
|
16
|
-
|
17
|
-
def create_forwarding_rule forwarding_rule_name: "grpc-gke-forwarding-rule", proxy_name: "grpc-gke-proxy", port: 8000
|
18
|
-
system "gcloud compute -q forwarding-rules create #{forwarding_rule_name} \
|
19
|
-
--global \
|
20
|
-
--load-balancing-scheme=INTERNAL_SELF_MANAGED \
|
21
|
-
--address=0.0.0.0 \
|
22
|
-
--target-grpc-proxy=#{proxy_name} \
|
23
|
-
--ports #{port} \
|
24
|
-
--network #{Souls.configuration.network}"
|
25
|
-
end
|
26
|
-
|
27
|
-
def delete_target_grpc_proxy proxy_name: "grpc-gke-proxy"
|
28
|
-
system "gcloud compute -q target-grpc-proxies delete #{proxy_name}"
|
29
|
-
end
|
30
|
-
|
31
|
-
def create_target_grpc_proxy proxy_name: "grpc-gke-proxy", url_map_name: "grpc-gke-url-map"
|
32
|
-
system "gcloud compute -q target-grpc-proxies create #{proxy_name} \
|
33
|
-
--url-map #{url_map_name} \
|
34
|
-
--validate-for-proxyless"
|
35
|
-
end
|
36
|
-
|
37
|
-
def create_path_matcher url_map_name: "grpc-gke-url-map", service_name: "grpc-gke-helloworld-service", path_matcher_name: "grpc-gke-path-matcher", hostname: "helloworld-gke", port: "8000"
|
38
|
-
system "gcloud compute -q url-maps add-path-matcher #{url_map_name} \
|
39
|
-
--default-service #{service_name} \
|
40
|
-
--path-matcher-name #{path_matcher_name} \
|
41
|
-
--new-hosts #{hostname}:#{port}"
|
42
|
-
end
|
43
|
-
|
44
|
-
def delete_url_map url_map_name: "grpc-gke-url-map"
|
45
|
-
system "gcloud compute -q url-maps delete #{url_map_name}"
|
46
|
-
end
|
47
|
-
|
48
|
-
def create_url_map url_map_name: "grpc-gke-url-map", service_name: "grpc-gke-helloworld-service"
|
49
|
-
system "gcloud compute -q url-maps create #{url_map_name} \
|
50
|
-
--default-service #{service_name}"
|
51
|
-
end
|
52
|
-
|
53
|
-
def add_backend_service service_name: "grpc-gke-helloworld-service", zone: "us-central1-a", neg_name: ""
|
54
|
-
system "gcloud compute -q backend-services add-backend #{service_name} \
|
55
|
-
--global \
|
56
|
-
--network-endpoint-group #{neg_name} \
|
57
|
-
--network-endpoint-group-zone #{zone} \
|
58
|
-
--balancing-mode RATE \
|
59
|
-
--max-rate-per-endpoint 5"
|
60
|
-
end
|
61
|
-
|
62
|
-
def delete_backend_service service_name: "grpc-gke-helloworld-service"
|
63
|
-
system "gcloud compute -q backend-services delete #{service_name} --global"
|
64
|
-
end
|
65
|
-
|
66
|
-
def create_backend_service service_name: "grpc-gke-helloworld-service", health_check_name: "grpc-gke-helloworld-hc"
|
67
|
-
system "gcloud compute -q backend-services create #{service_name} \
|
68
|
-
--global \
|
69
|
-
--load-balancing-scheme=INTERNAL_SELF_MANAGED \
|
70
|
-
--protocol=GRPC \
|
71
|
-
--health-checks #{health_check_name}"
|
72
|
-
end
|
73
|
-
|
74
|
-
def delete_firewall_rule firewall_rule_name: "grpc-gke-allow-health-checks"
|
75
|
-
system "gcloud compute -q firewall-rules delete #{firewall_rule_name}"
|
76
|
-
end
|
77
|
-
|
78
|
-
def create_firewall_rule firewall_rule_name: "grpc-gke-allow-health-checks"
|
79
|
-
network = Souls.configuration.network
|
80
|
-
system "gcloud compute -q firewall-rules create #{firewall_rule_name} \
|
81
|
-
--network #{network} \
|
82
|
-
--action allow \
|
83
|
-
--direction INGRESS \
|
84
|
-
--source-ranges 35.191.0.0/16,130.211.0.0/22 \
|
85
|
-
--target-tags allow-health-checks \
|
86
|
-
--rules tcp:50051"
|
87
|
-
end
|
88
|
-
|
89
|
-
def delete_health_check health_check_name: "grpc-gke-helloworld-hc"
|
90
|
-
system "gcloud compute -q health-checks delete #{health_check_name}"
|
91
|
-
end
|
92
|
-
|
93
|
-
def create_health_check health_check_name: "grpc-gke-helloworld-hc"
|
94
|
-
system "gcloud compute -q health-checks create grpc #{health_check_name} --use-serving-port"
|
95
|
-
end
|
96
|
-
|
97
|
-
def create_network
|
98
|
-
return "Error: Please Set Souls.configuration" if Souls.configuration.nil?
|
99
|
-
network = Souls.configuration.network
|
100
|
-
system "gcloud compute networks create #{network}"
|
101
|
-
end
|
102
|
-
|
103
|
-
def create_firewall_tcp ip_range:
|
104
|
-
network = Souls.configuration.network
|
105
|
-
`gcloud compute firewall-rules create #{network} --network #{network} --allow tcp,udp,icmp --source-ranges #{ip_range}`
|
106
|
-
end
|
107
|
-
|
108
|
-
def create_firewall_ssh
|
109
|
-
network = Souls.configuration.network
|
110
|
-
`gcloud compute firewall-rules create #{network}-ssh --network #{network} --allow tcp:22,tcp:3389,icmp`
|
111
|
-
end
|
112
|
-
|
113
|
-
def get_network_group_list
|
114
|
-
system "gcloud compute network-endpoint-groups list"
|
115
|
-
end
|
116
|
-
|
117
|
-
def create_network_group
|
118
|
-
app = Souls.configuration.app
|
119
|
-
network = Souls.configuration.network
|
120
|
-
sub_network = Souls.configuration.network
|
121
|
-
system(
|
122
|
-
"gcloud compute network-endpoint-groups create #{app} \
|
123
|
-
--default-port=0 \
|
124
|
-
--network #{network} \
|
125
|
-
--subnet #{sub_network} \
|
126
|
-
--global"
|
127
|
-
)
|
128
|
-
end
|
129
|
-
|
130
|
-
def export_network_group
|
131
|
-
app = Souls.configuration.app
|
132
|
-
system "NEG_NAME=$(gcloud compute network-endpoint-groups list | grep #{app} | awk '{print $1}')"
|
133
|
-
`echo $NEG_NAME > ./config/neg_name`
|
134
|
-
end
|
135
|
-
|
136
|
-
def delete_network_group_list neg_name:
|
137
|
-
zone = Souls.configuration.zone
|
138
|
-
system "gcloud compute network-endpoint-groups delete #{neg_name} --zone #{zone} -q"
|
139
|
-
end
|
140
|
-
|
141
|
-
def delete_cluster
|
142
|
-
app = Souls.configuration.app
|
143
|
-
zone = Souls.configuration.zone
|
144
|
-
system "gcloud container clusters delete #{app} --zone #{zone} -q"
|
145
|
-
end
|
146
|
-
|
147
|
-
def config_set_main
|
148
|
-
project_id = Souls.configuration.main_project_id
|
149
|
-
system "gcloud config set project #{project_id}"
|
150
|
-
end
|
151
|
-
|
152
|
-
def config_set
|
153
|
-
project_id = Souls.configuration.project_id
|
154
|
-
system "gcloud config set project #{project_id}"
|
155
|
-
end
|
156
|
-
|
157
|
-
def create_cluster
|
158
|
-
app = Souls.configuration.app
|
159
|
-
network = Souls.configuration.network
|
160
|
-
sub_network = Souls.configuration.network
|
161
|
-
machine_type = Souls.configuration.machine_type
|
162
|
-
zone = Souls.configuration.zone
|
163
|
-
system(
|
164
|
-
"gcloud container clusters create #{app} \
|
165
|
-
--network #{network} \
|
166
|
-
--subnetwork #{sub_network} \
|
167
|
-
--zone #{zone} \
|
168
|
-
--scopes=https://www.googleapis.com/auth/cloud-platform \
|
169
|
-
--machine-type #{machine_type} \
|
170
|
-
--enable-autorepair \
|
171
|
-
--enable-ip-alias \
|
172
|
-
--num-nodes 2 \
|
173
|
-
--enable-autoscaling \
|
174
|
-
--min-nodes 1 \
|
175
|
-
--max-nodes 4 \
|
176
|
-
--tags=allow-health-checks"
|
177
|
-
)
|
178
|
-
end
|
179
|
-
|
180
|
-
def deploy
|
181
|
-
strain = Souls.configuration.strain
|
182
|
-
case strain
|
183
|
-
when "api"
|
184
|
-
Souls::Init.api_deploy
|
185
|
-
when "service"
|
186
|
-
Souls::Init.service_deploy
|
187
|
-
else
|
188
|
-
puts "coming soon..."
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
def update
|
193
|
-
`souls i apply_deployment`
|
194
|
-
end
|
195
|
-
|
196
|
-
def resize_cluster pool_name: "default-pool", node_num: 1
|
197
|
-
app = Souls.configuration.app
|
198
|
-
zone = Souls.configuration.zone
|
199
|
-
system "gcloud container clusters resize #{app} --node-pool #{pool_name} --num-nodes #{node_num} --zone #{zone}"
|
200
|
-
end
|
201
|
-
|
202
|
-
def create_namespace
|
203
|
-
namespace = Souls.configuration.namespace
|
204
|
-
system("kubectl create namespace #{namespace}")
|
205
|
-
end
|
206
|
-
|
207
|
-
def create_ip
|
208
|
-
ip_name = "#{Souls.configuration.app}-ip"
|
209
|
-
system("gcloud compute addresses create #{ip_name} --global")
|
210
|
-
end
|
211
|
-
|
212
|
-
def apply_deployment
|
213
|
-
namespace = Souls.configuration.namespace
|
214
|
-
system("kubectl apply -f ./infra/deployment.yml --namespace=#{namespace}")
|
215
|
-
end
|
216
|
-
|
217
|
-
def apply_secret
|
218
|
-
namespace = Souls.configuration.namespace
|
219
|
-
system("kubectl apply -f ./infra/secret.yml --namespace=#{namespace}")
|
220
|
-
end
|
221
|
-
|
222
|
-
def apply_service
|
223
|
-
namespace = Souls.configuration.namespace
|
224
|
-
system("kubectl apply -f ./infra/service.yml --namespace=#{namespace}")
|
225
|
-
end
|
226
|
-
|
227
|
-
def apply_ingress
|
228
|
-
namespace = Souls.configuration.namespace
|
229
|
-
system("kubectl apply -f ./infra/ingress.yml --namespace=#{namespace}")
|
230
|
-
end
|
231
|
-
|
232
|
-
def delete_deployment
|
233
|
-
namespace = Souls.configuration.namespace
|
234
|
-
system("kubectl delete -f ./infra/deployment.yml --namespace=#{namespace}")
|
235
|
-
end
|
236
|
-
|
237
|
-
def delete_secret
|
238
|
-
namespace = Souls.configuration.namespace
|
239
|
-
system("kubectl delete -f ./infra/secret.yml --namespace=#{namespace}")
|
240
|
-
end
|
241
|
-
|
242
|
-
def delete_service
|
243
|
-
namespace = Souls.configuration.namespace
|
244
|
-
system("kubectl delete -f ./infra/service.yml --namespace=#{namespace}")
|
245
|
-
end
|
246
|
-
|
247
|
-
def delete_ingress
|
248
|
-
namespace = Souls.configuration.namespace
|
249
|
-
system("kubectl delete -f ./infra/ingress.yml --namespace=#{namespace}")
|
250
|
-
end
|
251
|
-
|
252
|
-
def create_dns_conf
|
253
|
-
app = Souls.configuration.app
|
254
|
-
namespace = Souls.configuration.namespace
|
255
|
-
domain = Souls.configuration.domain
|
256
|
-
`echo "#{domain}. 300 IN A $(kubectl get ingress --namespace #{namespace} | grep #{app} | awk '{print $3}')" >> ./infra/dns_conf`
|
257
|
-
"created dns file!"
|
258
|
-
end
|
259
|
-
|
260
|
-
def set_dns
|
261
|
-
project_id = Souls.configuration.main_project_id
|
262
|
-
`gcloud dns record-sets import -z=#{project_id} --zone-file-format ./infra/dns_conf`
|
263
|
-
end
|
264
|
-
|
265
|
-
def service_api_enable
|
266
|
-
`gcloud services enable iam.googleapis.com`
|
267
|
-
`gcloud services enable dns.googleapis.com`
|
268
|
-
`gcloud services enable container.googleapis.com`
|
269
|
-
`gcloud services enable containerregistry.googleapis.com`
|
270
|
-
`gcloud services enable servicenetworking.googleapis.com`
|
271
|
-
`gcloud services enable sqladmin.googleapis.com`
|
272
|
-
`gcloud services enable sql-component.googleapis.com`
|
273
|
-
`gcloud services enable cloudbuild.googleapis.com`
|
274
|
-
end
|
275
|
-
|
276
|
-
def update_container zone: :asia
|
277
|
-
project_id = Souls.configuration.project_id
|
278
|
-
firestore = Google::Cloud::Firestore.new
|
279
|
-
strain = Souls.configuration.strain
|
280
|
-
app = Souls.configuration.app
|
281
|
-
container = case strain
|
282
|
-
when "api"
|
283
|
-
app
|
284
|
-
else
|
285
|
-
Souls.configuration.service_name
|
286
|
-
end
|
287
|
-
zones = {
|
288
|
-
us: "gcr.io",
|
289
|
-
eu: "eu.gcr.io",
|
290
|
-
asia: "asia.gcr.io"
|
291
|
-
}
|
292
|
-
versions = firestore.doc "containers/#{container}/versions/1"
|
293
|
-
if versions.get.exists?
|
294
|
-
versions = firestore.col("containers").doc(container).col("versions")
|
295
|
-
query = versions.order("version_counter", "desc").limit 1
|
296
|
-
query.get do |v|
|
297
|
-
@next_version = v.data[:version_counter] + 1
|
298
|
-
end
|
299
|
-
else
|
300
|
-
@next_version = 1
|
301
|
-
end
|
302
|
-
version = firestore.col("containers").doc(container).col("versions").doc @next_version
|
303
|
-
version.set version: "v#{@next_version}", version_counter: @next_version, zone: zones[zone], created_at: Time.now.utc
|
304
|
-
|
305
|
-
system("docker build . -t #{app}:v#{@next_version}")
|
306
|
-
system("docker tag #{app}:v#{@next_version} #{zones[zone]}/#{project_id}/#{app}:v#{@next_version}")
|
307
|
-
system("docker push #{zones[zone]}/#{project_id}/#{app}:v#{@next_version}")
|
308
|
-
end
|
309
|
-
|
310
|
-
def create_service_account
|
311
|
-
service_account = Souls.configuration.app
|
312
|
-
`gcloud iam service-accounts create #{service_account} \
|
313
|
-
--description="Souls Service Account" \
|
314
|
-
--display-name="#{service_account}"`
|
315
|
-
end
|
316
|
-
|
317
|
-
def create_service_account_key
|
318
|
-
project_id = Souls.configuration.project_id
|
319
|
-
service_account = Souls.configuration.app
|
320
|
-
`gcloud iam service-accounts keys create ./config/keyfile.json \
|
321
|
-
--iam-account #{service_account}@#{project_id}.iam.gserviceaccount.com`
|
322
|
-
end
|
323
|
-
|
324
|
-
def add_service_account_role role: "roles/firebase.admin"
|
325
|
-
project_id = Souls.configuration.project_id
|
326
|
-
service_account = Souls.configuration.app
|
327
|
-
`gcloud projects add-iam-policy-binding #{project_id} \
|
328
|
-
--member="serviceAccount:#{service_account}@#{project_id}.iam.gserviceaccount.com" \
|
329
|
-
--role="#{role}"`
|
330
|
-
end
|
331
|
-
|
332
|
-
def get_pods
|
333
|
-
namespace = Souls.configuration.namespace
|
334
|
-
system("kubectl get pods --namespace=#{namespace}")
|
335
|
-
end
|
336
|
-
|
337
|
-
def get_svc
|
338
|
-
namespace = Souls.configuration.namespace
|
339
|
-
system("kubectl get svc --namespace=#{namespace}")
|
340
|
-
end
|
341
|
-
|
342
|
-
def get_ingress
|
343
|
-
namespace = Souls.configuration.namespace
|
344
|
-
system("kubectl get ingress --namespace=#{namespace}")
|
345
|
-
end
|
346
|
-
|
347
|
-
def run
|
348
|
-
app = Souls.configuration.app
|
349
|
-
system("docker rm -f web")
|
350
|
-
system("docker build . -t #{app}:latest")
|
351
|
-
system("docker run --name web -it --env-file $PWD/.env -p 3000:3000 #{app}:latest")
|
352
|
-
end
|
353
|
-
|
354
|
-
def get_clusters
|
355
|
-
system("kubectl config get-clusters")
|
356
|
-
end
|
357
|
-
|
358
|
-
def get_current_cluster
|
359
|
-
system("kubectl config current-context")
|
360
|
-
end
|
361
|
-
|
362
|
-
def use_context cluster:
|
363
|
-
system("kubectl config use-context #{cluster}")
|
364
|
-
end
|
365
|
-
|
366
|
-
def get_credentials
|
367
|
-
app = Souls.configuration.app
|
368
|
-
zone = Souls.configuration.zone
|
369
|
-
system "gcloud container clusters get-credentials #{app} --zone #{zone}"
|
370
|
-
end
|
371
|
-
|
372
|
-
def create_ssl
|
373
|
-
app = Souls.configuration.app
|
374
|
-
domain = Souls.configuration.domain
|
375
|
-
system "gcloud compute ssl-certificates create #{app}-ssl --domains=#{domain} --global"
|
376
|
-
end
|
377
|
-
|
378
13
|
def run_psql
|
379
14
|
`docker run --rm -d \
|
380
15
|
-p 5433:5432 \
|
@@ -434,21 +69,10 @@ module Souls
|
|
434
69
|
end
|
435
70
|
|
436
71
|
class Configuration
|
437
|
-
attr_accessor :
|
72
|
+
attr_accessor :app
|
438
73
|
|
439
74
|
def initialize
|
440
|
-
@main_project_id = nil
|
441
|
-
@project_id = nil
|
442
75
|
@app = nil
|
443
|
-
@network = nil
|
444
|
-
@namespace = nil
|
445
|
-
@service_name = nil
|
446
|
-
@machine_type = nil
|
447
|
-
@zone = nil
|
448
|
-
@domain = nil
|
449
|
-
@google_application_credentials = nil
|
450
|
-
@strain = nil
|
451
|
-
@proto_package_name = nil
|
452
76
|
end
|
453
77
|
end
|
454
78
|
end
|
data/lib/souls/init.rb
CHANGED
@@ -1,103 +1,6 @@
|
|
1
1
|
module Souls
|
2
|
-
STRAINS = ["graph", "api", "service", "media", "admin"]
|
3
2
|
module Init
|
4
3
|
class << self
|
5
|
-
def create_souls strain: 1, app_name: "souls"
|
6
|
-
config_needed = (1..3)
|
7
|
-
project = {}
|
8
|
-
project[:strain] = STRAINS[strain.to_i - 1]
|
9
|
-
begin
|
10
|
-
puts "Google Cloud Main PROJECT_ID(This project will controll Cloud DNS): (default: elsoul2)"
|
11
|
-
project[:main_project_id] = STDIN.gets.chomp
|
12
|
-
project[:main_project_id] == "" ? project[:main_project_id] = "elsoul2" : true
|
13
|
-
puts "Google Cloud PROJECT_ID: (default: elsoul2)"
|
14
|
-
project[:project_id] = STDIN.gets.chomp
|
15
|
-
project[:project_id] = "elsoul2" if project[:project_id] == ""
|
16
|
-
puts "VPC Network Name: (default: default)"
|
17
|
-
project[:network] = STDIN.gets.chomp
|
18
|
-
project[:network] == "" ? project[:network] = "default" : true
|
19
|
-
puts "Namespace: (default: souls)"
|
20
|
-
project[:namespace] = STDIN.gets.chomp
|
21
|
-
project[:namespace] == "" ? project[:namespace] = "souls" : true
|
22
|
-
if project[:strain] == "service"
|
23
|
-
puts "Service Name: (default: blog-service)"
|
24
|
-
project[:service_name] = STDIN.gets.chomp
|
25
|
-
project[:service_name] == "" ? project[:service_name] = "blog-service" : true
|
26
|
-
end
|
27
|
-
puts "Instance MachineType: (default: custom-1-6656)"
|
28
|
-
project[:machine_type] = STDIN.gets.chomp
|
29
|
-
project[:machine_type] == "" ? project[:machine_type] = "custom-1-6656" : true
|
30
|
-
puts "Zone: (default: us-central1-a)"
|
31
|
-
project[:zone] = STDIN.gets.chomp
|
32
|
-
project[:zone] == "" ? project[:zone] = "us-central1-a" : true
|
33
|
-
puts "Domain: (e.g API: el-soul.com, Serive: xds:///blog-service:8000)"
|
34
|
-
project[:domain] = STDIN.gets.chomp
|
35
|
-
project[:domain] == "" ? project[:domain] = "el-soul.com" : true
|
36
|
-
puts "Google Application Credentials Path: (default: #{app_name}/config/credentials.json)"
|
37
|
-
project[:google_application_credentials] = STDIN.gets.chomp
|
38
|
-
project[:google_application_credentials] == "" ? project[:google_application_credentials] = "./config/credentials.json" : true
|
39
|
-
puts project
|
40
|
-
puts "Enter to finish set up!"
|
41
|
-
confirm = STDIN.gets.chomp
|
42
|
-
raise StandardError, "Retry" unless confirm == ""
|
43
|
-
download_souls app_name: app_name, repository_name: "souls_#{STRAINS[strain.to_i - 1]}"
|
44
|
-
initial_config_init app_name: app_name, project: project if config_needed.include?(strain)
|
45
|
-
rescue StandardError => error
|
46
|
-
puts error
|
47
|
-
retry
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def initial_config_init app_name: "souls", project: {}
|
52
|
-
`touch "#{app_name}/config/initializers/souls.rb"`
|
53
|
-
file_path = "#{app_name}/config/initializers/souls.rb"
|
54
|
-
File.open(file_path, "w") do |f|
|
55
|
-
f.write <<~EOS
|
56
|
-
Souls.configure do |config|
|
57
|
-
config.main_project_id = "#{project[:main_project_id]}"
|
58
|
-
config.project_id = "#{project[:project_id]}"
|
59
|
-
config.app = "#{app_name}"
|
60
|
-
config.namespace = "#{project[:namespace]}"
|
61
|
-
config.service_name = "#{project[:service_name]}"
|
62
|
-
config.network = "#{project[:network]}"
|
63
|
-
config.machine_type = "#{project[:machine_type]}"
|
64
|
-
config.zone = "#{project[:zone]}"
|
65
|
-
config.domain = "#{project[:domain]}"
|
66
|
-
config.google_application_credentials = "#{project[:google_application_credentials]}"
|
67
|
-
config.strain = "#{project[:strain]}"
|
68
|
-
config.proto_package_name = "souls"
|
69
|
-
end
|
70
|
-
EOS
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def config_init app_name: "souls", project: {}
|
75
|
-
`touch ./config/initializers/souls.rb`
|
76
|
-
file_path = "./config/initializers/souls.rb"
|
77
|
-
puts "Generating souls conf..."
|
78
|
-
sleep(rand(0.1..0.3))
|
79
|
-
puts "Generated!"
|
80
|
-
puts "Let's Edit SOULs Conf: `#{file_path}`"
|
81
|
-
File.open(file_path, "w") do |f|
|
82
|
-
f.write <<~EOS
|
83
|
-
Souls.configure do |config|
|
84
|
-
config.main_project_id = "#{project[:main_project_id]}"
|
85
|
-
config.project_id = "#{project[:project_id]}"
|
86
|
-
config.app = "#{app_name}"
|
87
|
-
config.namespace = "#{project[:namespace]}"
|
88
|
-
config.service_name = "#{project[:service_name]}"
|
89
|
-
config.network = "#{project[:network]}"
|
90
|
-
config.machine_type = "#{project[:machine_type]}"
|
91
|
-
config.zone = "#{project[:zone]}"
|
92
|
-
config.domain = "#{project[:domain]}"
|
93
|
-
config.google_application_credentials = "#{project[:google_application_credentials]}"
|
94
|
-
config.strain = "#{project[:strain]}"
|
95
|
-
config.proto_package_name = "souls"
|
96
|
-
end
|
97
|
-
EOS
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
4
|
def get_version repository_name: "souls_service"
|
102
5
|
data = JSON.parse `curl \
|
103
6
|
-H "Accept: application/vnd.github.v3+json" \
|
@@ -129,119 +32,6 @@ module Souls
|
|
129
32
|
puts "------------------------------"
|
130
33
|
end
|
131
34
|
|
132
|
-
def proto proto_package_name: "souls", service: "blog"
|
133
|
-
system "grpc_tools_ruby_protoc -I ./protos --ruby_out=./app/services --grpc_out=./app/services ./protos/#{service}.proto"
|
134
|
-
service_pb_path = "./app/services/#{service}_services_pb.rb"
|
135
|
-
new_file = "./app/services/#{proto_package_name}.rb"
|
136
|
-
File.open(new_file, "w") do |new_line|
|
137
|
-
File.open(service_pb_path, "r") do |f|
|
138
|
-
f.each_line.with_index do |line, i|
|
139
|
-
case i
|
140
|
-
when 0
|
141
|
-
new_line.write "# Generated by the SOULs protocol buffer compiler. DO NOT EDIT!\n"
|
142
|
-
when 3
|
143
|
-
next
|
144
|
-
else
|
145
|
-
puts "#{i}: #{line}"
|
146
|
-
new_line.write line.to_s
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
FileUtils.rm service_pb_path
|
152
|
-
puts "SOULs Proto Created!"
|
153
|
-
end
|
154
|
-
|
155
|
-
def service_deploy
|
156
|
-
service_name = Souls.configuration.service_name
|
157
|
-
health_check_name = "#{service_name}-hc"
|
158
|
-
firewall_rule_name = "#{service_name}-allow-health-checks"
|
159
|
-
zone = Souls.configuration.zone
|
160
|
-
url_map_name = "#{service_name}-url-map"
|
161
|
-
path_matcher_name = "#{service_name}-path-mathcher"
|
162
|
-
port = "5000"
|
163
|
-
proxy_name = "#{service_name}-proxy"
|
164
|
-
forwarding_rule_name = "#{service_name}-forwarding-rule"
|
165
|
-
|
166
|
-
Souls.create_service_account
|
167
|
-
Souls.create_service_account_key
|
168
|
-
Souls.add_service_account_role
|
169
|
-
Souls.add_service_account_role role: "roles/containerregistry.ServiceAgent"
|
170
|
-
Souls.create_health_check health_check_name: health_check_name
|
171
|
-
Souls.create_firewall_rule firewall_rule_name: firewall_rule_name
|
172
|
-
Souls.create_backend_service service_name: service_name, health_check_name: health_check_name
|
173
|
-
Souls.export_network_group
|
174
|
-
file_path = "./config/neg_name"
|
175
|
-
File.open(file_path) do |f|
|
176
|
-
Souls.add_backend_service service_name: service_name, neg_name: f.gets.to_s, zone: zone
|
177
|
-
end
|
178
|
-
Souls.create_url_map url_map_name: url_map_name, service_name: service_name
|
179
|
-
Souls.create_path_matcher url_map_name: url_map_name, service_name: service_name, path_matcher_name: path_matcher_name, hostname: app, port: port
|
180
|
-
Souls.create_target_grpc_proxy proxy_name: proxy_name, url_map_name: url_map_name
|
181
|
-
Souls.create_forwarding_rule forwarding_rule_name: forwarding_rule_name, proxy_name: proxy_name, port: port
|
182
|
-
end
|
183
|
-
|
184
|
-
def api_deploy
|
185
|
-
Souls.service_api_enable
|
186
|
-
Souls.create_service_account
|
187
|
-
Souls.create_service_account_key
|
188
|
-
Souls.add_service_account_role
|
189
|
-
Souls.add_service_account_role role: "roles/containerregistry.ServiceAgent"
|
190
|
-
Souls.config_set
|
191
|
-
Souls.create_network
|
192
|
-
Souls.create_cluster
|
193
|
-
Souls.get_credentials
|
194
|
-
Souls.create_namespace
|
195
|
-
Souls.create_ip
|
196
|
-
Souls.create_ssl
|
197
|
-
Souls.apply_deployment
|
198
|
-
Souls.apply_service
|
199
|
-
Souls.apply_ingress
|
200
|
-
puts "Wainting for Ingress to get IP..."
|
201
|
-
sleep 1
|
202
|
-
puts "This migth take a few mins..."
|
203
|
-
sleep 90
|
204
|
-
Souls.create_dns_conf
|
205
|
-
Souls.config_set_main
|
206
|
-
Souls.set_dns
|
207
|
-
Souls.config_set
|
208
|
-
end
|
209
|
-
|
210
|
-
def local_deploy
|
211
|
-
`souls i run_psql`
|
212
|
-
`docker pull`
|
213
|
-
end
|
214
|
-
|
215
|
-
def service_update
|
216
|
-
`souls i apply_deployment`
|
217
|
-
end
|
218
|
-
|
219
|
-
def api_update
|
220
|
-
`souls i apply_deployment`
|
221
|
-
end
|
222
|
-
|
223
|
-
def service_delete
|
224
|
-
service_name = Souls.configuration.service_name
|
225
|
-
firewall_rule_name = "#{service_name}-allow-health-checks"
|
226
|
-
url_map_name = "#{service_name}-url-map"
|
227
|
-
proxy_name = "#{service_name}-proxy"
|
228
|
-
forwarding_rule_name = "#{service_name}-forwarding-rule"
|
229
|
-
|
230
|
-
Souls.delete_forwarding_rule forwarding_rule_name: forwarding_rule_name
|
231
|
-
Souls.delete_target_grpc_proxy proxy_name: proxy_name
|
232
|
-
Souls.delete_url_map url_map_name: url_map_name
|
233
|
-
Souls.delete_backend_service service_name: service_name
|
234
|
-
Souls.delete_health_check health_check_name: health_check_name
|
235
|
-
Souls.delete_firewall_rule firewall_rule_name: firewall_rule_name
|
236
|
-
end
|
237
|
-
|
238
|
-
def api_delete
|
239
|
-
`souls i delete_deployment`
|
240
|
-
`souls i delete_secret`
|
241
|
-
`souls i delete_service`
|
242
|
-
`souls i delete_ingress`
|
243
|
-
end
|
244
|
-
|
245
35
|
def model class_name: "souls"
|
246
36
|
file_path = "./app/models/#{class_name.singularize}.rb"
|
247
37
|
return ["Model already exist! #{file_path}"] if File.exist? file_path
|
data/lib/souls/version.rb
CHANGED
data/souls.gemspec
CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = "souls"
|
5
5
|
spec.version = Souls::VERSION
|
6
6
|
spec.authors = ["POPPIN-FUMI", "KishiTheMechanic", "James Neve"]
|
7
|
-
spec.email = ["
|
7
|
+
spec.email = ["f.kawasaki@elsoul.nl", "s.kishi@elsoul.nl", "jamesoneve@gmail.com"]
|
8
8
|
|
9
9
|
spec.summary = "SOULS is a GraphQL Based Web Application Framework for Microservices on Multi Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud. Auto deploy with scalable condition. You can focus on business logic. No more infra problems."
|
10
10
|
spec.description = "SOULS is a Web Application Framework for Microservices on Multi Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud. Auto deploy with scalable condition. You can focus on business logic. No more infra problems."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: souls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
@@ -10,15 +10,15 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-04-
|
13
|
+
date: 2021-04-07 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: SOULS is a Web Application Framework for Microservices on Multi Cloud
|
16
16
|
Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud.
|
17
17
|
Auto deploy with scalable condition. You can focus on business logic. No more infra
|
18
18
|
problems.
|
19
19
|
email:
|
20
|
-
-
|
21
|
-
-
|
20
|
+
- f.kawasaki@elsoul.nl
|
21
|
+
- s.kishi@elsoul.nl
|
22
22
|
- jamesoneve@gmail.com
|
23
23
|
executables:
|
24
24
|
- souls
|