pfab 0.52.0 → 0.54.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 +19 -17
- data/lib/pfab/cli.rb +3 -0
- data/lib/pfab/templates/base.rb +6 -0
- data/lib/pfab/templates/web.rb +47 -42
- data/lib/pfab/version.rb +1 -1
- data/lib/pfab/yamls.rb +2 -1
- data/pfab.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6db80ed30cdab582adbf60a44b1cb80ffb32420898d07117b5e0fe81f0012ac
|
4
|
+
data.tar.gz: 818d93a741088cee1a7988273e6eb3389c013fee43227193d086f9cdaa8c01ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f53b2f212245784bd4d518c7058aa7a2bdad7c2bba7b4a1c956f86356e037ff429ec704c1f7210969ac05e2bfbc05e2273e7961cee9028941e0361d85aaaa618
|
7
|
+
data.tar.gz: 2d1e0b3cd52341158feea24b3f184b5ccd53c1dd1951b37b4cdcbed9d54d5e023c7bd772e27a7f86828f56ad86ccf1187c7ed7596a79acc5efc6457d525199cd
|
data/Gemfile.lock
CHANGED
@@ -18,11 +18,12 @@ GIT
|
|
18
18
|
GEM
|
19
19
|
remote: https://rubygems.org/
|
20
20
|
specs:
|
21
|
-
activesupport (
|
21
|
+
activesupport (6.1.7.5)
|
22
22
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
23
|
-
i18n (>=
|
24
|
-
minitest (
|
25
|
-
tzinfo (~>
|
23
|
+
i18n (>= 1.6, < 2)
|
24
|
+
minitest (>= 5.1)
|
25
|
+
tzinfo (~> 2.0)
|
26
|
+
zeitwerk (~> 2.3)
|
26
27
|
addressable (2.8.0)
|
27
28
|
public_suffix (>= 2.0.2, < 5.0)
|
28
29
|
builder (3.2.4)
|
@@ -30,7 +31,7 @@ GEM
|
|
30
31
|
coderay (1.1.3)
|
31
32
|
commander (4.4.6)
|
32
33
|
highline (~> 1.7.2)
|
33
|
-
concurrent-ruby (1.
|
34
|
+
concurrent-ruby (1.2.3)
|
34
35
|
descendants_tracker (0.0.4)
|
35
36
|
thread_safe (~> 0.3, >= 0.3.1)
|
36
37
|
docile (1.3.1)
|
@@ -64,27 +65,27 @@ GEM
|
|
64
65
|
oauth2 (~> 1.0)
|
65
66
|
hashie (3.6.0)
|
66
67
|
highline (1.7.10)
|
67
|
-
i18n (1.
|
68
|
+
i18n (1.14.5)
|
68
69
|
concurrent-ruby (~> 1.0)
|
69
70
|
json (1.8.6)
|
70
71
|
jwt (2.3.0)
|
71
72
|
kamelcase (0.0.2)
|
72
73
|
semver2 (~> 3)
|
73
74
|
method_source (1.0.0)
|
74
|
-
mini_portile2 (2.8.
|
75
|
-
minitest (5.
|
75
|
+
mini_portile2 (2.8.6)
|
76
|
+
minitest (5.22.3)
|
76
77
|
multi_json (1.15.0)
|
77
78
|
multi_xml (0.6.0)
|
78
79
|
multipart-post (2.1.1)
|
79
|
-
nokogiri (1.
|
80
|
-
mini_portile2 (~> 2.8.
|
80
|
+
nokogiri (1.16.5)
|
81
|
+
mini_portile2 (~> 2.8.2)
|
81
82
|
racc (~> 1.4)
|
82
|
-
oauth2 (1.4.
|
83
|
-
faraday (>= 0.
|
83
|
+
oauth2 (1.4.11)
|
84
|
+
faraday (>= 0.17.3, < 3.0)
|
84
85
|
jwt (>= 1.0, < 3.0)
|
85
86
|
multi_json (~> 1.3)
|
86
87
|
multi_xml (~> 0.5)
|
87
|
-
rack (>= 1.2, <
|
88
|
+
rack (>= 1.2, < 4)
|
88
89
|
power_assert (1.1.3)
|
89
90
|
pry (0.14.2)
|
90
91
|
coderay (~> 1.1)
|
@@ -94,8 +95,8 @@ GEM
|
|
94
95
|
pry (>= 0.13, < 0.15)
|
95
96
|
psych (4.0.2)
|
96
97
|
public_suffix (4.0.6)
|
97
|
-
racc (1.
|
98
|
-
rack (
|
98
|
+
racc (1.7.3)
|
99
|
+
rack (3.0.11)
|
99
100
|
rake (13.0.6)
|
100
101
|
rchardet (1.8.0)
|
101
102
|
rdoc (3.12.2)
|
@@ -111,8 +112,9 @@ GEM
|
|
111
112
|
test-unit (3.2.9)
|
112
113
|
power_assert
|
113
114
|
thread_safe (0.3.6)
|
114
|
-
tzinfo (
|
115
|
-
|
115
|
+
tzinfo (2.0.6)
|
116
|
+
concurrent-ruby (~> 1.0)
|
117
|
+
zeitwerk (2.6.14)
|
116
118
|
|
117
119
|
PLATFORMS
|
118
120
|
ruby
|
data/lib/pfab/cli.rb
CHANGED
@@ -4,6 +4,7 @@ require "yaml"
|
|
4
4
|
require "json"
|
5
5
|
require 'active_support/core_ext/hash/indifferent_access'
|
6
6
|
require 'styled_yaml'
|
7
|
+
require 'digest'
|
7
8
|
|
8
9
|
module Pfab
|
9
10
|
class CLI
|
@@ -16,6 +17,7 @@ module Pfab
|
|
16
17
|
|
17
18
|
if File.exist? "application.yaml"
|
18
19
|
@application_yaml = YAML.load(File.read("application.yaml")).with_indifferent_access
|
20
|
+
@application_yaml_hash = Digest::SHA256.hexdigest(@application_yaml.to_json)
|
19
21
|
else
|
20
22
|
raise "I need to be run in a directory with a application.yaml"
|
21
23
|
end
|
@@ -291,6 +293,7 @@ module Pfab
|
|
291
293
|
def yy
|
292
294
|
Pfab::Yamls.new(apps: all_runnables,
|
293
295
|
application_yaml: @application_yaml,
|
296
|
+
application_yaml_hash: @application_yaml_hash,
|
294
297
|
env: $env,
|
295
298
|
sha: get_current_sha,
|
296
299
|
image_name: image_name,
|
data/lib/pfab/templates/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
module Pfab
|
2
4
|
module Templates
|
3
5
|
class Base
|
@@ -63,6 +65,10 @@ module Pfab
|
|
63
65
|
"#{@data['application']}.#{application_type}.#{@data['deployed_name']}"
|
64
66
|
end
|
65
67
|
|
68
|
+
def deploy_unique_id
|
69
|
+
@data['sha'] + "-" + @data['application_yaml_hash'][0,8]
|
70
|
+
end
|
71
|
+
|
66
72
|
def env_from
|
67
73
|
env_from = []
|
68
74
|
env_from << @data.dig("application_yaml", :env_from)
|
data/lib/pfab/templates/web.rb
CHANGED
@@ -14,7 +14,9 @@ module Pfab
|
|
14
14
|
puts "skipping ingress because ingress_disabled = #{@data['generateIngressEnabled']}"
|
15
15
|
end
|
16
16
|
f << StyledYAML.dump(deployment.deep_stringify_keys)
|
17
|
-
|
17
|
+
if get("replicas") || 1 > 1
|
18
|
+
f << StyledYAML.dump(pod_disruption_budget.deep_stringify_keys)
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -185,13 +187,7 @@ module Pfab
|
|
185
187
|
|
186
188
|
|
187
189
|
def anti_affinity
|
188
|
-
|
189
|
-
z = zone_anti_affinity
|
190
|
-
printf("host anti affinity: %s\n", p)
|
191
|
-
printf("zone anti affinity: %s\n", z)
|
192
|
-
m = merge_anti_affinity(p, z)
|
193
|
-
printf("merged anti affinity: %s\n", m)
|
194
|
-
return m
|
190
|
+
return host_anti_affinity
|
195
191
|
end
|
196
192
|
|
197
193
|
|
@@ -199,50 +195,57 @@ module Pfab
|
|
199
195
|
anti_affinity_builder(ANTI_AFFINITY_MODE, ANTI_AFFINITY_PREFERRED_MODE_WEIGHT, "kubernetes.io/hostname")
|
200
196
|
end
|
201
197
|
|
202
|
-
def zone_anti_affinity
|
203
|
-
anti_affinity_builder(ZONE_ANTI_AFFINITY_MODE, ZONE_ANTI_AFFINITY_PREFERRED_MODE_WEIGHT, "topology.kubernetes.io/zone")
|
204
|
-
end
|
205
198
|
|
206
|
-
def
|
207
|
-
|
199
|
+
def topology_spread_constraints
|
200
|
+
waiveTopologySpreadConstraints = get("waiveTopologySpreadConstraints") || false
|
208
201
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
if pod_anti_affinity.dig(:podAntiAffinity, key) && zone_anti_affinity.dig(:podAntiAffinity, key)
|
223
|
-
merged[:podAntiAffinity][key] = pod_anti_affinity[:podAntiAffinity][key] + zone_anti_affinity[:podAntiAffinity][key]
|
224
|
-
elsif pod_anti_affinity.dig(:podAntiAffinity, key)
|
225
|
-
merged[:podAntiAffinity][key] = pod_anti_affinity[:podAntiAffinity][key]
|
226
|
-
elsif zone_anti_affinity.dig(:podAntiAffinity, key)
|
227
|
-
merged[:podAntiAffinity][key] = zone_anti_affinity[:podAntiAffinity][key]
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
202
|
+
schedulingRule = waiveTopologySpreadConstraints ? "ScheduleAnyway" : "DoNotSchedule"
|
203
|
+
|
204
|
+
zone_constraint = {
|
205
|
+
maxSkew: 1,
|
206
|
+
topologyKey: "topology.kubernetes.io/zone",
|
207
|
+
whenUnsatisfiable: schedulingRule,
|
208
|
+
labelSelector: labelSelector
|
209
|
+
}
|
210
|
+
host_constraint = {
|
211
|
+
maxSkew: 1,
|
212
|
+
topologyKey: "kubernetes.io/hostname",
|
213
|
+
whenUnsatisfiable: schedulingRule,
|
214
|
+
labelSelector: labelSelector
|
231
215
|
|
232
|
-
|
216
|
+
}
|
217
|
+
[zone_constraint, host_constraint]
|
233
218
|
end
|
234
219
|
|
235
220
|
|
221
|
+
|
222
|
+
def labelSelector
|
223
|
+
{
|
224
|
+
matchExpressions: [
|
225
|
+
{
|
226
|
+
key: "deployed-name",
|
227
|
+
operator: "In",
|
228
|
+
values: [
|
229
|
+
@data['deployed_name']
|
230
|
+
]
|
231
|
+
},
|
232
|
+
{
|
233
|
+
key: "deployment-unique-id",
|
234
|
+
operator: "In",
|
235
|
+
values: [
|
236
|
+
StyledYAML.double_quoted(deploy_unique_id)
|
237
|
+
]
|
238
|
+
}
|
239
|
+
]
|
240
|
+
}
|
241
|
+
end
|
242
|
+
|
236
243
|
def anti_affinity_builder(key, weight_key, topology_key)
|
237
244
|
antiAffinityMode = get(key) || "disabled"
|
238
245
|
if antiAffinityMode
|
239
246
|
affinitySelector = {
|
240
247
|
topologyKey: topology_key,
|
241
|
-
labelSelector:
|
242
|
-
matchLabels: {
|
243
|
-
"deployed-name" => @data['deployed_name'],
|
244
|
-
},
|
245
|
-
},
|
248
|
+
labelSelector: labelSelector,
|
246
249
|
}
|
247
250
|
|
248
251
|
return case antiAffinityMode
|
@@ -316,6 +319,7 @@ module Pfab
|
|
316
319
|
"deployed-name" => @data['deployed_name'],
|
317
320
|
"application-type" => application_type,
|
318
321
|
"deploy-id" => deploy_id,
|
322
|
+
"deploy-unique-id" => StyledYAML.double_quoted(deploy_unique_id),
|
319
323
|
"tags.datadoghq.com/env": @data['env'],
|
320
324
|
"tags.datadoghq.com/service": @data['deployed_name'],
|
321
325
|
"tags.datadoghq.com/version": StyledYAML.double_quoted(@data['sha'])
|
@@ -343,6 +347,7 @@ module Pfab
|
|
343
347
|
application: @data['application'],
|
344
348
|
"deployed-name" => @data['deployed_name'],
|
345
349
|
"application-type" => "web",
|
350
|
+
"deploy-unique-id" => StyledYAML.double_quoted(deploy_unique_id),
|
346
351
|
"tags.datadoghq.com/env": @data['env'],
|
347
352
|
"tags.datadoghq.com/service": @data['deployed_name'],
|
348
353
|
"tags.datadoghq.com/version": StyledYAML.double_quoted(@data['sha'])
|
@@ -367,7 +372,7 @@ module Pfab
|
|
367
372
|
volumeMounts: volume_mounts
|
368
373
|
}.compact
|
369
374
|
],
|
370
|
-
|
375
|
+
topologySpreadConstraints: topology_spread_constraints,
|
371
376
|
volumes: volumes
|
372
377
|
}.compact,
|
373
378
|
},
|
data/lib/pfab/version.rb
CHANGED
data/lib/pfab/yamls.rb
CHANGED
@@ -2,7 +2,7 @@ require 'pry'
|
|
2
2
|
module Pfab
|
3
3
|
class Yamls
|
4
4
|
|
5
|
-
def initialize(apps:, application_yaml:, image_name:, env:, sha:, config:)
|
5
|
+
def initialize(apps:, application_yaml:, image_name:, env:, sha:, config:, application_yaml_hash:)
|
6
6
|
@apps = apps
|
7
7
|
namespace = application_yaml.dig(env.to_s, "namespace") || application_yaml["namespace"]
|
8
8
|
raise "No namespace founds" unless namespace
|
@@ -15,6 +15,7 @@ module Pfab
|
|
15
15
|
'application' => application_yaml["name"],
|
16
16
|
'application_yaml' => application_yaml,
|
17
17
|
'namespace' => namespace,
|
18
|
+
'application_yaml_hash' => application_yaml_hash
|
18
19
|
}
|
19
20
|
end
|
20
21
|
|
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.54.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.54.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 = "2024-05-
|
14
|
+
s.date = "2024-05-15"
|
15
15
|
s.description = "k8s helper".freeze
|
16
16
|
s.email = "jdwyer@prefab.cloud".freeze
|
17
17
|
s.executables = ["pfab".freeze]
|
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.54.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: 2024-05-
|
11
|
+
date: 2024-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|