pfab 0.53.0 → 0.54.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06aa820e3141930ca45a670075b6824a23010f5f3568aa3c81edd1825ea452c2
4
- data.tar.gz: 9d43a1c6d16ac3e44f057817fa50f0143d7e3ce6d9b9ca0446735ae060144dfe
3
+ metadata.gz: f6db80ed30cdab582adbf60a44b1cb80ffb32420898d07117b5e0fe81f0012ac
4
+ data.tar.gz: 818d93a741088cee1a7988273e6eb3389c013fee43227193d086f9cdaa8c01ba
5
5
  SHA512:
6
- metadata.gz: 9e42f6a07719549799f99885888d33218dd69b0211e07ea7d927bf22b4d6d39984a4d246aa7f1c99afa8ccdd273eb2d96292363cb167b0a7c1c09e7ecff73464
7
- data.tar.gz: 655b9ecb7007a4c19e27591a6edbe2acefcbce8a374ade1b1fb2e97985089503ae875d156cf269d969984f02e1dc148ca1e86a7702c444aab8e5b33fd65bc288
6
+ metadata.gz: f53b2f212245784bd4d518c7058aa7a2bdad7c2bba7b4a1c956f86356e037ff429ec704c1f7210969ac05e2bfbc05e2273e7961cee9028941e0361d85aaaa618
7
+ data.tar.gz: 2d1e0b3cd52341158feea24b3f184b5ccd53c1dd1951b37b4cdcbed9d54d5e023c7bd772e27a7f86828f56ad86ccf1187c7ed7596a79acc5efc6457d525199cd
@@ -187,10 +187,7 @@ module Pfab
187
187
 
188
188
 
189
189
  def anti_affinity
190
- p = host_anti_affinity
191
- z = zone_anti_affinity
192
- m = merge_anti_affinity(p, z)
193
- return m
190
+ return host_anti_affinity
194
191
  end
195
192
 
196
193
 
@@ -198,63 +195,57 @@ module Pfab
198
195
  anti_affinity_builder(ANTI_AFFINITY_MODE, ANTI_AFFINITY_PREFERRED_MODE_WEIGHT, "kubernetes.io/hostname")
199
196
  end
200
197
 
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
198
 
205
- def merge_anti_affinity(pod_anti_affinity, zone_anti_affinity)
206
- merged = {}
199
+ def topology_spread_constraints
200
+ waiveTopologySpreadConstraints = get("waiveTopologySpreadConstraints") || false
207
201
 
208
- if pod_anti_affinity.empty? && zone_anti_affinity.empty?
209
- merged = {}
210
- elsif pod_anti_affinity.empty?
211
- merged = zone_anti_affinity
212
- elsif zone_anti_affinity.empty?
213
- merged = pod_anti_affinity
214
- else
215
- merged[:podAntiAffinity] = {}
216
-
217
- required_key = :requiredDuringSchedulingIgnoredDuringExecution
218
- preferred_key = :preferredDuringSchedulingIgnoredDuringExecution
219
-
220
- [required_key, preferred_key].each do |key|
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
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
230
215
 
231
- merged
216
+ }
217
+ [zone_constraint, host_constraint]
232
218
  end
233
219
 
234
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
+
235
243
  def anti_affinity_builder(key, weight_key, topology_key)
236
244
  antiAffinityMode = get(key) || "disabled"
237
245
  if antiAffinityMode
238
246
  affinitySelector = {
239
247
  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
- },
248
+ labelSelector: labelSelector,
258
249
  }
259
250
 
260
251
  return case antiAffinityMode
@@ -381,7 +372,7 @@ module Pfab
381
372
  volumeMounts: volume_mounts
382
373
  }.compact
383
374
  ],
384
- affinity: anti_affinity,
375
+ topologySpreadConstraints: topology_spread_constraints,
385
376
  volumes: volumes
386
377
  }.compact,
387
378
  },
data/lib/pfab/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Pfab
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 53
4
+ MINOR = 54
5
5
  PATCH = 0
6
6
  BUILD = nil
7
7
 
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.53.0 ruby lib
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.53.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"
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.53.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-14 00:00:00.000000000 Z
11
+ date: 2024-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander