pfab 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/README.markdown +3 -3
- data/lib/pfab/cli.rb +16 -57
- data/lib/pfab/templates/base.rb +1 -26
- data/lib/pfab/templates/cron.rb +5 -16
- data/lib/pfab/templates/daemon.rb +4 -16
- data/lib/pfab/templates/job.rb +4 -16
- data/lib/pfab/templates/web.rb +12 -83
- data/lib/pfab/version.rb +1 -1
- data/pfab.gemspec +4 -5
- metadata +1 -2
- data/CODEOWNERS +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ae7b00c6d13d8b45b8366942aff2a3afacc421e798a715bde6acb2455623a1b2
|
|
4
|
+
data.tar.gz: c94e58d362a8c6f3f6da51dd183b32da9474278eb6aaaf8e8ba2d35c2aab346e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '092d1680e87f567c670d566dcebaa029a4c2b30fd841695a4d0bd6a2da0b542f8aa5f41208e70116c374a90a359276f2df0a4bdac511ec28c490ac4ac040538a'
|
|
7
|
+
data.tar.gz: ef414f2881c18685adef089dfdfd0a61937941ff3945338b74d3025f1f48a77203ca5545df80fa8fdb4bb4f0a2ca9722929c0a3ae780f770d9cb83ee418abd9a
|
data/Gemfile.lock
CHANGED
|
@@ -18,7 +18,7 @@ GIT
|
|
|
18
18
|
GEM
|
|
19
19
|
remote: https://rubygems.org/
|
|
20
20
|
specs:
|
|
21
|
-
activesupport (5.2.
|
|
21
|
+
activesupport (5.2.2)
|
|
22
22
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
23
23
|
i18n (>= 0.7, < 2)
|
|
24
24
|
minitest (~> 5.1)
|
|
@@ -30,7 +30,7 @@ GEM
|
|
|
30
30
|
coderay (1.1.2)
|
|
31
31
|
commander (4.4.6)
|
|
32
32
|
highline (~> 1.7.2)
|
|
33
|
-
concurrent-ruby (1.1.
|
|
33
|
+
concurrent-ruby (1.1.4)
|
|
34
34
|
descendants_tracker (0.0.4)
|
|
35
35
|
thread_safe (~> 0.3, >= 0.3.1)
|
|
36
36
|
docile (1.3.1)
|
|
@@ -53,7 +53,7 @@ GEM
|
|
|
53
53
|
faraday-net_http_persistent (1.2.0)
|
|
54
54
|
faraday-patron (1.0.0)
|
|
55
55
|
faraday-rack (1.0.0)
|
|
56
|
-
git (1.
|
|
56
|
+
git (1.9.1)
|
|
57
57
|
rchardet (~> 1.8)
|
|
58
58
|
github_api (0.19.0)
|
|
59
59
|
addressable (~> 2.4)
|
|
@@ -63,19 +63,19 @@ GEM
|
|
|
63
63
|
oauth2 (~> 1.0)
|
|
64
64
|
hashie (3.6.0)
|
|
65
65
|
highline (1.7.10)
|
|
66
|
-
i18n (1.
|
|
66
|
+
i18n (1.2.0)
|
|
67
67
|
concurrent-ruby (~> 1.0)
|
|
68
68
|
json (1.8.6)
|
|
69
69
|
jwt (2.3.0)
|
|
70
70
|
kamelcase (0.0.2)
|
|
71
71
|
semver2 (~> 3)
|
|
72
72
|
method_source (0.9.2)
|
|
73
|
-
mini_portile2 (2.8.
|
|
74
|
-
minitest (5.
|
|
73
|
+
mini_portile2 (2.8.1)
|
|
74
|
+
minitest (5.11.3)
|
|
75
75
|
multi_json (1.15.0)
|
|
76
76
|
multi_xml (0.6.0)
|
|
77
77
|
multipart-post (2.1.1)
|
|
78
|
-
nokogiri (1.
|
|
78
|
+
nokogiri (1.14.2)
|
|
79
79
|
mini_portile2 (~> 2.8.0)
|
|
80
80
|
racc (~> 1.4)
|
|
81
81
|
oauth2 (1.4.7)
|
|
@@ -93,7 +93,7 @@ GEM
|
|
|
93
93
|
pry (~> 0.10)
|
|
94
94
|
psych (4.0.2)
|
|
95
95
|
public_suffix (4.0.6)
|
|
96
|
-
racc (1.6.
|
|
96
|
+
racc (1.6.2)
|
|
97
97
|
rack (2.2.3)
|
|
98
98
|
rake (13.0.6)
|
|
99
99
|
rchardet (1.8.0)
|
|
@@ -109,7 +109,7 @@ GEM
|
|
|
109
109
|
test-unit (3.2.9)
|
|
110
110
|
power_assert
|
|
111
111
|
thread_safe (0.3.6)
|
|
112
|
-
tzinfo (1.2.
|
|
112
|
+
tzinfo (1.2.5)
|
|
113
113
|
thread_safe (~> 0.1)
|
|
114
114
|
|
|
115
115
|
PLATFORMS
|
|
@@ -126,4 +126,4 @@ DEPENDENCIES
|
|
|
126
126
|
test-unit
|
|
127
127
|
|
|
128
128
|
BUNDLED WITH
|
|
129
|
-
|
|
129
|
+
1.17.2
|
data/README.markdown
CHANGED
|
@@ -117,9 +117,9 @@ Releasing
|
|
|
117
117
|
- modify version.rb
|
|
118
118
|
- ```bundle exec rake gemspec```
|
|
119
119
|
- ```git commit ```
|
|
120
|
-
- ```
|
|
121
|
-
- ```
|
|
122
|
-
- ```gem push pkg/pfab-0.
|
|
120
|
+
- ```bundle exec rake git:release```
|
|
121
|
+
- ```bundle exec rake build```
|
|
122
|
+
- ```gem push pkg/pfab-0.12.0.gem```
|
|
123
123
|
|
|
124
124
|
Copyright
|
|
125
125
|
---------
|
data/lib/pfab/cli.rb
CHANGED
|
@@ -22,14 +22,7 @@ module Pfab
|
|
|
22
22
|
$dryrun = false
|
|
23
23
|
global_option("--dryrun") { $dryrun = true }
|
|
24
24
|
$env = :staging
|
|
25
|
-
global_option("-p")
|
|
26
|
-
puts "please use `-e production` next time!"
|
|
27
|
-
$env = :production
|
|
28
|
-
end
|
|
29
|
-
global_option("-e", "--environment ENV", "specify target env") do |env_name|
|
|
30
|
-
puts "Using environment #{env_name}"
|
|
31
|
-
$env = env_name
|
|
32
|
-
end
|
|
25
|
+
global_option("-p") { $env = :production }
|
|
33
26
|
global_option("-a", "--application_name APP_NAME", "run without prompting for app") do |app_name|
|
|
34
27
|
$app_name = app_name
|
|
35
28
|
end
|
|
@@ -38,9 +31,8 @@ module Pfab
|
|
|
38
31
|
c.syntax = "pfab build"
|
|
39
32
|
c.summary = "build image"
|
|
40
33
|
c.option "--force", "force build and push"
|
|
41
|
-
c.option "--check", "just check if built"
|
|
42
34
|
c.action do |_args, options|
|
|
43
|
-
cmd_build(force: options.force
|
|
35
|
+
cmd_build(force: options.force)
|
|
44
36
|
end
|
|
45
37
|
end
|
|
46
38
|
|
|
@@ -91,18 +83,6 @@ module Pfab
|
|
|
91
83
|
end
|
|
92
84
|
end
|
|
93
85
|
|
|
94
|
-
command :restart do |c|
|
|
95
|
-
c.syntax = "pfab restart"
|
|
96
|
-
c.summary = "rolling restart of a deployment"
|
|
97
|
-
c.description = "rolling restart of a deployment"
|
|
98
|
-
c.action do
|
|
99
|
-
set_kube_context
|
|
100
|
-
app_name = get_app_name
|
|
101
|
-
|
|
102
|
-
puts_and_system "kubectl rollout restart deployment.apps/#{app_name}"
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
86
|
command :exec do |c|
|
|
107
87
|
c.syntax = "pfab exec"
|
|
108
88
|
c.summary = "kubectl exec into a pod"
|
|
@@ -210,20 +190,10 @@ module Pfab
|
|
|
210
190
|
end
|
|
211
191
|
puts_and_system("kubectl apply -f .application-k8s-#{$env}-#{app_name}.yaml")
|
|
212
192
|
puts_and_system("git tag release-#{$env}-#{app_name}-#{Time.now.strftime("%Y-%m-%d-%H-%M-%S")} HEAD")
|
|
213
|
-
puts_and_system("git push origin --tags")
|
|
214
193
|
end
|
|
215
194
|
end
|
|
216
195
|
|
|
217
|
-
def
|
|
218
|
-
|
|
219
|
-
# return 0 if image exists 1 if not
|
|
220
|
-
cmd = "docker manifest inspect #{full_image_name} > /dev/null ; echo $?"
|
|
221
|
-
say "Looking for images with #{cmd}"
|
|
222
|
-
existing = `#{cmd}`.strip
|
|
223
|
-
existing == "0"
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
def cmd_build(force: false, checkonly: false)
|
|
196
|
+
def cmd_build(force: false)
|
|
227
197
|
rev = get_current_sha
|
|
228
198
|
say "This repo is at rev: #{rev}"
|
|
229
199
|
uncommitted_changes = !`git diff-index HEAD --`.empty?
|
|
@@ -239,14 +209,13 @@ module Pfab
|
|
|
239
209
|
|
|
240
210
|
full_image_name = "#{container_repository}/#{image_name}:#{rev}"
|
|
241
211
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return if checkonly
|
|
212
|
+
cmd = "docker images -q #{full_image_name}"
|
|
213
|
+
say "Looking for images with #{cmd}"
|
|
214
|
+
existing = `#{cmd}`
|
|
215
|
+
|
|
216
|
+
if !existing.to_s.empty? && !force
|
|
217
|
+
say "Found image #{full_image_name} already, skipping prebuild, build & push"
|
|
218
|
+
return true
|
|
250
219
|
end
|
|
251
220
|
|
|
252
221
|
say "No image #{full_image_name} present, building"
|
|
@@ -265,23 +234,13 @@ module Pfab
|
|
|
265
234
|
end
|
|
266
235
|
end
|
|
267
236
|
|
|
268
|
-
|
|
269
|
-
puts build_cmd
|
|
270
|
-
result = system(build_cmd)
|
|
237
|
+
puts_and_system "docker build -t #{image_name} --platform amd64 ."
|
|
271
238
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if result
|
|
275
|
-
puts_and_system "docker tag #{image_name}:latest #{image_name}:#{rev}"
|
|
276
|
-
puts_and_system "docker tag #{image_name}:#{rev} #{full_image_name}"
|
|
277
|
-
|
|
278
|
-
puts_and_system "docker push #{container_repository}/#{image_name}:#{rev}"
|
|
279
|
-
return true
|
|
280
|
-
else
|
|
281
|
-
say "Build Did Not Succeed"
|
|
282
|
-
return false
|
|
283
|
-
end
|
|
239
|
+
puts_and_system "docker tag #{image_name}:latest #{image_name}:#{rev}"
|
|
240
|
+
puts_and_system "docker tag #{image_name}:#{rev} #{full_image_name}"
|
|
284
241
|
|
|
242
|
+
puts_and_system "docker push #{container_repository}/#{image_name}:#{rev}"
|
|
243
|
+
return true
|
|
285
244
|
end
|
|
286
245
|
|
|
287
246
|
def yy
|
|
@@ -304,7 +263,7 @@ module Pfab
|
|
|
304
263
|
end
|
|
305
264
|
|
|
306
265
|
def get_current_sha
|
|
307
|
-
`git rev-parse --short
|
|
266
|
+
`git rev-parse --short --verify HEAD`.chomp
|
|
308
267
|
end
|
|
309
268
|
|
|
310
269
|
def set_kube_context
|
data/lib/pfab/templates/base.rb
CHANGED
|
@@ -17,10 +17,6 @@ module Pfab
|
|
|
17
17
|
app_vars.dig(@data["env"], key) || app_vars[key]
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def get_namespace()
|
|
21
|
-
get("namespace") || @data['env']
|
|
22
|
-
end
|
|
23
|
-
|
|
24
20
|
def cpu(req_type)
|
|
25
21
|
default_cpu_string = @data["config"]["default_cpu_string"] || "50m/250m"
|
|
26
22
|
(request, limit) = (get("cpu") || default_cpu_string).split("/")
|
|
@@ -46,24 +42,8 @@ module Pfab
|
|
|
46
42
|
}
|
|
47
43
|
end
|
|
48
44
|
|
|
49
|
-
# overridden in subtypes
|
|
50
|
-
def application_type
|
|
51
|
-
"base"
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def deploy_id
|
|
55
|
-
"#{@data['application']}.#{application_type}.#{@data['deployed_name']}"
|
|
56
|
-
end
|
|
57
|
-
|
|
58
45
|
def env_vars
|
|
59
|
-
env_vars = { "DEPLOYED_NAME" => { value: @data['deployed_name'] }
|
|
60
|
-
"DEPLOY_ID" => { value: deploy_id },
|
|
61
|
-
"POD_ID" => { valueFrom: { fieldRef: { fieldPath: 'metadata.name' } } },
|
|
62
|
-
"SPEC_NODENAME" => { valueFrom: { fieldRef: { fieldPath: 'spec.nodeName' } } },
|
|
63
|
-
"DD_ENV" => { valueFrom: { fieldRef: { fieldPath: "metadata.labels['tags.datadoghq.com/env']" } } },
|
|
64
|
-
"DD_SERVICE" => { valueFrom: { fieldRef: { fieldPath: "metadata.labels['tags.datadoghq.com/service']" } } },
|
|
65
|
-
"DD_VERSION" => { valueFrom: { fieldRef: { fieldPath: "metadata.labels['tags.datadoghq.com/version']" } } }
|
|
66
|
-
}
|
|
46
|
+
env_vars = { "DEPLOYED_NAME" => { value: @data['deployed_name'] } }
|
|
67
47
|
|
|
68
48
|
# load defaults
|
|
69
49
|
load_env_vars(env_vars, @data.dig("application_yaml", :environment))
|
|
@@ -85,11 +65,6 @@ module Pfab
|
|
|
85
65
|
env_vars[env_var_name] = { valueFrom: {
|
|
86
66
|
fieldRef: { fieldPath: field_name }
|
|
87
67
|
} }
|
|
88
|
-
elsif v.to_s.start_with? "configmap/"
|
|
89
|
-
(_, configmap_name, key_name) = v.split("/")
|
|
90
|
-
env_vars[env_var_name] = { valueFrom: {
|
|
91
|
-
configMapKeyRef: { name: configmap_name, key: key_name }
|
|
92
|
-
} }
|
|
93
68
|
else
|
|
94
69
|
env_vars[env_var_name] = { value: v }
|
|
95
70
|
end
|
data/lib/pfab/templates/cron.rb
CHANGED
|
@@ -5,25 +5,17 @@ module Pfab
|
|
|
5
5
|
f << YAML.dump(job.deep_stringify_keys)
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
def application_type
|
|
9
|
-
"cron"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
8
|
def job
|
|
13
9
|
{
|
|
14
|
-
apiVersion: "batch/
|
|
10
|
+
apiVersion: "batch/v1beta1",
|
|
15
11
|
kind: "CronJob",
|
|
16
12
|
metadata: {
|
|
17
13
|
name: "#{@data['deployed_name']}-#{@data['sha']}",
|
|
18
|
-
namespace:
|
|
14
|
+
namespace: @data['env'],
|
|
19
15
|
labels: {
|
|
20
16
|
application: @data['application'],
|
|
21
17
|
"deployed-name" => @data['deployed_name'],
|
|
22
|
-
"application-type" =>
|
|
23
|
-
"deploy-id" => deploy_id,
|
|
24
|
-
"tags.datadoghq.com/env": @data['env'],
|
|
25
|
-
"tags.datadoghq.com/service": @data['deployed_name'],
|
|
26
|
-
"tags.datadoghq.com/version": "#{@data['sha']}"
|
|
18
|
+
"application-type" => "job",
|
|
27
19
|
}
|
|
28
20
|
},
|
|
29
21
|
spec: {
|
|
@@ -47,13 +39,10 @@ module Pfab
|
|
|
47
39
|
application: @data['application'],
|
|
48
40
|
"deployed-name" => @data['deployed_name'],
|
|
49
41
|
"application-type" => "cron",
|
|
50
|
-
"tags.datadoghq.com/env": @data['env'],
|
|
51
|
-
"tags.datadoghq.com/service": @data['deployed_name'],
|
|
52
|
-
"tags.datadoghq.com/version": "#{@data['sha']}"
|
|
53
42
|
},
|
|
54
43
|
},
|
|
55
44
|
spec: {
|
|
56
|
-
|
|
45
|
+
|
|
57
46
|
containers: [
|
|
58
47
|
{
|
|
59
48
|
image: image_name,
|
|
@@ -64,7 +53,7 @@ module Pfab
|
|
|
64
53
|
},
|
|
65
54
|
],
|
|
66
55
|
restartPolicy: "Never",
|
|
67
|
-
}
|
|
56
|
+
},
|
|
68
57
|
},
|
|
69
58
|
backoffLimit: 2,
|
|
70
59
|
},
|
|
@@ -5,25 +5,17 @@ module Pfab
|
|
|
5
5
|
f << YAML.dump(deployment.deep_stringify_keys)
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
def application_type
|
|
9
|
-
"daemon"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
8
|
def deployment
|
|
13
9
|
{
|
|
14
10
|
kind: "Deployment",
|
|
15
11
|
apiVersion: "apps/v1",
|
|
16
12
|
metadata: {
|
|
17
13
|
name: @data['deployed_name'],
|
|
18
|
-
namespace:
|
|
14
|
+
namespace: @data['env'],
|
|
19
15
|
labels: {
|
|
20
16
|
application: @data['application'],
|
|
21
17
|
"deployed-name" => @data['deployed_name'],
|
|
22
|
-
"application-type" =>
|
|
23
|
-
"deploy-id" => deploy_id,
|
|
24
|
-
"tags.datadoghq.com/env": @data['env'],
|
|
25
|
-
"tags.datadoghq.com/service": @data['deployed_name'],
|
|
26
|
-
"tags.datadoghq.com/version":"#{@data['sha']}"
|
|
18
|
+
"application-type" => "daemon",
|
|
27
19
|
}
|
|
28
20
|
},
|
|
29
21
|
spec: {
|
|
@@ -43,13 +35,9 @@ module Pfab
|
|
|
43
35
|
application: @data['application'],
|
|
44
36
|
"deployed-name" => @data['deployed_name'],
|
|
45
37
|
"application-type" => "daemon",
|
|
46
|
-
"tags.datadoghq.com/env": @data['env'],
|
|
47
|
-
"tags.datadoghq.com/service": @data['deployed_name'],
|
|
48
|
-
"tags.datadoghq.com/version": "#{@data['sha']}"
|
|
49
38
|
},
|
|
50
39
|
},
|
|
51
40
|
spec: {
|
|
52
|
-
serviceAccountName: get('serviceAccountName'),
|
|
53
41
|
containers: [
|
|
54
42
|
{
|
|
55
43
|
image: image_name,
|
|
@@ -59,9 +47,9 @@ module Pfab
|
|
|
59
47
|
resources: resources,
|
|
60
48
|
}
|
|
61
49
|
]
|
|
62
|
-
}
|
|
50
|
+
},
|
|
63
51
|
},
|
|
64
|
-
}
|
|
52
|
+
},
|
|
65
53
|
}
|
|
66
54
|
end
|
|
67
55
|
end
|
data/lib/pfab/templates/job.rb
CHANGED
|
@@ -5,43 +5,31 @@ module Pfab
|
|
|
5
5
|
f << YAML.dump(job.deep_stringify_keys)
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
def application_type
|
|
9
|
-
"job"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
8
|
def job
|
|
13
9
|
{
|
|
14
10
|
apiVersion: "batch/v1",
|
|
15
11
|
kind: "Job",
|
|
16
12
|
metadata: {
|
|
17
13
|
name: "job-#{@data['deployed_name']}-#{@data['sha']}",
|
|
18
|
-
namespace:
|
|
14
|
+
namespace: @data['env'],
|
|
19
15
|
labels: {
|
|
20
16
|
application: @data['application'],
|
|
21
17
|
"deployed-name" => @data['deployed_name'],
|
|
22
|
-
"application-type" =>
|
|
23
|
-
"deploy-id" => deploy_id,
|
|
24
|
-
"tags.datadoghq.com/env": @data['env'],
|
|
25
|
-
"tags.datadoghq.com/service": @data['deployed_name'],
|
|
26
|
-
"tags.datadoghq.com/version":"#{@data['sha']}"
|
|
18
|
+
"application-type" => "job",
|
|
27
19
|
}
|
|
28
20
|
},
|
|
29
21
|
spec: {
|
|
30
22
|
template: {
|
|
31
23
|
metadata: {
|
|
32
24
|
name: "#{@data['deployed_name']}-#{@data['sha']}",
|
|
33
|
-
namespace:
|
|
25
|
+
namespace: @data['env'],
|
|
34
26
|
labels: {
|
|
35
27
|
application: @data['application'],
|
|
36
28
|
"deployed-name" => @data['deployed_name'],
|
|
37
29
|
"application-type" => "job",
|
|
38
|
-
"tags.datadoghq.com/env": @data['env'],
|
|
39
|
-
"tags.datadoghq.com/service": @data['deployed_name'],
|
|
40
|
-
"tags.datadoghq.com/version": "#{@data['sha']}"
|
|
41
30
|
},
|
|
42
31
|
},
|
|
43
32
|
spec: {
|
|
44
|
-
serviceAccountName: get('serviceAccountName'),
|
|
45
33
|
containers: [
|
|
46
34
|
{
|
|
47
35
|
image: image_name,
|
|
@@ -52,7 +40,7 @@ module Pfab
|
|
|
52
40
|
},
|
|
53
41
|
],
|
|
54
42
|
restartPolicy: "Never",
|
|
55
|
-
}
|
|
43
|
+
},
|
|
56
44
|
},
|
|
57
45
|
backoffLimit: 0,
|
|
58
46
|
},
|
data/lib/pfab/templates/web.rb
CHANGED
|
@@ -6,11 +6,7 @@ module Pfab
|
|
|
6
6
|
puts "No host to deploy to for #{@data['deployed_name']}. Skipping."
|
|
7
7
|
else
|
|
8
8
|
f << YAML.dump(service.deep_stringify_keys)
|
|
9
|
-
|
|
10
|
-
f << YAML.dump(ingress.deep_stringify_keys)
|
|
11
|
-
else
|
|
12
|
-
puts "skipping ingress because ingress_disabled = #{@data['generateIngressEnabled']}"
|
|
13
|
-
end
|
|
9
|
+
f << YAML.dump(ingress.deep_stringify_keys)
|
|
14
10
|
f << YAML.dump(deployment.deep_stringify_keys)
|
|
15
11
|
end
|
|
16
12
|
end
|
|
@@ -21,12 +17,11 @@ module Pfab
|
|
|
21
17
|
kind: "Service",
|
|
22
18
|
metadata: {
|
|
23
19
|
name: @data['deployed_name'],
|
|
24
|
-
namespace:
|
|
20
|
+
namespace: @data['env'],
|
|
25
21
|
labels: {
|
|
26
22
|
application: @data['application'],
|
|
27
23
|
"deployed-name" => @data['deployed_name'],
|
|
28
|
-
}
|
|
29
|
-
annotations: service_annotations,
|
|
24
|
+
}
|
|
30
25
|
},
|
|
31
26
|
spec: {
|
|
32
27
|
selector: {
|
|
@@ -36,27 +31,20 @@ module Pfab
|
|
|
36
31
|
{
|
|
37
32
|
name: "http",
|
|
38
33
|
port: 80,
|
|
39
|
-
targetPort:
|
|
40
|
-
|
|
41
|
-
}.compact
|
|
34
|
+
targetPort: get("port"),
|
|
35
|
+
}
|
|
42
36
|
]
|
|
43
37
|
}
|
|
44
38
|
}
|
|
45
39
|
end
|
|
46
40
|
|
|
47
|
-
def service_annotations
|
|
48
|
-
h = {}
|
|
49
|
-
h["traefik.ingress.kubernetes.io/service.serversscheme"] = "h2c" if get("protocol") == "h2c"
|
|
50
|
-
h
|
|
51
|
-
end
|
|
52
|
-
|
|
53
41
|
def ingress
|
|
54
42
|
{
|
|
55
43
|
apiVersion: "networking.k8s.io/v1",
|
|
56
44
|
kind: "Ingress",
|
|
57
45
|
metadata: {
|
|
58
46
|
name: "ingress-#{@data['deployed_name']}",
|
|
59
|
-
namespace:
|
|
47
|
+
namespace: @data['env'],
|
|
60
48
|
labels: {
|
|
61
49
|
application: @data['application'],
|
|
62
50
|
"deployed-name" => @data['deployed_name'],
|
|
@@ -119,6 +107,7 @@ module Pfab
|
|
|
119
107
|
"traefik.ingress.kubernetes.io/router.entrypoints" => "websecure",
|
|
120
108
|
"traefik.ingress.kubernetes.io/router.tls" => "true"
|
|
121
109
|
}
|
|
110
|
+
h["ingress.kubernetes.io/protocol"] = "h2c" if get("protocol") == "h2c"
|
|
122
111
|
h
|
|
123
112
|
end
|
|
124
113
|
|
|
@@ -141,60 +130,17 @@ module Pfab
|
|
|
141
130
|
get("readinessProbe") || default_probe
|
|
142
131
|
end
|
|
143
132
|
|
|
144
|
-
def startupProbe
|
|
145
|
-
get("startupProbe") || default_probe
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def application_type
|
|
149
|
-
"web"
|
|
150
|
-
end
|
|
151
|
-
|
|
152
133
|
def deployment
|
|
153
|
-
secret_mounts = get("secretMounts") || []
|
|
154
|
-
volume_mounts = []
|
|
155
|
-
volumes = []
|
|
156
|
-
secret_mounts.each do |secret_mount|
|
|
157
|
-
volumes.append({
|
|
158
|
-
name: secret_mount['name'],
|
|
159
|
-
secret: { secretName: secret_mount['secretName'] }
|
|
160
|
-
})
|
|
161
|
-
volume_mounts.append({
|
|
162
|
-
name: secret_mount['name'],
|
|
163
|
-
mountPath: secret_mount['path'],
|
|
164
|
-
readOnly: secret_mount['readOnly'] || true
|
|
165
|
-
})
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
if get("datadogVolumeMountEnabled")
|
|
169
|
-
datadog_volume_name = "ddsocket"
|
|
170
|
-
datadog_path = "/var/run/datadog"
|
|
171
|
-
volumes.append({
|
|
172
|
-
name: datadog_volume_name,
|
|
173
|
-
hostPath: {
|
|
174
|
-
path: datadog_path
|
|
175
|
-
}
|
|
176
|
-
})
|
|
177
|
-
volume_mounts.append(
|
|
178
|
-
name: datadog_volume_name,
|
|
179
|
-
mountPath: datadog_path,
|
|
180
|
-
readOnly: true
|
|
181
|
-
)
|
|
182
|
-
end
|
|
183
|
-
|
|
184
134
|
{
|
|
185
135
|
kind: "Deployment",
|
|
186
136
|
apiVersion: "apps/v1",
|
|
187
137
|
metadata: {
|
|
188
138
|
name: @data['deployed_name'],
|
|
189
|
-
namespace:
|
|
139
|
+
namespace: @data['env'],
|
|
190
140
|
labels: {
|
|
191
141
|
application: @data['application'],
|
|
192
142
|
"deployed-name" => @data['deployed_name'],
|
|
193
|
-
"application-type" =>
|
|
194
|
-
"deploy-id" => deploy_id,
|
|
195
|
-
"tags.datadoghq.com/env": @data['env'],
|
|
196
|
-
"tags.datadoghq.com/service": @data['deployed_name'],
|
|
197
|
-
"tags.datadoghq.com/version":"#{@data['sha']}"
|
|
143
|
+
"application-type" => "web",
|
|
198
144
|
}
|
|
199
145
|
},
|
|
200
146
|
spec: {
|
|
@@ -219,13 +165,9 @@ module Pfab
|
|
|
219
165
|
application: @data['application'],
|
|
220
166
|
"deployed-name" => @data['deployed_name'],
|
|
221
167
|
"application-type" => "web",
|
|
222
|
-
"tags.datadoghq.com/env": @data['env'],
|
|
223
|
-
"tags.datadoghq.com/service": @data['deployed_name'],
|
|
224
|
-
"tags.datadoghq.com/version": "#{@data['sha']}"
|
|
225
168
|
},
|
|
226
169
|
},
|
|
227
170
|
spec: {
|
|
228
|
-
serviceAccountName: get('serviceAccountName'),
|
|
229
171
|
containers: [
|
|
230
172
|
{
|
|
231
173
|
image: image_name,
|
|
@@ -233,26 +175,13 @@ module Pfab
|
|
|
233
175
|
command: get("command").split(" "),
|
|
234
176
|
env: env_vars,
|
|
235
177
|
resources: resources,
|
|
236
|
-
ports: [
|
|
237
|
-
{
|
|
238
|
-
name: "main",
|
|
239
|
-
containerPort: app_vars["port"]
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
name: "health-port",
|
|
243
|
-
containerPort: 8085 # the default micronaut endpoint port
|
|
244
|
-
}
|
|
245
|
-
],
|
|
246
178
|
livenessProbe: livenessProbe,
|
|
247
179
|
readinessProbe: readinessProbe,
|
|
248
|
-
startupProbe: startupProbe,
|
|
249
|
-
volumeMounts: volume_mounts
|
|
250
180
|
}
|
|
251
|
-
]
|
|
252
|
-
|
|
253
|
-
}.compact,
|
|
181
|
+
]
|
|
182
|
+
},
|
|
254
183
|
},
|
|
255
|
-
}
|
|
184
|
+
},
|
|
256
185
|
}
|
|
257
186
|
end
|
|
258
187
|
end
|
data/lib/pfab/version.rb
CHANGED
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.33.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.33.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 = "2023-02-
|
|
14
|
+
s.date = "2023-02-21"
|
|
15
15
|
s.description = "k8s helper".freeze
|
|
16
16
|
s.email = "jdwyer@prefab.cloud".freeze
|
|
17
17
|
s.executables = ["pfab".freeze]
|
|
@@ -22,7 +22,6 @@ Gem::Specification.new do |s|
|
|
|
22
22
|
s.files = [
|
|
23
23
|
".document",
|
|
24
24
|
".tool-versions",
|
|
25
|
-
"CODEOWNERS",
|
|
26
25
|
"Gemfile",
|
|
27
26
|
"Gemfile.lock",
|
|
28
27
|
"LICENSE.txt",
|
|
@@ -44,7 +43,7 @@ Gem::Specification.new do |s|
|
|
|
44
43
|
]
|
|
45
44
|
s.homepage = "http://github.com/prefab-cloud/pfab".freeze
|
|
46
45
|
s.licenses = ["MIT".freeze]
|
|
47
|
-
s.rubygems_version = "3.
|
|
46
|
+
s.rubygems_version = "3.3.7".freeze
|
|
48
47
|
s.summary = "helper gem".freeze
|
|
49
48
|
|
|
50
49
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pfab
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.33.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeff Dwyer
|
|
@@ -133,7 +133,6 @@ extra_rdoc_files:
|
|
|
133
133
|
files:
|
|
134
134
|
- ".document"
|
|
135
135
|
- ".tool-versions"
|
|
136
|
-
- CODEOWNERS
|
|
137
136
|
- Gemfile
|
|
138
137
|
- Gemfile.lock
|
|
139
138
|
- LICENSE.txt
|
data/CODEOWNERS
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
* @prefab-cloud/prefabdevs @prefab-cloud/prefabmaintainers @prefab-cloud/prefabadmins
|