pfab 0.48.0 → 0.49.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1f48c3d9fcd1452e69dd15582ee9ba820e059c3af739b95798026ae36e1a0d0
4
- data.tar.gz: daee2b61dcb71d13ecfbcd9f3b5440dd5b7e2aca4a7a6226ecd7209956b30570
3
+ metadata.gz: 2f1a84c3c63d1db81cc363286650c690eab5759533679a74d0dc1849368204f6
4
+ data.tar.gz: fec0e7d30e078a426b4596ae0ea7dface693f5b4f994c9cd26c9e63eb9f9b086
5
5
  SHA512:
6
- metadata.gz: 64e704e41017b4c5eb47846d6444149c08124549d2b57d76c42ce6fb5e4bcb40fc08ce7d4b4b17335e9fc05a78ca3d4262823aba723e340b138eb276683026ce
7
- data.tar.gz: 9b5a22ccab3a869754c78b3458087e4a47007a5a69a3fc023b884f355765fe2a5de154b49bd2799672210dc5777aae8dc8d52a3ba236bda0a83cb545af0ced1a
6
+ metadata.gz: 644d664ff9952cc3f485b19b0c188f6b608547e9b42af3a2975392a0c80a83df6f6c754d637a023a725b0e2eec56d96334a0c0ee76d6bff409ca8feeef72deb2
7
+ data.tar.gz: 6c002bd38ff2975392daa54845aa2333a18e5fff14e0d1c51001415aae9724cca5eb7f00630c0e81e7b717c24f1273edc43cdd961a18359a6a7ca069ef3f9582
@@ -14,6 +14,7 @@ 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
+ f << StyledYAML.dump(pod_disruption_budget.deep_stringify_keys)
17
18
  end
18
19
  end
19
20
 
@@ -155,6 +156,70 @@ module Pfab
155
156
  "web"
156
157
  end
157
158
 
159
+ def pod_disruption_budget
160
+ pdb = {
161
+ apiVersion: "policy/v1",
162
+ kind: "PodDisruptionBudget",
163
+ metadata: {
164
+ name: "#{@data['deployed_name']}-pdb",
165
+ namespace: get_namespace()
166
+ },
167
+ spec: {
168
+ minAvailable: 1,
169
+ selector: {
170
+ matchLabels: {
171
+ application: @data['application'],
172
+ "deployed-name" => @data['deployed_name'],
173
+ "application-type" => application_type
174
+ }
175
+ }
176
+ }
177
+ }
178
+ return pdb
179
+ end
180
+ ANTI_AFFINITY_TYPES = %w[disabled required preferred]
181
+ ANTI_AFFINITY_MODE = 'antiAffinityMode'
182
+ ANTI_AFFINITY_PREFERRED_MODE_WEIGHT = 'antiAffinityPreferredModeWeight'
183
+
184
+ def anti_affinity
185
+ if app_vars.has_key?(ANTI_AFFINITY_MODE)
186
+ antiAffinityMode = app_vars[ANTI_AFFINITY_MODE]
187
+ affinitySelector = {
188
+ topologyKey: "kubernetes.io/hostname",
189
+ labelSelector: {
190
+ matchLabels: {
191
+ "deployed-name" => @data['deployed_name'],
192
+ },
193
+ },
194
+ }
195
+
196
+ return case antiAffinityMode
197
+ when "disabled"
198
+ puts "antiAffinityMode is set to disabled, skipping"
199
+ {}
200
+ when "required"
201
+ {
202
+ podAntiAffinity: {
203
+ requiredDuringSchedulingIgnoredDuringExecution: [
204
+ affinitySelector
205
+ ] } }
206
+ when "preferred"
207
+ { podAntiAffinity: {
208
+ preferredDuringSchedulingIgnoredDuringExecution: [
209
+ {
210
+ weight: app_vars[ANTI_AFFINITY_PREFERRED_MODE_WEIGHT] || 100,
211
+ podAffinityTerm: affinitySelector
212
+ }
213
+ ]
214
+ }
215
+ }
216
+ else
217
+ raise "Unexpected value #{antiAffinityMode} specified for `#{ANTI_AFFINITY_MODE}`. Valid selections are #{ANTI_AFFINITY_TYPES}"
218
+ end
219
+ end
220
+ return {}
221
+ end
222
+
158
223
  def deployment
159
224
  secret_mounts = get("secretMounts") || []
160
225
  volume_mounts = []
@@ -260,25 +325,12 @@ module Pfab
260
325
  volumeMounts: volume_mounts
261
326
  }.compact
262
327
  ],
263
- affinity: {
264
- podAntiAffinity: {
265
- requiredDuringSchedulingIgnoredDuringExecution: [
266
- {
267
- topologyKey: "kubernetes.io/hostname",
268
- labelSelector: {
269
- matchLabels: {
270
- "deployed-name" => @data['deployed_name'],
271
- },
272
- },
273
- }
274
- ]
275
- }
276
- },
328
+ affinity: anti_affinity,
277
329
  volumes: volumes
278
330
  }.compact,
279
331
  },
280
332
  }.compact,
281
- }
333
+ }.compact
282
334
  end
283
335
  end
284
336
  end
data/lib/pfab/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Pfab
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 48
4
+ MINOR = 49
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.48.0 ruby lib
5
+ # stub: pfab 0.49.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "pfab".freeze
9
- s.version = "0.48.0"
9
+ s.version = "0.49.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-02-15"
14
+ s.date = "2024-03-01"
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.48.0
4
+ version: 0.49.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-02-15 00:00:00.000000000 Z
11
+ date: 2024-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander