kuby-core 0.8.0 → 0.10.1

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.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -0
  3. data/Gemfile +1 -0
  4. data/README.md +11 -1
  5. data/bin/kuby +4 -0
  6. data/kuby-core.gemspec +5 -2
  7. data/lib/kuby.rb +55 -18
  8. data/lib/kuby/basic_logger.rb +13 -0
  9. data/lib/kuby/cli_base.rb +125 -4
  10. data/lib/kuby/commands.rb +244 -0
  11. data/lib/kuby/definition.rb +1 -3
  12. data/lib/kuby/dev_setup.rb +255 -0
  13. data/lib/kuby/docker.rb +1 -0
  14. data/lib/kuby/docker/bundler_phase.rb +3 -3
  15. data/lib/kuby/docker/cli.rb +24 -1
  16. data/lib/kuby/docker/dev_spec.rb +131 -0
  17. data/lib/kuby/docker/dockerfile.rb +16 -1
  18. data/lib/kuby/docker/errors.rb +1 -0
  19. data/lib/kuby/docker/layer_stack.rb +4 -0
  20. data/lib/kuby/docker/local_tags.rb +4 -0
  21. data/lib/kuby/docker/metadata.rb +14 -34
  22. data/lib/kuby/docker/setup_phase.rb +3 -2
  23. data/lib/kuby/docker/spec.rb +31 -5
  24. data/lib/kuby/docker/timestamp_tag.rb +6 -0
  25. data/lib/kuby/environment.rb +10 -1
  26. data/lib/kuby/kubernetes.rb +9 -9
  27. data/lib/kuby/kubernetes/deploy_task.rb +4 -0
  28. data/lib/kuby/kubernetes/deployer.rb +66 -11
  29. data/lib/kuby/kubernetes/{minikube_provider.rb → docker_desktop_provider.rb} +4 -4
  30. data/lib/kuby/kubernetes/provider.rb +8 -4
  31. data/lib/kuby/kubernetes/spec.rb +23 -22
  32. data/lib/kuby/plugin_registry.rb +27 -0
  33. data/lib/kuby/plugins/rails_app/database.rb +1 -2
  34. data/lib/kuby/plugins/rails_app/generators/kuby.rb +14 -16
  35. data/lib/kuby/plugins/rails_app/mysql.rb +0 -3
  36. data/lib/kuby/plugins/rails_app/plugin.rb +237 -42
  37. data/lib/kuby/plugins/rails_app/tasks.rake +2 -2
  38. data/lib/kuby/rails_commands.rb +83 -0
  39. data/lib/kuby/railtie.rb +0 -4
  40. data/lib/kuby/tasks.rb +77 -23
  41. data/lib/kuby/version.rb +1 -1
  42. data/spec/docker/metadata_spec.rb +84 -0
  43. data/spec/docker/spec_spec.rb +266 -0
  44. data/spec/docker/timestamp_tag_spec.rb +54 -4
  45. data/spec/dummy/Gemfile +54 -0
  46. data/spec/dummy/Gemfile.lock +223 -0
  47. data/spec/dummy/README.md +24 -0
  48. data/spec/dummy/Rakefile +6 -0
  49. data/spec/dummy/app/assets/config/manifest.js +2 -0
  50. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  51. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  52. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  53. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  54. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  55. data/spec/dummy/app/javascript/channels/consumer.js +6 -0
  56. data/spec/dummy/app/javascript/channels/index.js +5 -0
  57. data/spec/dummy/app/javascript/packs/application.js +17 -0
  58. data/spec/dummy/app/jobs/application_job.rb +7 -0
  59. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  60. data/spec/dummy/app/models/application_record.rb +3 -0
  61. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  62. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  63. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  64. data/spec/dummy/bin/bundle +114 -0
  65. data/spec/dummy/bin/rails +9 -0
  66. data/spec/dummy/bin/rake +9 -0
  67. data/spec/dummy/bin/setup +36 -0
  68. data/spec/dummy/bin/spring +17 -0
  69. data/spec/dummy/bin/yarn +11 -0
  70. data/spec/dummy/config.ru +5 -0
  71. data/spec/dummy/config/application.rb +19 -0
  72. data/spec/dummy/config/boot.rb +4 -0
  73. data/spec/dummy/config/cable.yml +10 -0
  74. data/spec/dummy/config/credentials.yml.enc +1 -0
  75. data/spec/dummy/config/database.yml +25 -0
  76. data/spec/dummy/config/environment.rb +5 -0
  77. data/spec/dummy/config/environments/development.rb +62 -0
  78. data/spec/dummy/config/environments/production.rb +112 -0
  79. data/spec/dummy/config/environments/test.rb +49 -0
  80. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  81. data/spec/dummy/config/initializers/assets.rb +14 -0
  82. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  83. data/spec/dummy/config/initializers/content_security_policy.rb +30 -0
  84. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  85. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  86. data/spec/dummy/config/initializers/inflections.rb +16 -0
  87. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  88. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  89. data/spec/dummy/config/locales/en.yml +33 -0
  90. data/spec/dummy/config/master.key +1 -0
  91. data/spec/dummy/config/puma.rb +38 -0
  92. data/spec/dummy/config/routes.rb +3 -0
  93. data/spec/dummy/config/spring.rb +6 -0
  94. data/spec/dummy/config/storage.yml +34 -0
  95. data/spec/dummy/db/seeds.rb +7 -0
  96. data/spec/dummy/package.json +11 -0
  97. data/spec/dummy/public/404.html +67 -0
  98. data/spec/dummy/public/422.html +67 -0
  99. data/spec/dummy/public/500.html +66 -0
  100. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  101. data/spec/dummy/public/apple-touch-icon.png +0 -0
  102. data/spec/dummy/public/favicon.ico +0 -0
  103. data/spec/dummy/public/robots.txt +1 -0
  104. data/spec/dummy/test/application_system_test_case.rb +5 -0
  105. data/spec/dummy/test/channels/application_cable/connection_test.rb +11 -0
  106. data/spec/dummy/test/test_helper.rb +13 -0
  107. data/spec/dummy/tmp/cache/bootsnap-load-path-cache +0 -0
  108. data/spec/spec_helper.rb +77 -2
  109. data/spec/support/docker/fake_cli.rb +54 -0
  110. data/spec/support/docker/remote/fake_client.rb +16 -0
  111. data/spec/trailing_hash_spec.rb +23 -0
  112. metadata +111 -9
  113. data/lib/kuby/tasks/kuby.rake +0 -70
@@ -55,20 +55,24 @@ module Kuby
55
55
  @kubernetes_cli ||= ::KubernetesCLI.new(kubeconfig_path)
56
56
  end
57
57
 
58
+ def helm_cli
59
+ @helm_cli ||= ::HelmCLI.new(kubeconfig_path)
60
+ end
61
+
58
62
  def kubeconfig_path
59
63
  raise NotImplementedError, "please define #{__method__} in #{self.class.name}"
60
64
  end
61
65
 
66
+ def deployer
67
+ @deployer ||= Kuby::Kubernetes::Deployer.new(environment)
68
+ end
69
+
62
70
  private
63
71
 
64
72
  def after_initialize
65
73
  # override this in derived classes
66
74
  end
67
75
 
68
- def deployer
69
- @deployer ||= Kuby::Kubernetes::Deployer.new(environment)
70
- end
71
-
72
76
  def spec
73
77
  environment.kubernetes
74
78
  end
@@ -36,13 +36,12 @@ module Kuby
36
36
  end
37
37
 
38
38
  def configure_plugin(plugin_name, &block)
39
- if @plugins[plugin_name] || plugin_klass = Kuby.plugins[plugin_name]
40
- @plugins[plugin_name] ||= plugin_klass.new(environment)
41
- @plugins[plugin_name].configure(&block) if block
42
- else
43
- raise MissingPluginError, "no plugin registered with name #{plugin_name}, "\
44
- 'do you need to add a gem to your Gemfile?'
39
+ unless @plugins.include?(plugin_name)
40
+ plugin_klass = Kuby.plugins.find(plugin_name)
41
+ @plugins[plugin_name] = plugin_klass.new(environment)
45
42
  end
43
+
44
+ @plugins[plugin_name].configure(&block) if block
46
45
  end
47
46
 
48
47
  alias_method :add_plugin, :configure_plugin
@@ -57,7 +56,7 @@ module Kuby
57
56
  end
58
57
 
59
58
  def before_deploy
60
- @tag ||= docker.metadata.tag
59
+ @tag ||= docker.tag
61
60
 
62
61
  provider.before_deploy(resources)
