pfab 0.58.11 → 0.58.13

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: 00df54c67b4498f532bc8bc0a7c3d4d938b93e49bb029feb12f4ad34769db2b9
4
- data.tar.gz: '07888f8bfdec5736018b0cbaf9d4f8ecaee98748dc43d88414570ba14a21be72'
3
+ metadata.gz: a497cd33d42f67b9f5ee327df7b2bd1eb208108b963cdbc54d46b717823836fc
4
+ data.tar.gz: 455e633df3ddc4d7e6062886cf667788cda1d44cf7ae66c769ad8b77942d4536
5
5
  SHA512:
6
- metadata.gz: 5d83fbaa51cdacf123f9e88c2445b01d226459f7d6b279f2627758e632833a27db83bcfd8e3970a0ff3b1235918268e0aa1993c503b294d38d36b88936da2ec9
7
- data.tar.gz: 3374947912d66d19f18f01325f383c676eba0ae2f676ca9e73ae8609eb02513cc6d3a5cfb9dc783e4b84e708055671f1e0e5584d0905fa74953173aa3850401e
6
+ metadata.gz: adefb4f30b8860f3b575c09afa079bcba9af1b35f5008284b30ade91beff877d8f72021c40835dd657c0c21916be67bbe9c977c3b0c3400392449385cf56808d
7
+ data.tar.gz: 28c49bf1d80a83a1e503cf9d6c4d92dc31d206115f41655966396668a4c645f033fc942d1523d98969413dd95b4ca6d588b3de3d8fe0a3f687e9cc9c89f0f14f
data/lib/pfab/cli.rb CHANGED
@@ -85,6 +85,8 @@ module Pfab
85
85
  if success
86
86
  cmd_generate_yaml
87
87
  cmd_apply(timeout: options.timeout, retries: options.retries, sleep_duration: options.sleep, tagged: options.tagged)
88
+ else
89
+ raise "Build failed"
88
90
  end
89
91
  end
90
92
  end
@@ -474,9 +476,10 @@ module Pfab
474
476
 
475
477
  def get_app_name(all: false, include_run_locals: false)
476
478
  return $app_name unless $app_name.nil?
477
- apps = deployables.keys
478
- apps.concat(run_locals.keys) if include_run_locals
479
+ apps = []
479
480
  apps << "all" if all
481
+ apps.concat(deployables.keys)
482
+ apps.concat(run_locals.keys) if include_run_locals
480
483
  $app_name = choose("which app?", *apps)
481
484
  end
482
485
 
@@ -4,6 +4,12 @@ module Pfab
4
4
  LABEL_DEPLOY_UNIQUE_ID = "deploy-unique-id"
5
5
  module Templates
6
6
  class Web < LongRunningProcess
7
+
8
+ def get_replica_count
9
+ raw_replicas = get("replicas")
10
+ raw_replicas ? raw_replicas.to_i : 1
11
+ end
12
+
7
13
  def write_to(f)
8
14
  if ingres_enabled? && get("host").nil?
9
15
  puts "No host to configure ingress for #{@data['deployed_name']}. Skipping deployment. add a host or generateIngressEnabled:false"
@@ -15,8 +21,7 @@ module Pfab
15
21
  puts "skipping ingress because ingress_disabled = #{@data['generateIngressEnabled']}"
16
22
  end
17
23
  f << StyledYAML.dump(deployment.deep_stringify_keys)
18
- replica_count = get("replicas") ||1
19
- if (replica_count > 1)
24
+ if get_replica_count() > 1
20
25
  f << StyledYAML.dump(pod_disruption_budget.deep_stringify_keys)
21
26
  end
22
27
  end
@@ -166,21 +171,6 @@ module Pfab
166
171
  }
167
172
  return pdb
168
173
  end
