pfab 0.33.0 → 0.34.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/CODEOWNERS +1 -0
- data/Gemfile.lock +10 -10
- data/README.markdown +3 -3
- data/lib/pfab/cli.rb +57 -16
- data/lib/pfab/templates/base.rb +26 -1
- data/lib/pfab/templates/cron.rb +16 -5
- data/lib/pfab/templates/daemon.rb +16 -4
- data/lib/pfab/templates/job.rb +16 -4
- data/lib/pfab/templates/web.rb +83 -12
- data/lib/pfab/version.rb +1 -1
- data/pfab.gemspec +3 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43fd2d75471720154cc7f601da778a1f2e876ad3a2b6f10b6287a7c5c495a9a2
|
4
|
+
data.tar.gz: ea9b62311da369c161222052886f6203eb5c0abeffcb0eefb70d5624db530443
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68fb2dc8204e567dbae8a2d0b693e8f4fb313da71ae3ee99de55f2e80db90241c12a18b9420a780da66ee6e0279e65ba5436f757f1b8c55be6e7fe8b0524e12c
|
7
|
+
data.tar.gz: f14ce8e698afc69632ee311f1735ac0b6ac24de734dbfa2b947a93de120df7845cde3ef4daf28f3bf7f35fed65c97eb7095e8ad1110b380c307870e81e673214
|
data/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @prefab-cloud/prefabdevs @prefab-cloud/prefabmaintainers @prefab-cloud/prefabadmins
|
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.4.3)
|
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.9)
|
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.11.0)
|
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.8.11)
|
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.0)
|
74
|
+
minitest (5.15.0)
|
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.13.6)
|
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.0)
|
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.9)
|
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
|
+
2.3.5
|
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
|
-
- ```bundle exec rake git:release```
|
121
|
-
- ```bundle exec rake build```
|
122
|
-
- ```gem push pkg/pfab-0.
|
120
|
+
- ```REMOTE_BRANCH=main LOCAL_BRANCH=main bundle exec rake git:release```
|
121
|
+
- ```REMOTE_BRANCH=main LOCAL_BRANCH=main bundle exec rake build```
|
122
|
+
- ```gem push pkg/pfab-0.15.0.gem```
|
123
123
|
|
124
124
|
Copyright
|
125
125
|
---------
|
data/lib/pfab/cli.rb
CHANGED
@@ -22,7 +22,14 @@ module Pfab
|
|
22
22
|
$dryrun = false
|
23
23
|
global_option("--dryrun") { $dryrun = true }
|
24
24
|
$env = :staging
|
25
|
-
global_option("-p")
|
25
|
+
global_option("-p") do
|
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
|
26
33
|
global_option("-a", "--application_name APP_NAME", "run without prompting for app") do |app_name|
|
27
34
|
$app_name = app_name
|
28
35
|
end
|
@@ -31,8 +38,9 @@ module Pfab
|
|
31
38
|
c.syntax = "pfab build"
|
32
39
|
c.summary = "build image"
|
33
40
|
c.option "--force", "force build and push"
|
41
|
+
c.option "--check", "just check if built"
|
34
42
|
c.action do |_args, options|
|
35
|
-
cmd_build(force: options.force)
|
43
|
+
cmd_build(force: options.force, checkonly: options.check)
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
@@ -83,6 +91,18 @@ module Pfab
|
|
83
91
|
end
|
84
92
|
end
|
85
93
|
|
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
|
+
|
86
106
|
command :exec do |c|
|
87
107
|
c.syntax = "pfab exec"
|
88
108
|
c.summary = "kubectl exec into a pod"
|
@@ -190,10 +210,20 @@ module Pfab
|
|
190
210
|
end
|
191
211
|
puts_and_system("kubectl apply -f .application-k8s-#{$env}-#{app_name}.yaml")
|
192
212
|
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")
|
193
214
|
end
|
194
215
|
end
|
195
216
|
|
196
|
-
def
|
217
|
+
def image_exists?(full_image_name)
|
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)
|
197
227
|
rev = get_current_sha
|
198
228
|
say "This repo is at rev: #{rev}"
|
199
229
|
uncommitted_changes = !`git diff-index HEAD --`.empty?
|
@@ -209,13 +239,14 @@ module Pfab
|
|
209
239
|
|
210
240
|
full_image_name = "#{container_repository}/#{image_name}:#{rev}"
|
211
241
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
242
|
+
unless force
|
243
|
+
if image_exists?(full_image_name)
|
244
|
+
say "Found image #{full_image_name} already, skipping prebuild, build & push"
|
245
|
+
return true
|
246
|
+
else
|
247
|
+
say "No image #{full_image_name} present"
|
248
|
+
end
|
249
|
+
return if checkonly
|
219
250
|
end
|
220
251
|
|
221
252
|
say "No image #{full_image_name} present, building"
|
@@ -234,13 +265,23 @@ module Pfab
|
|
234
265
|
end
|
235
266
|
end
|
236
267
|
|
237
|
-
|
268
|
+
build_cmd = "docker build -t #{image_name} --platform amd64 ."
|
269
|
+
puts build_cmd
|
270
|
+
result = system(build_cmd)
|
238
271
|
|
239
|
-
|
240
|
-
|
272
|
+
puts "Build Result #{result}"
|
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
|
241
284
|
|
242
|
-
puts_and_system "docker push #{container_repository}/#{image_name}:#{rev}"
|
243
|
-
return true
|
244
285
|
end
|
245
286
|
|
246
287
|
def yy
|
@@ -263,7 +304,7 @@ module Pfab
|
|
263
304
|
end
|
264
305
|
|
265
306
|
def get_current_sha
|
266
|
-
`git rev-parse --short --verify HEAD`.chomp
|
307
|
+
`git rev-parse --short=8 --verify HEAD`.chomp
|
267
308
|
end
|
268
309
|
|
269
310
|
def set_kube_context
|
data/lib/pfab/templates/base.rb
CHANGED
@@ -17,6 +17,10 @@ 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
|
+
|
20
24
|
def cpu(req_type)
|
21
25
|
default_cpu_string = @data["config"]["default_cpu_string"] || "50m/250m"
|
22
26
|
(request, limit) = (get("cpu") || default_cpu_string).split("/")
|
@@ -42,8 +46,24 @@ module Pfab
|
|
42
46
|
}
|
43
47
|
end
|
44
48
|
|
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
|
+
|
45
58
|
def env_vars
|
46
|
-
env_vars = { "DEPLOYED_NAME" => { value: @data['deployed_name'] }
|
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
|
+
}
|
47
67
|
|
48
68
|
# load defaults
|
49
69
|
load_env_vars(env_vars, @data.dig("application_yaml", :environment))
|
@@ -65,6 +85,11 @@ module Pfab
|
|
65
85
|
env_vars[env_var_name] = { valueFrom: {
|
66
86
|
fieldRef: { fieldPath: field_name }
|
67
87
|
} }
|
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
|
+
} }
|
68
93
|
else
|
69
94
|
env_vars[env_var_name] = { value: v }
|
70
95
|
end
|
data/lib/pfab/templates/cron.rb
CHANGED
@@ -5,17 +5,25 @@ 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
|
+
|
8
12
|
def job
|
9
13
|
{
|
10
|
-
apiVersion: "batch/
|
14
|
+
apiVersion: "batch/v1",
|
11
15
|
kind: "CronJob",
|
12
16
|
metadata: {
|
13
17
|
name: "#{@data['deployed_name']}-#{@data['sha']}",
|
14
|
-
namespace:
|
18
|
+
namespace: get_namespace,
|
15
19
|
labels: {
|
16
20
|
application: @data['application'],
|
17
21
|
"deployed-name" => @data['deployed_name'],
|
18
|
-
"application-type" =>
|
22
|
+
"application-type" => 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']}"
|
19
27
|
}
|
20
28
|
},
|
21
29
|
spec: {
|
@@ -39,10 +47,13 @@ module Pfab
|
|
39
47
|
application: @data['application'],
|
40
48
|
"deployed-name" => @data['deployed_name'],
|
41
49
|
"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']}"
|
42
53
|
},
|
43
54
|
},
|
44
55
|
spec: {
|
45
|
-
|
56
|
+
serviceAccountName: get('serviceAccountName'),
|
46
57
|
containers: [
|
47
58
|
{
|
48
59
|
image: image_name,
|
@@ -53,7 +64,7 @@ module Pfab
|
|
53
64
|
},
|
54
65
|
],
|
55
66
|
restartPolicy: "Never",
|
56
|
-
},
|
67
|
+
}.compact,
|
57
68
|
},
|
58
69
|
backoffLimit: 2,
|
59
70
|
},
|
@@ -5,17 +5,25 @@ 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
|
+
|
8
12
|
def deployment
|
9
13
|
{
|
10
14
|
kind: "Deployment",
|
11
15
|
apiVersion: "apps/v1",
|
12
16
|
metadata: {
|
13
17
|
name: @data['deployed_name'],
|
14
|
-
namespace:
|
18
|
+
namespace: get_namespace,
|
15
19
|
labels: {
|
16
20
|
application: @data['application'],
|
17
21
|
"deployed-name" => @data['deployed_name'],
|
18
|
-
"application-type" =>
|
22
|
+
"application-type" => 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']}"
|
19
27
|
}
|
20
28
|
},
|
21
29
|
spec: {
|
@@ -35,9 +43,13 @@ module Pfab
|
|
35
43
|
application: @data['application'],
|
36
44
|
"deployed-name" => @data['deployed_name'],
|
37
45
|
"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']}"
|
38
49
|
},
|
39
50
|
},
|
40
51
|
spec: {
|
52
|
+
serviceAccountName: get('serviceAccountName'),
|
41
53
|
containers: [
|
42
54
|
{
|
43
55
|
image: image_name,
|
@@ -47,9 +59,9 @@ module Pfab
|
|
47
59
|
resources: resources,
|
48
60
|
}
|
49
61
|
]
|
50
|
-
},
|
62
|
+
}.compact,
|
51
63
|
},
|
52
|
-
},
|
64
|
+
}.compact,
|
53
65
|
}
|
54
66
|
end
|
55
67
|
end
|
data/lib/pfab/templates/job.rb
CHANGED
@@ -5,31 +5,43 @@ 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
|
+
|
8
12
|
def job
|
9
13
|
{
|
10
14
|
apiVersion: "batch/v1",
|
11
15
|
kind: "Job",
|
12
16
|
metadata: {
|
13
17
|
name: "job-#{@data['deployed_name']}-#{@data['sha']}",
|
14
|
-
namespace:
|
18
|
+
namespace: get_namespace,
|
15
19
|
labels: {
|
16
20
|
application: @data['application'],
|
17
21
|
"deployed-name" => @data['deployed_name'],
|
18
|
-
"application-type" =>
|
22
|
+
"application-type" => 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']}"
|
19
27
|
}
|
20
28
|
},
|
21
29
|
spec: {
|
22
30
|
template: {
|
23
31
|
metadata: {
|
24
32
|
name: "#{@data['deployed_name']}-#{@data['sha']}",
|
25
|
-
namespace:
|
33
|
+
namespace: get_namespace,
|
26
34
|
labels: {
|
27
35
|
application: @data['application'],
|
28
36
|
"deployed-name" => @data['deployed_name'],
|
29
37
|
"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']}"
|
30
41
|
},
|
31
42
|
},
|
32
43
|
spec: {
|
44
|
+
serviceAccountName: get('serviceAccountName'),
|
33
45
|
containers: [
|
34
46
|
{
|
35
47
|
image: image_name,
|
@@ -40,7 +52,7 @@ module Pfab
|
|
40
52
|
},
|
41
53
|
],
|
42
54
|
restartPolicy: "Never",
|
43
|
-
},
|
55
|
+
}.compact,
|
44
56
|
},
|
45
57
|
backoffLimit: 0,
|
46
58
|
},
|
data/lib/pfab/templates/web.rb
CHANGED
@@ -6,7 +6,11 @@ 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
|
-
|
9
|
+
if not app_vars.has_key?('generateIngressEnabled') || app_vars['generateIngressEnabled']
|
10
|
+
f << YAML.dump(ingress.deep_stringify_keys)
|
11
|
+
else
|
12
|
+
puts "skipping ingress because ingress_disabled = #{@data['generateIngressEnabled']}"
|
13
|
+
end
|
10
14
|
f << YAML.dump(deployment.deep_stringify_keys)
|
11
15
|
end
|
12
16
|
end
|
@@ -17,11 +21,12 @@ module Pfab
|
|
17
21
|
kind: "Service",
|
18
22
|
metadata: {
|
19
23
|
name: @data['deployed_name'],
|
20
|
-
namespace:
|
24
|
+
namespace: get_namespace,
|
21
25
|
labels: {
|
22
26
|
application: @data['application'],
|
23
27
|
"deployed-name" => @data['deployed_name'],
|
24
|
-
}
|
28
|
+
},
|
29
|
+
annotations: service_annotations,
|
25
30
|
},
|
26
31
|
spec: {
|
27
32
|
selector: {
|
@@ -31,20 +36,27 @@ module Pfab
|
|
31
36
|
{
|
32
37
|
name: "http",
|
33
38
|
port: 80,
|
34
|
-
targetPort:
|
35
|
-
|
39
|
+
targetPort: app_vars["port"],
|
40
|
+
appProtocol: app_vars["appProtocol"]
|
41
|
+
}.compact
|
36
42
|
]
|
37
43
|
}
|
38
44
|
}
|
39
45
|
end
|
40
46
|
|
47
|
+
def service_annotations
|
48
|
+
h = {}
|
49
|
+
h["traefik.ingress.kubernetes.io/service.serversscheme"] = "h2c" if get("protocol") == "h2c"
|
50
|
+
h
|
51
|
+
end
|
52
|
+
|
41
53
|
def ingress
|
42
54
|
{
|
43
55
|
apiVersion: "networking.k8s.io/v1",
|
44
56
|
kind: "Ingress",
|
45
57
|
metadata: {
|
46
58
|
name: "ingress-#{@data['deployed_name']}",
|
47
|
-
namespace:
|
59
|
+
namespace: get_namespace,
|
48
60
|
labels: {
|
49
61
|
application: @data['application'],
|
50
62
|
"deployed-name" => @data['deployed_name'],
|
@@ -107,7 +119,6 @@ module Pfab
|
|
107
119
|
"traefik.ingress.kubernetes.io/router.entrypoints" => "websecure",
|
108
120
|
"traefik.ingress.kubernetes.io/router.tls" => "true"
|
109
121
|
}
|
110
|
-
h["ingress.kubernetes.io/protocol"] = "h2c" if get("protocol") == "h2c"
|
111
122
|
h
|
112
123
|
end
|
113
124
|
|
@@ -130,17 +141,60 @@ module Pfab
|
|
130
141
|
get("readinessProbe") || default_probe
|
131
142
|
end
|
132
143
|
|
144
|
+
def startupProbe
|
145
|
+
get("startupProbe") || default_probe
|
146
|
+
end
|
147
|
+
|
148
|
+
def application_type
|
149
|
+
"web"
|
150
|
+
end
|
151
|
+
|
133
152
|
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
|
+
|
134
184
|
{
|
135
185
|
kind: "Deployment",
|
136
186
|
apiVersion: "apps/v1",
|
137
187
|
metadata: {
|
138
188
|
name: @data['deployed_name'],
|
139
|
-
namespace:
|
189
|
+
namespace: get_namespace,
|
140
190
|
labels: {
|
141
191
|
application: @data['application'],
|
142
192
|
"deployed-name" => @data['deployed_name'],
|
143
|
-
"application-type" =>
|
193
|
+
"application-type" => 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']}"
|
144
198
|
}
|
145
199
|
},
|
146
200
|
spec: {
|
@@ -165,9 +219,13 @@ module Pfab
|
|
165
219
|
application: @data['application'],
|
166
220
|
"deployed-name" => @data['deployed_name'],
|
167
221
|
"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']}"
|
168
225
|
},
|
169
226
|
},
|
170
227
|
spec: {
|
228
|
+
serviceAccountName: get('serviceAccountName'),
|
171
229
|
containers: [
|
172
230
|
{
|
173
231
|
image: image_name,
|
@@ -175,13 +233,26 @@ module Pfab
|
|
175
233
|
command: get("command").split(" "),
|
176
234
|
env: env_vars,
|
177
235
|
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
|
+
],
|
178
246
|
livenessProbe: livenessProbe,
|
179
247
|
readinessProbe: readinessProbe,
|
248
|
+
startupProbe: startupProbe,
|
249
|
+
volumeMounts: volume_mounts
|
180
250
|
}
|
181
|
-
]
|
182
|
-
|
251
|
+
],
|
252
|
+
volumes: volumes
|
253
|
+
}.compact,
|
183
254
|
},
|
184
|
-
},
|
255
|
+
}.compact,
|
185
256
|
}
|
186
257
|
end
|
187
258
|
end
|
data/lib/pfab/version.rb
CHANGED
data/pfab.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.34.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.34.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]
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.files = [
|
23
23
|
".document",
|
24
24
|
".tool-versions",
|
25
|
+
"CODEOWNERS",
|
25
26
|
"Gemfile",
|
26
27
|
"Gemfile.lock",
|
27
28
|
"LICENSE.txt",
|
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.34.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Dwyer
|
@@ -133,6 +133,7 @@ extra_rdoc_files:
|
|
133
133
|
files:
|
134
134
|
- ".document"
|
135
135
|
- ".tool-versions"
|
136
|
+
- CODEOWNERS
|
136
137
|
- Gemfile
|
137
138
|
- Gemfile.lock
|
138
139
|
- LICENSE.txt
|