pfab 0.51.0 → 0.52.0
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 +57 -5
- data/lib/pfab/version.rb +1 -1
- data/pfab.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e19f6543864483d014f040e4d0ba5c2e8322bb20ca5604f351c13a36f53b20cd
|
4
|
+
data.tar.gz: 1d1afb9c39e0e6d69f5849bd171e2a659174ec747c601239c6e9cc051da92d6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c402604e6fd169342b2aff975ecb79b15b59cf67399c91a57c15597df3b7629d0a0eb84c5df14e784c09ca4612fafdad60e620bae52a76f1da269030c05d9fa4
|
7
|
+
data.tar.gz: 569c405d1a4be90a456ef7dbb8f5e3cadf842b475644dbb79e85fc6d2765dc557e75b147dba2c58ae88c67ef37d0cab5f45bf9c000983ccb69535597c1a42d40
|
data/lib/pfab/templates/web.rb
CHANGED
@@ -180,12 +180,64 @@ module Pfab
|
|
180
180
|
ANTI_AFFINITY_TYPES = %w[disabled required preferred]
|
181
181
|
ANTI_AFFINITY_MODE = 'antiAffinityMode'
|
182
182
|
ANTI_AFFINITY_PREFERRED_MODE_WEIGHT = 'antiAffinityPreferredModeWeight'
|
183
|
+
ZONE_ANTI_AFFINITY_MODE = 'zoneAntiAffinityMode'
|
184
|
+
ZONE_ANTI_AFFINITY_PREFERRED_MODE_WEIGHT = 'zoneAntiAffinityPreferredModeWeight'
|
185
|
+
|
183
186
|
|
184
187
|
def anti_affinity
|
185
|
-
|
186
|
-
|
188
|
+
p = host_anti_affinity
|
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
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
def host_anti_affinity
|
199
|
+
anti_affinity_builder(ANTI_AFFINITY_MODE, ANTI_AFFINITY_PREFERRED_MODE_WEIGHT, "kubernetes.io/hostname")
|
200
|
+
end
|
201
|
+
|
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
|
+
|
206
|
+
def merge_anti_affinity(pod_anti_affinity, zone_anti_affinity)
|
207
|
+
merged = {}
|
208
|
+
|
209
|
+
if pod_anti_affinity.empty? && zone_anti_affinity.empty?
|
210
|
+
merged = {}
|
211
|
+
elsif pod_anti_affinity.empty?
|
212
|
+
merged = zone_anti_affinity
|
213
|
+
elsif zone_anti_affinity.empty?
|
214
|
+
merged = pod_anti_affinity
|
215
|
+
else
|
216
|
+
merged[:podAntiAffinity] = {}
|
217
|
+
|
218
|
+
required_key = :requiredDuringSchedulingIgnoredDuringExecution
|
219
|
+
preferred_key = :preferredDuringSchedulingIgnoredDuringExecution
|
220
|
+
|
221
|
+
[required_key, preferred_key].each do |key|
|
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
|
231
|
+
|
232
|
+
merged
|
233
|
+
end
|
234
|
+
|
235
|
+
|
236
|
+
def anti_affinity_builder(key, weight_key, topology_key)
|
237
|
+
antiAffinityMode = get(key) || "disabled"
|
238
|
+
if antiAffinityMode
|
187
239
|
affinitySelector = {
|
188
|
-
topologyKey:
|
240
|
+
topologyKey: topology_key,
|
189
241
|
labelSelector: {
|
190
242
|
matchLabels: {
|
191
243
|
"deployed-name" => @data['deployed_name'],
|
@@ -207,14 +259,14 @@ module Pfab
|
|
207
259
|
{ podAntiAffinity: {
|
208
260
|
preferredDuringSchedulingIgnoredDuringExecution: [
|
209
261
|
{
|
210
|
-
weight: app_vars[
|
262
|
+
weight: app_vars[weight_key] || 100,
|
211
263
|
podAffinityTerm: affinitySelector
|
212
264
|
}
|
213
265
|
]
|
214
266
|
}
|
215
267
|
}
|
216
268
|
else
|
217
|
-
raise "Unexpected value #{antiAffinityMode} specified for `#{
|
269
|
+
raise "Unexpected value #{antiAffinityMode} specified for `#{key}`. Valid selections are #{ANTI_AFFINITY_TYPES}"
|
218
270
|
end
|
219
271
|
end
|
220
272
|
return {}
|
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.52.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.52.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]
|