63
62
  @plugins.each { |_, plg| plg.before_deploy(resources) }
@@ -66,7 +65,7 @@ module Kuby
66
65
  end
67
66
 
68
67
  def after_deploy
69
- @tag ||= docker.metadata.tag
68
+ @tag ||= docker.tag
70
69
 
71
70
  @plugins.each { |_, plg| plg.after_deploy(resources) }
72
71
  provider.after_deploy(resources)
@@ -129,22 +128,24 @@ module Kuby
129
128
  def registry_secret(&block)
130
129
  spec = self
131
130
 
132
- @registry_secret ||= RegistrySecret.new do
133
- metadata do
134
- name "#{spec.selector_app}-registry-secret"
135
- namespace spec.namespace.metadata.name
136
- end
131
+ unless environment.development?
132
+ @registry_secret ||= RegistrySecret.new do
133
+ metadata do
134
+ name "#{spec.selector_app}-registry-secret"
135
+ namespace spec.namespace.metadata.name
136
+ end
137
137
 
138
- docker_config do
139
- registry_host spec.docker.metadata.image_host
140
- username spec.docker.credentials.username
141
- password spec.docker.credentials.password
142
- email spec.docker.credentials.email
138
+ docker_config do
139
+ registry_host spec.docker.metadata.image_host
140
+ username spec.docker.credentials.username
141
+ password spec.docker.credentials.password
142
+ email spec.docker.credentials.email
143
+ end
143
144
  end
144
- end
145
145
 
146
- @registry_secret.instance_eval(&block) if block
147
- @registry_secret
146
+ @registry_secret.instance_eval(&block) if block
147
+ @registry_secret
148
+ end
148
149
  end
149
150
 
150
151
  def resources
@@ -152,7 +153,7 @@ module Kuby
152
153
  namespace,
153
154
  registry_secret,
154
155
  *@plugins.flat_map { |_, plugin| plugin.resources }
155
- ])
156
+ ].compact)
156
157
  end
157
158
 
158
159
  def selector_app
@@ -0,0 +1,27 @@
1
+ module Kuby
2
+ class PluginRegistry
3
+ ANY = 'any'.freeze
4
+
5
+ def register(plugin_name, plugin_klass, environment: ANY)
6
+ plugins[plugin_name] ||= {}
7
+ plugins[plugin_name][environment] ||= plugin_klass
8
+ end
9
+
10
+ def find(plugin_name, environment: Kuby.env)
11
+ plugins_by_env = plugins[plugin_name]
12
+
13
+ unless plugins_by_env
14
+ raise MissingPluginError, "no plugin registered with name #{plugin_name}, "\
15
+ 'do you need to add a gem to your Gemfile?'
16
+ end
17
+
18
+ plugins_by_env[environment] || plugins_by_env[ANY]
19
+ end
20
+
21
+ private
22
+
23
+ def plugins
24
+ @plugins ||= {}
25
+ end
26
+ end
27
+ end
@@ -1,4 +1,3 @@
1
- require 'erb'
2
1
  require 'yaml'
3
2
 
4
3
  module Kuby
@@ -51,7 +50,7 @@ module Kuby
51
50
  end
52
51
 
53
52
  def db_configs
54
- @db_configs ||= YAML.load(ERB.new(File.read(db_config_path)).result)
53
+ @db_configs ||= YAML.load(File.read(db_config_path))
55
54
  end
56
55
 
57
56
  def db_config_path
@@ -2,25 +2,18 @@ require 'rails/generators'
2
2
  require 'rails/generators/base'
3
3
 
4
4
  class KubyGenerator < Rails::Generators::Base
5
- def create_initializer_file
6
- initializer(
7
- 'kuby.rb',
8
- <<~END
9
- require 'kuby'
10
-
11
- Kuby.load!
12
- END
13
- )
14
- end
15
-
16
5
  def create_config_file
