pfab 0.11.0 → 0.15.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: 86a0173094dded1e5b572b11593274b17abcfa2f29e7aac04977918af2d5674c
4
- data.tar.gz: 3e189a70dc5126e40f8e81e13f84872964e35b06561251c6e260efa42a517de2
3
+ metadata.gz: f44e4e52088b70f22abb23eadd83fcc6aaeb2425ff364f09e575bf4f129836a2
4
+ data.tar.gz: 345422cee58debfccf961a6658f48064735d045446ce671685313a17abe4290c
5
5
  SHA512:
6
- metadata.gz: '09b0ce9accab6e86643d1dff636a84c0b6aa077d1309ff82867fa3e7125255bdb60fa2639a74766d2575b239ea8cb8933ec7ac94f6659d0ce55336aca59704d0'
7
- data.tar.gz: 67427d6c7818d428945a36736cb45ac024967ccacd189087a3146f2458f85e12316e2e9e7497c1801d65bbae70055480c8e7a22a30f9aeb2d190f3a998456446
6
+ metadata.gz: 0e3fba3155e96609eea6edb3483a2a4980aacfbbb05df8cb2f5f6ef10b1ff31bb02563ed0e03e960c7c593f93590239e381352ba612c0e79279770bc841c0e49
7
+ data.tar.gz: 6bb77697b5a49f4e13aadc08b48b64c8529a7864a68c3f7f8758493e2371743e30a6cc294660038651624e7d271783670c1a58e6bad1dde09c9f91f8951a787c
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.6.9
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ gem "pry-byebug"
12
12
  group :development do
13
13
  gem "rdoc", "~> 3.12"
14
14
  gem "bundler", "~> 1.0"
15
- gem "juwelier", "~> 2.4.9"
15
+ gem "juwelier", "~> 2.4.9", git: "https://github.com/flajann2/juwelier"
16
16
  gem "simplecov", ">= 0"
17
17
  gem "test-unit", ">= 0"
18
18
  end
data/Gemfile.lock CHANGED
@@ -1,3 +1,20 @@
1
+ GIT
2
+ remote: https://github.com/flajann2/juwelier
3
+ revision: de59d5a2ddea00c1f18957ab62129c1c141acce1
4
+ specs:
5
+ juwelier (2.4.9)
6
+ builder
7
+ bundler
8
+ git
9
+ github_api
10
+ highline
11
+ kamelcase (~> 0)
12
+ nokogiri
13
+ psych
14
+ rake
15
+ rdoc
16
+ semver2
17
+
1
18
  GEM
2
19
  remote: https://rubygems.org/
3
20
  specs:
@@ -6,7 +23,7 @@ GEM
6
23
  i18n (>= 0.7, < 2)
7
24
  minitest (~> 5.1)
8
25
  tzinfo (~> 1.1)
9
- addressable (2.7.0)
26
+ addressable (2.8.0)
10
27
  public_suffix (>= 2.0.2, < 5.0)
11
28
  builder (3.2.4)
12
29
  byebug (10.0.2)
@@ -17,12 +34,26 @@ GEM
17
34
  descendants_tracker (0.0.4)
18
35
  thread_safe (~> 0.3, >= 0.3.1)
19
36
  docile (1.3.1)
20
- faraday (1.3.0)
37
+ faraday (1.8.0)
38
+ faraday-em_http (~> 1.0)
39
+ faraday-em_synchrony (~> 1.0)
40
+ faraday-excon (~> 1.1)
41
+ faraday-httpclient (~> 1.0.1)
21
42
  faraday-net_http (~> 1.0)
43
+ faraday-net_http_persistent (~> 1.1)
44
+ faraday-patron (~> 1.0)
45
+ faraday-rack (~> 1.0)
22
46
  multipart-post (>= 1.2, < 3)
23
- ruby2_keywords
47
+ ruby2_keywords (>= 0.0.4)
48
+ faraday-em_http (1.0.0)
49
+ faraday-em_synchrony (1.0.0)
50
+ faraday-excon (1.1.0)
51
+ faraday-httpclient (1.0.1)
24
52
  faraday-net_http (1.0.1)
25
- git (1.8.1)
53
+ faraday-net_http_persistent (1.2.0)
54
+ faraday-patron (1.0.0)
55
+ faraday-rack (1.0.0)
56
+ git (1.9.1)
26
57
  rchardet (~> 1.8)
27
58
  github_api (0.19.0)
28
59
  addressable (~> 2.4)
@@ -35,31 +66,19 @@ GEM
35
66
  i18n (1.2.0)
36
67
  concurrent-ruby (~> 1.0)
37
68
  json (1.8.6)