169
- ANTI_AFFINITY_TYPES = %w[disabled required preferred]
170
- ANTI_AFFINITY_MODE = 'antiAffinityMode'
171
- ANTI_AFFINITY_PREFERRED_MODE_WEIGHT = 'antiAffinityPreferredModeWeight'
172
- ZONE_ANTI_AFFINITY_MODE = 'zoneAntiAffinityMode'
173
- ZONE_ANTI_AFFINITY_PREFERRED_MODE_WEIGHT = 'zoneAntiAffinityPreferredModeWeight'
174
-
175
-
176
- def anti_affinity
177
- return host_anti_affinity
178
- end
179
-
180
-
181
- def host_anti_affinity
182
- anti_affinity_builder(ANTI_AFFINITY_MODE, ANTI_AFFINITY_PREFERRED_MODE_WEIGHT, "kubernetes.io/hostname")
183
- end
184
174
 
185
175
 
186
176
  def topology_spread_constraints
@@ -227,40 +217,6 @@ module Pfab
227
217
  }
228
218
  end
229
219
 
230
- def anti_affinity_builder(key, weight_key, topology_key)
231
- antiAffinityMode = get(key) || "disabled"
232
- if antiAffinityMode
233
- affinitySelector = {
234
- topologyKey: topology_key,
235
- labelSelector: labelSelector,
236
- }
237
-
238
- return case antiAffinityMode
239
- when "disabled"
240
- puts "antiAffinityMode is set to disabled, skipping"
241
- {}
242
- when "required"
243
- {
244
- podAntiAffinity: {
245
- requiredDuringSchedulingIgnoredDuringExecution: [
246
- affinitySelector
247
- ] } }
248
- when "preferred"
249
- { podAntiAffinity: {
250
- preferredDuringSchedulingIgnoredDuringExecution: [
251
- {
252
- weight: app_vars[weight_key] || 100,
253
- podAffinityTerm: affinitySelector
254
- }
255
- ]
256
- }
257
- }
258
- else
259
- raise "Unexpected value #{antiAffinityMode} specified for `#{key}`. Valid selections are #{ANTI_AFFINITY_TYPES}"
260
- end
261
- end
262
- return {}
263
- end
264
220
 
265
221
  def deployment
266
222
  secret_mounts = get("secretMounts") || []
@@ -295,6 +251,7 @@ module Pfab
295
251
  end
296
252
  ports = container_ports()
297
253
 
254
+
298
255
  {
299
256
  kind: "Deployment",
300
257
  apiVersion: "apps/v1",
@@ -302,14 +259,14 @@ module Pfab
302
259
  name: @data['deployed_name'],
303
260
  namespace: get_namespace,
304
261
  labels: {
305
- application: @data['application'],
262
+ "application" => @data['application'],
306
263
  "deployed-name" => @data['deployed_name'],
307
264
  "application-type" => application_type,
308
265
  "deploy-id" => deploy_id,
309
- LABEL_DEPLOY_UNIQUE_ID: StyledYAML.double_quoted(deploy_unique_id),
310
- "tags.datadoghq.com/env": @data['env'],
311
- "tags.datadoghq.com/service": @data['deployed_name'],
312
- "tags.datadoghq.com/version": StyledYAML.double_quoted(@data['sha'])
266
+ LABEL_DEPLOY_UNIQUE_ID => StyledYAML.double_quoted(deploy_unique_id),
267
+ "tags.datadoghq.com/env" => @data['env'],
268
+ "tags.datadoghq.com/service" => @data['deployed_name'],
269
+ "tags.datadoghq.com/version" => StyledYAML.double_quoted(@data['sha'])
313
270
  }
314
271
  },
315
272
  spec: {
@@ -350,7 +307,7 @@ module Pfab
350
307
  volumeMounts: volume_mounts
351
308
  }.merge(probes()).compact
352
309
  ],
353
- topologySpreadConstraints: topology_spread_constraints,
310
+ topologySpreadConstraints: get_replica_count > 1 ? topology_spread_constraints : [],
354
311
  volumes: volumes
355
312
  }.compact,
356
313
  },
data/lib/pfab/version.rb CHANGED
@@ -2,7 +2,7 @@ module Pfab
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 58
5
- PATCH = 11
5
+ PATCH = 13
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
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.58.11 ruby lib
5
+ # stub: pfab 0.58.13 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "pfab".freeze
9
- s.version = "0.58.11"
9
+ s.version = "0.58.13"
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-12-16"
14
+ s.date = "2025-02-11"
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.58.11
4
+ version: 0.58.13
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-12-16 00:00:00.000000000 Z
11
+ date: 2025-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander