pfab 0.50.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/cli.rb +6 -4
- data/lib/pfab/templates/web.rb +57 -5
- data/lib/pfab/version.rb +1 -1
- 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: 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/cli.rb
CHANGED
@@ -106,18 +106,20 @@ module Pfab
|
|
106
106
|
|
107
107
|
command :exec do |c|
|
108
108
|
c.option "-c", "--command command", "use with exec to run a command and exit. default is /bin/sh"
|
109
|
-
c.syntax = "pfab exec"
|
109
|
+
c.syntax = "pfab exec [-- command to execute]'"
|
110
110
|
c.summary = "kubectl exec into a pod"
|
111
111
|
c.description = "CLI to the Cloud"
|
112
112
|
c.example "exec into the first pod in staging",
|
113
|
-
"pfab exec"
|
113
|
+
"pfab -e staging exec"
|
114
114
|
c.example "exec into the first pod in production",
|
115
|
-
"
|
115
|
+
"pfab -p exec"
|
116
116
|
c.action do |args, options|
|
117
117
|
set_kube_context
|
118
|
+
# Access the command line input after "--"
|
119
|
+
additional_args = ARGV[ARGV.index('--') + 1..-1] if ARGV.include?('--')
|
118
120
|
app_name = get_app_name
|
119
121
|
first_pod = get_first_pod app_name
|
120
|
-
kubectl "exec -it #{first_pod}", "-- #{options.command || '/bin/sh'}"
|
122
|
+
kubectl "exec -it #{first_pod}", "-- #{additional_args.join(" ") || options.command || '/bin/sh'}"
|
121
123
|
end
|
122
124
|
end
|
123
125
|
|
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,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.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]
|
13
13
|
s.authors = ["Jeff Dwyer".freeze]
|
14
|
-
s.date = "2024-05-
|
14
|
+
s.date = "2024-05-13"
|
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.52.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-
|
11
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|