38
- juwelier (2.4.9)
39
- builder
40
- bundler
41
- git
42
- github_api
43
- highline
44
- kamelcase (~> 0)
45
- nokogiri
46
- psych
47
- rake
48
- rdoc
49
- semver2
50
- jwt (2.2.2)
69
+ jwt (2.3.0)
51
70
  kamelcase (0.0.2)
52
71
  semver2 (~> 3)
53
72
  method_source (0.9.2)
54
- mini_portile2 (2.5.0)
73
+ mini_portile2 (2.6.1)
55
74
  minitest (5.11.3)
56
75
  multi_json (1.15.0)
57
76
  multi_xml (0.6.0)
58
77
  multipart-post (2.1.1)
59
- nokogiri (1.11.2)
60
- mini_portile2 (~> 2.5.0)
78
+ nokogiri (1.12.5)
79
+ mini_portile2 (~> 2.6.1)
61
80
  racc (~> 1.4)
62
- oauth2 (1.4.4)
81
+ oauth2 (1.4.7)
63
82
  faraday (>= 0.8, < 2.0)
64
83
  jwt (>= 1.0, < 3.0)
65
84
  multi_json (~> 1.3)
@@ -72,15 +91,15 @@ GEM
72
91
  pry-byebug (3.6.0)
73
92
  byebug (~> 10.0)
74
93
  pry (~> 0.10)
75
- psych (3.3.1)
94
+ psych (4.0.2)
76
95
  public_suffix (4.0.6)
77
- racc (1.5.2)
96
+ racc (1.6.0)
78
97
  rack (2.2.3)
79
- rake (13.0.3)
98
+ rake (13.0.6)
80
99
  rchardet (1.8.0)
81
100
  rdoc (3.12.2)
82
101
  json (~> 1.4)
83
- ruby2_keywords (0.0.4)
102
+ ruby2_keywords (0.0.5)
84
103
  semver2 (3.4.2)
85
104
  simplecov (0.16.1)
86
105
  docile (~> 1.1)
@@ -100,11 +119,11 @@ DEPENDENCIES
100
119
  activesupport
101
120
  bundler (~> 1.0)
102
121
  commander
103
- juwelier (~> 2.4.9)
122
+ juwelier (~> 2.4.9)!
104
123
  pry-byebug
105
124
  rdoc (~> 3.12)
106
125
  simplecov
107
126
  test-unit
108
127
 
109
128
  BUNDLED WITH
110
- 1.16.6
129
+ 1.17.2
data/README.markdown CHANGED
@@ -40,6 +40,7 @@ deployables:
40
40
  type: web
41
41
  port: 8443
42
42
  protocol: h2c # tell traefik this is going to be http2
43
+ tls_cert_secret: my-tls-secret
43
44
  command: java -Xmx550m -javaagent:/app/dd-java-agent.jar -jar myjar.jar server /app/grpc.yml
44
45
  readinessProbe:
45
46
  exec:
@@ -100,12 +101,25 @@ Contributing to pfab
100
101
  is fine, but please isolate to its own commit so I can cherry-pick
101
102
  around it.
102
103
 
104
+ Local Testing
105
+ -----------------------------------------
106
+ ```bash
107
+ bundle exec rake build
108
+ gem install --local pkg/pfab-0.11.0.gem
109
+ ```
110
+ ```ruby
111
+ gem 'pfab', :path => "../pfab"
112
+ ```
113
+
103
114
  Releasing
104
115
  -----------------------------------------
105
116
 
106
117
  - modify version.rb
107
- - ```rake gemspec:release```
108
- - ```rake gemcutter:release```
118
+ - ```bundle exec rake gemspec```
119
+ - ```git commit ```
120
+ - ```bundle exec rake git:release```
121
+ - ```bundle exec rake build```
122
+ - ```gem push pkg/pfab-0.12.0.gem```
109
123
 
110
124
  Copyright
111
125
  ---------
data/lib/pfab/cli.rb CHANGED
@@ -27,8 +27,6 @@ module Pfab
27
27
  $app_name = app_name
28
28
  end
29
29
 
30
- @apps = apps
31
-
32
30
  command :build do |c|
33
31
  c.syntax = "pfab build"
34
32
  c.summary = "build image"
@@ -142,14 +140,14 @@ module Pfab
142
140
  c.option "-c", "--command COMMAND", "Run a command with the ENV vars of the selected app"
143
141
  c.action do |_args, options|
144
142
  $env = :development
145
- app_name = get_app_name
143
+ app_name = get_app_name(include_run_locals: true)
146
144
  puts "RUNNING THE FOLLOWING LOCALLY"
147
145
 
148
146
  env_vars = yy.env_vars(app_name).