17
6
  create_file(
18
7
  'kuby.rb',
19
8
  <<~END
9
+ require 'active_support/core_ext'
20
10
  require 'active_support/encrypted_configuration'
21
11
 
22
12
  # Define a production Kuby deploy environment
23
13
  Kuby.define(:production) do
14
+ # Because the Rails environment isn't always loaded when
15
+ # your Kuby config is loaded, provide access to Rails
16
+ # credentials manually.
24
17
  app_creds = ActiveSupport::EncryptedConfiguration.new(
25
18
  config_path: File.join('config', 'credentials.yml.enc'),
26
19
  key_path: File.join('config', 'master.key'),
@@ -46,17 +39,22 @@ class KubyGenerator < Rails::Generators::Base
46
39
 
47
40
  kubernetes do
48
41
  # Add a plugin that facilitates deploying a Rails app.
49
- add_plugin :rails_app
42
+ add_plugin :rails_app do
43
+ # configure database credentials
44
+ database do
45
+ user app_creds[:KUBY_DB_USER]
46
+ password app_creds[:KUBY_DB_PASSWORD]
47
+ end
48
+ end
50
49
 
51
- # Use minikube as the provider, which is the default installed by
52
- # Docker Desktop.
53
- # See: https://github.com/kubernetes/minikube
50
+ # Use Docker Desktop as the provider.
51
+ # See: https://www.docker.com/products/docker-desktop
54
52
  #
55
53
  # Note: you will likely want to use a different provider when deploying
56
54
  # your application into a production environment. To configure a different
57
55
  # provider, add the corresponding gem to your gemfile and update the
58
56
  # following line according to the provider gem's README.
59
- provider :minikube
57
+ provider :docker_desktop
60
58
  end
61
59
  end
62
60
  END
@@ -12,9 +12,6 @@ module Kuby
12
12
  def initialize(environment, configs)
13
13
  @environment = environment
14
14
  @configs = configs
15
-
16
- user(config['username'])
17
- password(config['password'])
18
15
  end
19
16
 
20
17
  def name
@@ -32,6 +32,7 @@ module Kuby
32
32
  @asset_url = DEFAULT_ASSET_URL
33
33
  @packs_url = DEFAULT_PACKS_URL
34
34
  @asset_path = DEFAULT_ASSET_PATH
35
+ @database = Database.get(self)
35
36
  end
36
37
 
37
38
  def configure(&block)
@@ -41,32 +42,39 @@ module Kuby
41
42
  def after_configuration
42
43
  context = self
43
44
 
44
- if @database = Database.get(self)
45
+ if database
45
46
  environment.kubernetes.plugins[database.plugin_name] = @database.plugin
46
47
  environment.kubernetes.add_plugin(:kube_db)
47
48
 
48
- environment.docker do
49
- insert :rewrite_db_config, RewriteDbConfig.new, after: :copy_phase
49
+ unless environment.development?
50
+ environment.docker do
51
+ insert :rewrite_db_config, RewriteDbConfig.new, after: :copy_phase
52
+ end
50
53
  end
51
54
  end
52
55
 
53
- # do we always want this?
54
- environment.kubernetes.add_plugin(:nginx_ingress)
55
- environment.kubernetes.add_plugin(:rails_assets) do
56
- asset_url context.asset_url
57
- packs_url context.packs_url
58
- asset_path context.asset_path
59
- end
56
+ unless environment.development?
57
+ environment.kubernetes.add_plugin(:nginx_ingress)
58
+ environment.kubernetes.add_plugin(:rails_assets) do
59
+ asset_url context.asset_url
60
+ packs_url context.packs_url
61
+ asset_path context.asset_path
62
+ end
60
63
 
61
- if @tls_enabled
62
- context = self
64
+ if @tls_enabled
65
+ context = self
63
66
 
64
- environment.kubernetes.add_plugin(:cert_manager) do
65
- email context.environment.docker.credentials.email
67
+ environment.kubernetes.add_plugin(:cert_manager) do
68
+ email context.environment.docker.credentials.email
69
+ end
66
70
  end
67
71
  end
68
72
  end
69
73
 
74
+ def database_host
75
+ database.plugin.host
76
+ end
77
+
70
78
  def before_deploy(manifest)
71
79
  # Make sure plugin has been configured. If not, do nothing.
72
80
  if cert_manager = environment.kubernetes.plugin(:cert_manager)
@@ -80,6 +88,8 @@ module Kuby
80
88
  assets.configure_deployment(deployment, image_with_tag)
81
89
  end
82
90
 
91
+ spec = self
92
+
83
93
  deployment do
84
94
  spec do
85
95
  template do
@@ -88,12 +98,14 @@ module Kuby
88
98
  image image_with_tag
89
99
  end
90
100
 
91
- init_container(:create_db) do
92
- image image_with_tag
93
- end
101
+ unless spec.environment.development?
102
+ init_container(:create_db) do
103
+ image image_with_tag
104
+ end
94
105
 
95
- init_container(:migrate_db) do
96
- image image_with_tag
106
+ init_container(:migrate_db) do
107
+ image image_with_tag
108
+ end
97
109
  end
98
110
  end
99
111
  end
@@ -102,7 +114,7 @@ module Kuby
102
114
  end
103
115
 
104
116
  def database(&block)
105
- @database.instance_eval(&block) if block
117
+ @database.plugin.instance_eval(&block) if block
106
118
  @database
107
119
  end
108
120
 
@@ -130,7 +142,7 @@ module Kuby
130
142
 
131
143
  port do
132
144
  name 'http'
133
- port 8080
145
+ port spec.docker.webserver_phase.port
134
146
  protocol 'TCP'
135
147
  target_port 'http'
136
148
  end
@@ -226,6 +238,13 @@ module Kuby
226
238
  add :app, kube_spec.selector_app
227
239
  add :role, kube_spec.role
228
240
  end
241
+
242
+ annotations do
243
+ add(
244
+ 'getkuby.io/dockerfile-checksum',
245
+ kube_spec.environment.docker.to_dockerfile.checksum
246
+ )
247
+ end
229
248
  end
230
249
 
231
250
  spec do
@@ -278,33 +297,93 @@ module Kuby
278
297
  end
279
298
  end
280
299
 
281
- readiness_probe do
282
- success_threshold 1
283
- failure_threshold 2
284
- initial_delay_seconds 15
285
- period_seconds 3
286
- timeout_seconds 1
287
-
288
- http_get do
289
- path '/healthz'
290
- port kube_spec.docker.webserver_phase.port
291
- scheme 'HTTP'
300
+ unless kube_spec.environment.development?
301
+ readiness_probe do
302
+ success_threshold 1
303
+ failure_threshold 2
304
+ initial_delay_seconds 15
305
+ period_seconds 3
306
+ timeout_seconds 1
307
+
308
+ http_get do
309
+ path '/healthz'
310
+ port kube_spec.docker.webserver_phase.port
311
+ scheme 'HTTP'
312
+ end
292
313
  end
293
314
  end
294
- end
295
315
 
296
- init_container(:create_db) do
297
- name "#{kube_spec.selector_app}-create-db"
298
- command %w(bundle exec rake kuby:rails_app:db:create_unless_exists)
299
- end
316
+ if kube_spec.environment.development?
317
+ env do
318
+ name 'BUNDLE_PATH'
319
+ value '/bundle'
320
+ end
321
+
322
+ env do
323
+ name 'GEM_HOME'
324
+ value '/bundle'
325
+ end
326
+
327
+ env do
328
+ name 'BOOTSNAP_CACHE_DIR'
329
+ value '/usr/src/bootsnap'
330
+ end
331
+
332
+ volume_mount do
333
+ name "#{kube_spec.selector_app}-code"
334
+ mount_path '/usr/src/app'
335
+ end
300
336
 
301
- init_container(:migrate_db) do
302
- name "#{kube_spec.selector_app}-migrate-db"
303
- command %w(bundle exec rake db:migrate)
337
+ volume_mount do
338
+ name "#{kube_spec.selector_app}-bundle"
339
+ mount_path '/bundle'
340
+ end
341
+
342
+ volume_mount do
343
+ name "#{kube_spec.selector_app}-bootsnap"
344
+ mount_path '/usr/src/bootsnap'
345
+ end
346
+ end
304
347
  end
305
348
 
306
- image_pull_secret do
307
- name kube_spec.environment.kubernetes.registry_secret.metadata.name
349
+ if kube_spec.environment.development?
350
+ volume do
351
+ name "#{kube_spec.selector_app}-code"
352
+
353
+ persistent_volume_claim do
354
+ claim_name kube_spec.code_volume_claim.metadata.name
355
+ end
356
+ end
357
+
358
+ volume do
359
+ name "#{kube_spec.selector_app}-bundle"
360
+
361
+ persistent_volume_claim do
362
+ claim_name kube_spec.bundle_volume_claim.metadata.name
363
+ end
364
+ end
365
+
366
+ volume do
367
+ name "#{kube_spec.selector_app}-bootsnap"
368
+
369
+ persistent_volume_claim do
370
+ claim_name kube_spec.bootsnap_volume_claim.metadata.name
371
+ end
372
+ end
373
+ else
374
+ init_container(:create_db) do
375
+ name "#{kube_spec.selector_app}-create-db"
376
+ command %w(bundle exec rake kuby:rails_app:db:create_unless_exists)
377
+ end
378
+
379
+ init_container(:migrate_db) do
380
+ name "#{kube_spec.selector_app}-migrate-db"
381
+ command %w(bundle exec rake db:migrate)
382
+ end
383
+
384
+ image_pull_secret do
385
+ name kube_spec.environment.kubernetes.registry_secret.metadata.name
386
+ end
308
387
  end
309
388
 
310
389
  restart_policy 'Always'
@@ -361,6 +440,118 @@ module Kuby
361
440
  @ingress
362
441
  end
363
442
 
443
+ def code_volume(&block)
444
+ spec = self
445
+
446
+ if environment.development?
447
+ @code_volume ||= KubeDSL.persistent_volume do
448
+ metadata do
449
+ name "#{spec.selector_app}-code"
450
+ end
451
+
452
+ spec do
453
+ access_modes ['ReadWriteMany']
454
+
455
+ capacity do
456
+ add :storage, '1Mi'
457
+ end
458
+
459
+ host_path do
460
+ path File.expand_path(spec.root)
461
+ end
462
+
463
+ storage_class_name 'hostpath'
464
+ end
465
+ end
466
+
467
+ @code_volume.instance_eval(&block) if block
468
+ @code_volume
469
+ end
470
+ end
471
+
472
+ def code_volume_claim(&block)
473
+ spec = self
474
+
475
+ if environment.development?
476
+ @code_volume_claim ||= KubeDSL.persistent_volume_claim do
477
+ metadata do
478
+ name "#{spec.selector_app}-code"
479
+ namespace spec.namespace.metadata.name
480
+ end
481
+
482
+ spec do
483
+ access_modes ['ReadWriteMany']
484
+
485
+ resources do
486
+ requests do
487
+ add :storage, '1Mi'
488
+ end
489
+ end
490
+
491
+ storage_class_name 'hostpath'
492
+ volume_name spec.code_volume.metadata.name
493
+ end
494
+ end
495
+
496
+ @code_volume_claim.instance_eval(&block) if block
497
+ @code_volume_claim
498
+ end
499
+ end
500
+
501
+ def bundle_volume_claim(&block)
502
+ spec = self
503
+
504
+ if environment.development?
505
+ @bundle_volume_claim ||= KubeDSL.persistent_volume_claim do
506
+ metadata do
507
+ name "#{spec.selector_app}-bundle"
508
+ namespace spec.namespace.metadata.name
509
+ end
510
+
511
+ spec do
512
+ access_modes ['ReadWriteMany']
513
+ storage_class_name 'hostpath'
514
+
515
+ resources do
516
+ requests do
517
+ add :storage, '2Gi'
518
+ end
519
+ end
520
+ end
521
+ end
522
+
523
+ @bundle_volume_claim.instance_eval(&block) if block
524
+ @bundle_volume_claim
525
+ end
526
+ end
527
+
528
+ def bootsnap_volume_claim(&block)
529
+ spec = self
530
+
531
+ if environment.development?
532
+ @bootsnap_volume_claim ||= KubeDSL.persistent_volume_claim do
533
+ metadata do
534
+ name "#{spec.selector_app}-bootsnap"
535
+ namespace spec.namespace.metadata.name
536
+ end
537
+
538
+ spec do
539
+ access_modes ['ReadWriteMany']
540
+ storage_class_name 'hostpath'
541
+
542
+ resources do
543
+ requests do
544
+ add :storage, '2Gi'
545
+ end
546
+ end
547
+ end
548
+ end
549
+
550
+ @bootsnap_volume_claim.instance_eval(&block) if block
551
+ @bootsnap_volume_claim
552
+ end
553
+ end
554
+
364
555
  def resources
365
556
  @resources ||= [
366
557
  service,
@@ -369,6 +560,10 @@ module Kuby
369
560
  app_secrets,
370
561
  deployment,
371
562
  ingress,
563
+ code_volume,
564
+ code_volume_claim,
565
+ bundle_volume_claim,
566
+ bootsnap_volume_claim,
372
567
  *database&.plugin&.resources
373
568
  ]
374
569
  end