pfab 0.53.0 → 0.54.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pfab/templates/web.rb +45 -53
- data/lib/pfab/version.rb +2 -2
- 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: 76cf1e72c2d80c355fdcd4d6a1d4029966302d885106239d4f440b02cd1ecec0
|
4
|
+
data.tar.gz: a89e2b49a230499c16dfacd205b9a025529a72f99bd9d89d0e143d7d90fdbce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8250a9a5c42ebdfb55d22c076c4a6be32a1c2596b720b2e77e60b35c86e92879116df789cdda86571e26ce2a0f2e9c1b3da7f4c4bc1edfa60ee81bb8115bc1e
|
7
|
+
data.tar.gz: c1517c24b3d9cde49f77a65b02084b3e200869d529c4c08753378761cb5466ef7ceda829438d65d29cd30718183d7bd4a3fd8fc73684e238167286dc0e88e0f2
|
data/lib/pfab/templates/web.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "rubygems/safe_yaml"
|
2
2
|
|
3
3
|
module Pfab
|
4
|
+
LABEL_DEPLOY_UNIQUE_ID = "deploy-unique-id"
|
4
5
|
module Templates
|
5
6
|
class Web < Base
|
6
7
|
def write_to(f)
|
@@ -187,10 +188,7 @@ module Pfab
|
|
187
188
|
|
188
189
|
|
189
190
|
def anti_affinity
|
190
|
-
|
191
|
-
z = zone_anti_affinity
|
192
|
-
m = merge_anti_affinity(p, z)
|
193
|
-
return m
|
191
|
+
return host_anti_affinity
|
194
192
|
end
|
195
193
|
|
196
194
|
|
@@ -198,63 +196,57 @@ module Pfab
|
|
198
196
|
anti_affinity_builder(ANTI_AFFINITY_MODE, ANTI_AFFINITY_PREFERRED_MODE_WEIGHT, "kubernetes.io/hostname")
|
199
197
|
end
|
200
198
|
|
201
|
-
def zone_anti_affinity
|
202
|
-
anti_affinity_builder(ZONE_ANTI_AFFINITY_MODE, ZONE_ANTI_AFFINITY_PREFERRED_MODE_WEIGHT, "topology.kubernetes.io/zone")
|
203
|
-
end
|
204
199
|
|
205
|
-
def
|
206
|
-
|
200
|
+
def topology_spread_constraints
|
201
|
+
waiveTopologySpreadConstraints = get("waiveTopologySpreadConstraints") || false
|
207
202
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
if pod_anti_affinity.dig(:podAntiAffinity, key) && zone_anti_affinity.dig(:podAntiAffinity, key)
|
222
|
-
merged[:podAntiAffinity][key] = pod_anti_affinity[:podAntiAffinity][key] + zone_anti_affinity[:podAntiAffinity][key]
|
223
|
-
elsif pod_anti_affinity.dig(:podAntiAffinity, key)
|
224
|
-
merged[:podAntiAffinity][key] = pod_anti_affinity[:podAntiAffinity][key]
|
225
|
-
elsif zone_anti_affinity.dig(:podAntiAffinity, key)
|
226
|
-
merged[:podAntiAffinity][key] = zone_anti_affinity[:podAntiAffinity][key]
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
203
|
+
schedulingRule = waiveTopologySpreadConstraints ? "ScheduleAnyway" : "DoNotSchedule"
|
204
|
+
|
205
|
+
zone_constraint = {
|
206
|
+
maxSkew: 1,
|
207
|
+
topologyKey: "topology.kubernetes.io/zone",
|
208
|
+
whenUnsatisfiable: schedulingRule,
|
209
|
+
labelSelector: labelSelector
|
210
|
+
}
|
211
|
+
host_constraint = {
|
212
|
+
maxSkew: 1,
|
213
|
+
topologyKey: "kubernetes.io/hostname",
|
214
|
+
whenUnsatisfiable: schedulingRule,
|
215
|
+
labelSelector: labelSelector
|
230
216
|
|
231
|
-
|
217
|
+
}
|
218
|
+
[zone_constraint, host_constraint]
|
232
219
|
end
|
233
220
|
|
234
221
|
|
222
|
+
|
223
|
+
def labelSelector
|
224
|
+
{
|
225
|
+
matchExpressions: [
|
226
|
+
{
|
227
|
+
key: "deployed-name",
|
228
|
+
operator: "In",
|
229
|
+
values: [
|
230
|
+
@data['deployed_name']
|
231
|
+
]
|
232
|
+
},
|
233
|
+
{
|
234
|
+
key: LABEL_DEPLOY_UNIQUE_ID,
|
235
|
+
operator: "In",
|
236
|
+
values: [
|
237
|
+
StyledYAML.double_quoted(deploy_unique_id)
|
238
|
+
]
|
239
|
+
}
|
240
|
+
]
|
241
|
+
}
|
242
|
+
end
|
243
|
+
|
235
244
|
def anti_affinity_builder(key, weight_key, topology_key)
|
236
245
|
antiAffinityMode = get(key) || "disabled"
|
237
246
|
if antiAffinityMode
|
238
247
|
affinitySelector = {
|
239
248
|
topologyKey: topology_key,
|
240
|
-
labelSelector:
|
241
|
-
matchExpressions: [
|
242
|
-
{
|
243
|
-
key: "deployed-name",
|
244
|
-
operator: "In",
|
245
|
-
values: [
|
246
|
-
@data['deployed_name']
|
247
|
-
]
|
248
|
-
},
|
249
|
-
{
|
250
|
-
key: "deployment-unique-id",
|
251
|
-
operator: "In",
|
252
|
-
values: [
|
253
|
-
StyledYAML.double_quoted(deploy_unique_id)
|
254
|
-
]
|
255
|
-
}
|
256
|
-
]
|
257
|
-
},
|
249
|
+
labelSelector: labelSelector,
|
258
250
|
}
|
259
251
|
|
260
252
|
return case antiAffinityMode
|
@@ -328,7 +320,7 @@ module Pfab
|
|
328
320
|
"deployed-name" => @data['deployed_name'],
|
329
321
|
"application-type" => application_type,
|
330
322
|
"deploy-id" => deploy_id,
|
331
|
-
|
323
|
+
LABEL_DEPLOY_UNIQUE_ID: StyledYAML.double_quoted(deploy_unique_id),
|
332
324
|
"tags.datadoghq.com/env": @data['env'],
|
333
325
|
"tags.datadoghq.com/service": @data['deployed_name'],
|
334
326
|
"tags.datadoghq.com/version": StyledYAML.double_quoted(@data['sha'])
|
@@ -356,7 +348,7 @@ module Pfab
|
|
356
348
|
application: @data['application'],
|
357
349
|
"deployed-name" => @data['deployed_name'],
|
358
350
|
"application-type" => "web",
|
359
|
-
|
351
|
+
LABEL_DEPLOY_UNIQUE_ID => StyledYAML.double_quoted(deploy_unique_id),
|
360
352
|
"tags.datadoghq.com/env": @data['env'],
|
361
353
|
"tags.datadoghq.com/service": @data['deployed_name'],
|
362
354
|
"tags.datadoghq.com/version": StyledYAML.double_quoted(@data['sha'])
|
@@ -381,7 +373,7 @@ module Pfab
|
|
381
373
|
volumeMounts: volume_mounts
|
382
374
|
}.compact
|
383
375
|
],
|
384
|
-
|
376
|
+
topologySpreadConstraints: topology_spread_constraints,
|
385
377
|
volumes: volumes
|
386
378
|
}.compact,
|
387
379
|
},
|
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.54.1 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.1"
|
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.1
|
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
|