149
147
  reject { |v| v.has_key? :valueFrom }
150
148
 
151
149
  env_var_string = env_vars.map { |item| "#{item[:name]}=\"#{item[:value]}\"" }.join(" ")
152
- options.default command: @apps[app_name][:command]
150
+ options.default command: all_runnables[app_name][:command]
153
151
 
154
152
  puts_and_system "#{env_var_string} #{options.command}"
155
153
  end
@@ -182,11 +180,10 @@ module Pfab
182
180
  run!
183
181
  end
184
182
 
185
-
186
183
  def cmd_apply
187
184
  set_kube_context
188
185
  get_apps.each do |app_name|
189
- app = @apps[app_name]
186
+ app = deployables[app_name]
190
187
  if app[:deployable_type] == "cron"
191
188
  deployed_name = deployed_name(app)
192
189
  puts_and_system("kubectl delete cronjob -l deployed-name=#{deployed_name}")
@@ -237,7 +234,7 @@ module Pfab
237
234
  end
238
235
  end
239
236
 
240
- puts_and_system "docker build -t #{image_name} ."
237
+ puts_and_system "docker build -t #{image_name} --platform amd64 ."
241
238
 
242
239
  puts_and_system "docker tag #{image_name}:latest #{image_name}:#{rev}"
243
240
  puts_and_system "docker tag #{image_name}:#{rev} #{full_image_name}"
@@ -247,7 +244,7 @@ module Pfab
247
244
  end
248
245
 
249
246
  def yy
