pfab 0.12.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +6 -2
- data/lib/pfab/cli.rb +22 -16
- data/lib/pfab/templates/web.rb +38 -8
- data/lib/pfab/version.rb +1 -1
- data/lib/pfab/yamls.rb +5 -5
- data/pfab.gemspec +3 -4
- metadata +2 -3
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9b74403a3e35834fc91e161a00965bd13444cd6dc5f4189947e7a5e92168a29
|
4
|
+
data.tar.gz: fbac3572c2f5b0f59b20195fcdd77657b511f6af95d430fc8d71c23e7a079748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01031a7a713ec836556fc3351c92955d46e67a6ed5dbdc73281fdb96b16d6aaa368a34b9fc61590d0f0aaa1cfcf13393e743b98a8cfc72c415f364b0f1e9f6ee
|
7
|
+
data.tar.gz: cc337ac58b41e94928356bfa846099f29546966da829799dd07d1661da308ca12e606b2ccfef2d9ebb6bfd8cfb98ecd96e65a37e5cf8ef77b0b7a3c49d714e7e
|
data/README.markdown
CHANGED
@@ -40,6 +40,7 @@ deployables:
|
|
40
40
|
type: web
|
41
41
|
port: 8443
|
42
42
|
protocol: h2c # tell traefik this is going to be http2
|
43
|
+
tls_cert_secret: my-tls-secret
|
43
44
|
command: java -Xmx550m -javaagent:/app/dd-java-agent.jar -jar myjar.jar server /app/grpc.yml
|
44
45
|
readinessProbe:
|
45
46
|
exec:
|
@@ -114,8 +115,11 @@ Releasing
|
|
114
115
|
-----------------------------------------
|
115
116
|
|
116
117
|
- modify version.rb
|
117
|
-
- ```rake gemspec
|
118
|
-
- ```
|
118
|
+
- ```bundle exec rake gemspec```
|
119
|
+
- ```git commit ```
|
120
|
+
- ```bundle exec rake git:release```
|
121
|
+
- ```bundle exec rake build```
|
122
|
+
- ```gem push pkg/pfab-0.15.0.gem```
|
119
123
|
|
120
124
|
Copyright
|
121
125
|
---------
|
data/lib/pfab/cli.rb
CHANGED
@@ -27,8 +27,6 @@ module Pfab
|
|
27
27
|
$app_name = app_name
|
28
28
|
end
|
29
29
|
|
30
|
-
@apps = apps
|
31
|
-
|
32
30
|
command :build do |c|
|
33
31
|
c.syntax = "pfab build"
|
34
32
|
c.summary = "build image"
|
@@ -142,14 +140,14 @@ module Pfab
|
|
142
140
|
c.option "-c", "--command COMMAND", "Run a command with the ENV vars of the selected app"
|
143
141
|
c.action do |_args, options|
|
144
142
|
$env = :development
|
145
|
-
app_name = get_app_name
|
143
|
+
app_name = get_app_name(include_run_locals: true)
|
146
144
|
puts "RUNNING THE FOLLOWING LOCALLY"
|
147
145
|
|
148
146
|
env_vars = yy.env_vars(app_name).
|
149
147
|
reject { |v| v.has_key? :valueFrom }
|
150
148
|
|
151
149
|
env_var_string = env_vars.map { |item| "#{item[:name]}=\"#{item[:value]}\"" }.join(" ")
|
152
|
-
options.default command:
|
150
|
+
options.default command: all_runnables[app_name][:command]
|
153
151
|
|
154
152
|
puts_and_system "#{env_var_string} #{options.command}"
|
155
153
|
end
|
@@ -182,11 +180,10 @@ module Pfab
|
|
182
180
|
run!
|
183
181
|
end
|
184
182
|
|
185
|
-
|
186
183
|
def cmd_apply
|
187
184
|
set_kube_context
|
188
185
|
get_apps.each do |app_name|
|
189
|
-
app =
|
186
|
+
app = deployables[app_name]
|
190
187
|
if app[:deployable_type] == "cron"
|
191
188
|
deployed_name = deployed_name(app)
|
192
189
|
puts_and_system("kubectl delete cronjob -l deployed-name=#{deployed_name}")
|
@@ -237,7 +234,7 @@ module Pfab
|
|
237
234
|
end
|
238
235
|
end
|
239
236
|
|
240
|
-
puts_and_system "docker build -t #{image_name} ."
|
237
|
+
puts_and_system "docker build -t #{image_name} --platform amd64 ."
|
241
238
|
|
242
239
|
puts_and_system "docker tag #{image_name}:latest #{image_name}:#{rev}"
|
243
240
|
puts_and_system "docker tag #{image_name}:#{rev} #{full_image_name}"
|
@@ -247,7 +244,7 @@ module Pfab
|
|
247
244
|
end
|
248
245
|
|
249
246
|
def yy
|
250
|
-
Pfab::Yamls.new(apps:
|
247
|
+
Pfab::Yamls.new(apps: all_runnables,
|
251
248
|
application_yaml: @application_yaml,
|
252
249
|
env: $env,
|
253
250
|
sha: get_current_sha,
|
@@ -257,7 +254,7 @@ module Pfab
|
|
257
254
|
end
|
258
255
|
|
259
256
|
def cmd_generate_yaml
|
260
|
-
wrote = yy.
|
257
|
+
wrote = yy.generate(deployables.keys)
|
261
258
|
puts "Generated #{wrote}"
|
262
259
|
end
|
263
260
|
|
@@ -295,14 +292,22 @@ module Pfab
|
|
295
292
|
end
|
296
293
|
end
|
297
294
|
|
298
|
-
def
|
299
|
-
@
|
295
|
+
def deployables
|
296
|
+
@_deployables ||= calculate_runnables("deployables")
|
297
|
+
end
|
298
|
+
|
299
|
+
def run_locals
|
300
|
+
@_rl ||= calculate_runnables("run_locals")
|
301
|
+
end
|
302
|
+
|
303
|
+
def all_runnables
|
304
|
+
deployables.merge(run_locals)
|
300
305
|
end
|
301
306
|
|
302
|
-
def
|
307
|
+
def calculate_runnables(runnable_type)
|
303
308
|
application = @application_yaml["name"]
|
304
309
|
apps = {}
|
305
|
-
@application_yaml[
|
310
|
+
(@application_yaml[runnable_type] || []).each do |deployable, dep|
|
306
311
|
deployable_type = dep["type"]
|
307
312
|
app_name = [application, deployable_type, deployable].join("-")
|
308
313
|
apps[app_name] = {
|
@@ -329,16 +334,17 @@ module Pfab
|
|
329
334
|
JSON.parse(pods_str)
|
330
335
|
end
|
331
336
|
|
332
|
-
def get_app_name(all: false)
|
337
|
+
def get_app_name(all: false, include_run_locals: false)
|
333
338
|
return $app_name unless $app_name.nil?
|
334
|
-
apps =
|
339
|
+
apps = deployables.keys
|
340
|
+
apps.concat(run_locals.keys) if include_run_locals
|
335
341
|
apps << "all" if all
|
336
342
|
$app_name = choose("which app?", *apps)
|
337
343
|
end
|
338
344
|
|
339
345
|
def get_apps
|
340
346
|
name = get_app_name(all: true)
|
341
|
-
(name == "all") ?
|
347
|
+
(name == "all") ? deployables.keys : [name]
|
342
348
|
end
|
343
349
|
end
|
344
350
|
end
|
data/lib/pfab/templates/web.rb
CHANGED
@@ -2,9 +2,13 @@ module Pfab
|
|
2
2
|
module Templates
|
3
3
|
class Web < Base
|
4
4
|
def write_to(f)
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
if get("host").nil?
|
6
|
+
puts "No host to deploy to for #{@data['deployed_name']}. Skipping."
|
7
|
+
else
|
8
|
+
f << YAML.dump(service.deep_stringify_keys)
|
9
|
+
f << YAML.dump(ingress.deep_stringify_keys)
|
10
|
+
f << YAML.dump(deployment.deep_stringify_keys)
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
def service
|
@@ -17,7 +21,8 @@ module Pfab
|
|
17
21
|
labels: {
|
18
22
|
application: @data['application'],
|
19
23
|
"deployed-name" => @data['deployed_name'],
|
20
|
-
}
|
24
|
+
},
|
25
|
+
annotations: service_annotations,
|
21
26
|
},
|
22
27
|
spec: {
|
23
28
|
selector: {
|
@@ -34,6 +39,12 @@ module Pfab
|
|
34
39
|
}
|
35
40
|
end
|
36
41
|
|
42
|
+
def service_annotations
|
43
|
+
h = {}
|
44
|
+
h["traefik.ingress.kubernetes.io/service.serversscheme"] = "h2c" if get("protocol") == "h2c"
|
45
|
+
h
|
46
|
+
end
|
47
|
+
|
37
48
|
def ingress
|
38
49
|
{
|
39
50
|
apiVersion: "networking.k8s.io/v1",
|
@@ -49,12 +60,25 @@ module Pfab
|
|
49
60
|
},
|
50
61
|
spec: {
|
51
62
|
rules: rules,
|
63
|
+
tls: tls_hosts
|
52
64
|
},
|
53
65
|
}
|
54
66
|
end
|
55
67
|
|
68
|
+
def tls_hosts
|
69
|
+
hosts.map do |host|
|
70
|
+
{
|
71
|
+
hosts: [host],
|
72
|
+
secretName: get("tls_cert_secret")
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def hosts
|
78
|
+
get("host").split(",")
|
79
|
+
end
|
80
|
+
|
56
81
|
def rules
|
57
|
-
hosts = get("host").split(",")
|
58
82
|
hosts.map do |host|
|
59
83
|
{
|
60
84
|
host: host,
|
@@ -62,9 +86,14 @@ module Pfab
|
|
62
86
|
paths: [
|
63
87
|
{
|
64
88
|
path: "/",
|
89
|
+
pathType: "Prefix",
|
65
90
|
backend: {
|
66
|
-
|
67
|
-
|
91
|
+
service: {
|
92
|
+
name: @data['deployed_name'],
|
93
|
+
port: {
|
94
|
+
name: "http"
|
95
|
+
}
|
96
|
+
}
|
68
97
|
},
|
69
98
|
},
|
70
99
|
],
|
@@ -82,8 +111,9 @@ module Pfab
|
|
82
111
|
"traefik.protocol" => get("protocol") || "http",
|
83
112
|
"traefik.frontend.headers.SSLRedirect" => "true",
|
84
113
|
"traefik.docker.network" => "traefik",
|
114
|
+
"traefik.ingress.kubernetes.io/router.entrypoints" => "websecure",
|
115
|
+
"traefik.ingress.kubernetes.io/router.tls" => "true"
|
85
116
|
}
|
86
|
-
h["ingress.kubernetes.io/protocol"] = "h2c" if get("protocol") == "h2c"
|
87
117
|
h
|
88
118
|
end
|
89
119
|
|
data/lib/pfab/version.rb
CHANGED
data/lib/pfab/yamls.rb
CHANGED
@@ -27,13 +27,13 @@ module Pfab
|
|
27
27
|
data
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def generate(keys)
|
31
31
|
|
32
|
-
|
32
|
+
keys.each do |key|
|
33
|
+
props = @apps[key]
|
34
|
+
data = data_for(key, props)
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
filename = ".application-k8s-#{data["env"]}-#{app}.yaml"
|
36
|
+
filename = ".application-k8s-#{data["env"]}-#{key}.yaml"
|
37
37
|
File.open(filename, "w") do |f|
|
38
38
|
case props[:deployable_type]
|
39
39
|
when "web" then
|
data/pfab.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: pfab 0.
|
5
|
+
# stub: pfab 0.16.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "pfab".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.16.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Jeff Dwyer".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2022-01-18"
|
15
15
|
s.description = "k8s helper".freeze
|
16
16
|
s.email = "jdwyer@prefab.cloud".freeze
|
17
17
|
s.executables = ["pfab".freeze]
|
@@ -21,7 +21,6 @@ Gem::Specification.new do |s|
|
|
21
21
|
]
|
22
22
|
s.files = [
|
23
23
|
".document",
|
24
|
-
".ruby-version",
|
25
24
|
".tool-versions",
|
26
25
|
"Gemfile",
|
27
26
|
"Gemfile.lock",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pfab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Dwyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -132,7 +132,6 @@ extra_rdoc_files:
|
|
132
132
|
- README.markdown
|
133
133
|
files:
|
134
134
|
- ".document"
|
135
|
-
- ".ruby-version"
|
136
135
|
- ".tool-versions"
|
137
136
|
- Gemfile
|
138
137
|
- Gemfile.lock
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.5.3
|