250
- Pfab::Yamls.new(apps: @apps,
247
+ Pfab::Yamls.new(apps: all_runnables,
251
248
  application_yaml: @application_yaml,
252
249
  env: $env,
253
250
  sha: get_current_sha,
@@ -257,7 +254,7 @@ module Pfab
257
254
  end
258
255
 
259
256
  def cmd_generate_yaml
260
- wrote = yy.generate_all
257
+ wrote = yy.generate(deployables.keys)
261
258
  puts "Generated #{wrote}"
262
259
  end
263
260
 
@@ -295,14 +292,22 @@ module Pfab
295
292
  end
296
293
  end
297
294
 
298
- def apps
299
- @_apps ||= calculate_apps
295
+ def deployables
296
+ @_deployables ||= calculate_runnables("deployables")
297
+ end
298
+
299
+ def run_locals
300
+ @_rl ||= calculate_runnables("run_locals")
301
+ end
302
+
303
+ def all_runnables
304
+ deployables.merge(run_locals)
300
305
  end
301
306
 
302
- def calculate_apps
307
+ def calculate_runnables(runnable_type)
303
308
  application = @application_yaml["name"]
304
309
  apps = {}
305
- @application_yaml["deployables"].each do |deployable, dep|
310
+ (@application_yaml[runnable_type] || []).each do |deployable, dep|
306
311
  deployable_type = dep["type"]
307
312
  app_name = [application, deployable_type, deployable].join("-")
308
313
  apps[app_name] = {
@@ -329,16 +334,17 @@ module Pfab
329
334
  JSON.parse(pods_str)
330
335
  end
331
336
 
332
- def get_app_name(all: false)
337
+ def get_app_name(all: false, include_run_locals: false)
333
338
  return $app_name unless $app_name.nil?
334
- apps = @apps.keys
339
+ apps = deployables.keys
340
+ apps.concat(run_locals.keys) if include_run_locals
335
341
  apps << "all" if all
336
342
  $app_name = choose("which app?", *apps)
337
343
  end
338
344
 
339
345
  def get_apps
340
346
  name = get_app_name(all: true)
341
- (name == "all") ? @apps.keys : [name]
347
+ (name == "all") ? deployables.keys : [name]
342
348
  end
343
349
  end
344
350
  end
@@ -43,7 +43,7 @@ module Pfab
43
43
  end
44
44
 
45
45
  def env_vars
46
- env_vars = { "DEPLOYED_NAME": { value: @data['deployed_name'] } }
46
+ env_vars = { "DEPLOYED_NAME" => { value: @data['deployed_name'] } }
47
47
 
48
48
  # load defaults
49
49
  load_env_vars(env_vars, @data.dig("application_yaml", :environment))
@@ -2,9 +2,13 @@ module Pfab
2
2
  module Templates
3
3
  class Web < Base
4
4
  def write_to(f)
5
- f << YAML.dump(service.deep_stringify_keys)
6
- f << YAML.dump(ingress.deep_stringify_keys)
7
- f << YAML.dump(deployment.deep_stringify_keys)
5
+ if get("host").nil?
6
+ puts "No host to deploy to for #{@data['deployed_name']}. Skipping."
7
+ else
8
+ f << YAML.dump(service.deep_stringify_keys)
9
+ f << YAML.dump(ingress.deep_stringify_keys)
10
+ f << YAML.dump(deployment.deep_stringify_keys)
11
+ end
8
12
  end
9
13
 
10
14
  def service
@@ -49,12 +53,25 @@ module Pfab
49
53
  },
50
54
  spec: {
51
55
  rules: rules,
56
+ tls: tls_hosts
52
57
  },
53
58
  }
54
59
  end
55
60
 
61
+ def tls_hosts
62
+ hosts.map do |host|
63
+ {
64
+ hosts: [host],
65
+ secretName: get("tls_cert_secret")
66
+ }
67
+ end
68
+ end
69
+
70
+ def hosts
71
+ get("host").split(",")
72
+ end
73
+
56
74
  def rules
57
- hosts = get("host").split(",")
58
75
  hosts.map do |host|
59
76
  {
60
77
  host: host,
@@ -62,9 +79,14 @@ module Pfab
62
79
  paths: [
63
80
  {
64
81
  path: "/",
82
+ pathType: "Prefix",
65
83
  backend: {
66
- serviceName: @data['deployed_name'],
67
- servicePort: "http",
84
+ service: {
85
+ name: @data['deployed_name'],
86
+ port: {
87
+ name: "http"
88
+ }
89
+ }
68
90
  },
69
91
  },
70
92
  ],
@@ -82,6 +104,8 @@ module Pfab
82
104
  "traefik.protocol" => get("protocol") || "http",
83
105
  "traefik.frontend.headers.SSLRedirect" => "true",
84
106
  "traefik.docker.network" => "traefik",
107
+ "traefik.ingress.kubernetes.io/router.entrypoints" => "websecure",
108
+ "traefik.ingress.kubernetes.io/router.tls" => "true"
85
109
  }
86
110
  h["ingress.kubernetes.io/protocol"] = "h2c" if get("protocol") == "h2c"
87
111
  h
data/lib/pfab/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Pfab
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 11
4
+ MINOR = 15
5
5
  PATCH = 0
6
6
  BUILD = nil
7
7
 
data/lib/pfab/yamls.rb CHANGED
@@ -27,13 +27,13 @@ module Pfab
27
27
  data
28
28
  end
29
29
 
30
- def generate_all
30
+ def generate(keys)
31
31
 
32
- @apps.map do |app, props|
32
+ keys.each do |key|
33
+ props = @apps[key]
34
+ data = data_for(key, props)
33
35
 
34
- data = data_for(app, props)
35
-
36
- filename = ".application-k8s-#{data["env"]}-#{app}.yaml"
36
+ filename = ".application-k8s-#{data["env"]}-#{key}.yaml"
37
37
  File.open(filename, "w") do |f|
38
38
  case props[:deployable_type]
39
39
  when "web" then
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.11.0 ruby lib
5
+ # stub: pfab 0.15.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "pfab".freeze
9
- s.version = "0.11.0"
9
+ s.version = "0.15.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 = "2021-11-30"
14
+ s.date = "2022-01-18"
15
15
  s.description = "k8s helper".freeze
16
16
  s.email = "jdwyer@prefab.cloud".freeze
17
17
  s.executables = ["pfab".freeze]
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  ]
22
22
  s.files = [
23
23
  ".document",
24
- ".ruby-version",
24
+ ".tool-versions",
25
25
  "Gemfile",
26
26
  "Gemfile.lock",
27
27
  "LICENSE.txt",
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
43
43
  ]
44
44
  s.homepage = "http://github.com/prefab-cloud/pfab".freeze
45
45
  s.licenses = ["MIT".freeze]
46
- s.rubygems_version = "2.7.8".freeze
46
+ s.rubygems_version = "3.0.3.1".freeze
47
47
  s.summary = "helper gem".freeze
48
48
 
49
49
  if s.respond_to? :specification_version then
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.11.0
4
+ version: 0.15.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: 2021-11-30 00:00:00.000000000 Z
11
+ date: 2022-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -132,7 +132,7 @@ extra_rdoc_files:
132
132
  - README.markdown
133
133
  files:
134
134
  - ".document"
135
- - ".ruby-version"
135
+ - ".tool-versions"
136
136
  - Gemfile
137
137
  - Gemfile.lock
138
138
  - LICENSE.txt
@@ -170,8 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  - !ruby/object:Gem::Version
171
171
  version: '0'
172
172
  requirements: []
173
- rubyforge_project:
174
- rubygems_version: 2.7.8
173
+ rubygems_version: 3.0.3.1
175
174
  signing_key:
176
175
  specification_version: 4
177
176
  summary: helper gem
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.5.3