kuby-core 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -1
  3. data/README.md +11 -1
  4. data/bin/kuby +4 -0
  5. data/kuby-core.gemspec +5 -2
  6. data/lib/kuby.rb +46 -18
  7. data/lib/kuby/basic_logger.rb +13 -0
  8. data/lib/kuby/cli_base.rb +81 -8
  9. data/lib/kuby/commands.rb +220 -0
  10. data/lib/kuby/definition.rb +1 -3
  11. data/lib/kuby/dev_setup.rb +255 -0
  12. data/lib/kuby/docker.rb +1 -0
  13. data/lib/kuby/docker/bundler_phase.rb +3 -3
  14. data/lib/kuby/docker/cli.rb +13 -1
  15. data/lib/kuby/docker/dev_spec.rb +131 -0
  16. data/lib/kuby/docker/dockerfile.rb +16 -1
  17. data/lib/kuby/docker/layer_stack.rb +4 -0
  18. data/lib/kuby/docker/local_tags.rb +4 -0
  19. data/lib/kuby/docker/metadata.rb +0 -22
  20. data/lib/kuby/docker/setup_phase.rb +3 -2
  21. data/lib/kuby/docker/spec.rb +31 -5
  22. data/lib/kuby/environment.rb +10 -1
  23. data/lib/kuby/kubernetes.rb +9 -9
  24. data/lib/kuby/kubernetes/deploy_task.rb +4 -0
  25. data/lib/kuby/kubernetes/deployer.rb +63 -11
  26. data/lib/kuby/kubernetes/{minikube_provider.rb → docker_desktop_provider.rb} +4 -4
  27. data/lib/kuby/kubernetes/provider.rb +8 -4
  28. data/lib/kuby/kubernetes/spec.rb +23 -22
  29. data/lib/kuby/plugin_registry.rb +27 -0
  30. data/lib/kuby/plugins/rails_app/generators/kuby.rb +3 -15
  31. data/lib/kuby/plugins/rails_app/plugin.rb +230 -40
  32. data/lib/kuby/rails_commands.rb +89 -0
  33. data/lib/kuby/railtie.rb +0 -4
  34. data/lib/kuby/tasks.rb +76 -23
  35. data/lib/kuby/version.rb +1 -1
  36. data/spec/docker/metadata_spec.rb +0 -108
  37. data/spec/docker/spec_spec.rb +266 -0
  38. data/spec/spec_helper.rb +8 -1
  39. metadata +44 -9
  40. data/lib/kuby/tasks/kuby.rake +0 -70
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0f3610dd2dc149fb09e589c56dc477534ece66a752106b251a94ac265cb1e34
4
- data.tar.gz: 673285ecde402c63a461ef4c4374a1353be45ff33610db840590658cc6cab5ed
3
+ metadata.gz: f9367e316dfab7a0210bea18ab630b65a5996ce0622960f3be2a76f8ec4482c1
4
+ data.tar.gz: d48777e79f11eab678545a2d398d3f60463e7d1209e6d15987c3f3665d571b82
5
5
  SHA512:
6
- metadata.gz: 6c8e407acf3a35f21b4446b0c0752a754720a7fbd03b887b64c4fe0991e61e6f107f61a2adb2394ac88d24470be5c814c6168cd96106295c777f50a35f77820a
7
- data.tar.gz: 1871572ccb876d772eec874ed224235905ba7265ced27319f4e7abd678a65e1862584bd88f0223e2f87ba1b99158342e6c6a2c4d033d758b28338296153f5e4b
6
+ metadata.gz: cbfd215f8b4a7cb2b1a53bc8de8298e4dd85f487f0245da82bd19a390d55500c20e97e155a07fafa09284683ee9c220bb4cdd89194c3e5cb4c6e3c055fbcce74
7
+ data.tar.gz: 03c15b9ffb8672ef2e45d2d818c3d048e694dae2656db0be6325a1edf6853b1c9c8bc7060b021add66b43d87c9ca3ac46bb71346f2e2a4e68bd89ba6d45635f9
@@ -1,10 +1,21 @@
1
+ ## 0.9.0
2
+ * Add support for developing your app using a local Kubernetes cluster.
3
+ - Includes a default `:development` Kuby environment.
4
+ * Remove rake tasks in favor of a `kuby` executable powered by [GLI](https://github.com/davetron5000/gli).
5
+ * Rename the `minikube` provider to `docker_desktop`, which is more accurate.
6
+ * Add more tests.
7
+ * Avoid running commands inside pods that aren't running or that are marked for deletion (#15).
8
+ * Pass `RAILS_MASTER_KEY` to Docker build (#14).
9
+ * Add `kuby remote restart` command for manually restarting Rails pods.
10
+ * Automatically restart Rails pods if deploy doesn't change the Docker image URL (#11).
11
+
1
12
  ## 0.8.1
2
13
  * Fix database config rewriter task.
3
14
  - Broke with refactoring of database config code.
4
15
  * More correctly parse Docker image URLs.
5
16
  - It can be challenging to identify the hostname in image URLs because 1) the host can be omitted, and 2) the scheme is often omitted.
6
17
  - The new strategy is to look for a "." in the first segment of the URL if there is no scheme. It's not bulletproof but is better than what we had before, which was to assume the first segment was the host. Eg. for an image URL like camertron/foo, we would identify the host as "camertron."
7
- * Added a number of tests and a Rails dummy app in spec/.
18
+ * Add a number of tests and a Rails dummy app in spec/.
8
19
 
9
20
  ## 0.8.0
10
21
  * Upgrade to Krane >= 1.1.4, < 2.0.
data/README.md CHANGED
@@ -8,6 +8,16 @@ At its core, Kuby is a set of tools and smart defaults that encapsulate and codi
8
8
 
9
9
  Under the hood, Kuby leverages the power of Docker and Kubernetes. It tries to make these technologies accessible to the average Rails dev without requiring a devops black belt.
10
10
 
11
+ ## Why Kuby?
12
+
13
+ Kuby embraces the same convention-over-configuration approach that Rails does. It aims to reduce the cognitive overhead associated with learning a bunch of ops tools to get your app onto the internet. In other words, Kuby does a whole lot for you. Specifically, it:
14
+
15
+ * leverages Docker and Kubernetes, industry-leading infrastructure tools.
16
+ * automatically configures your app with a TLS certificate from [LetsEncrypt](https://letsencrypt.org/).
17
+ * automatically spins up a database instance based on what's in your database.yml.
18
+ * runs a separate server for your static assets.
19
+ * features a powerful plugin system that allows, for example, easy [Sidekiq integration](https://github.com/getkuby/kuby-sidekiq).
20
+
11
21
  ## Getting Started
12
22
 
13
23
  See the [Quick Start Guide](https://github.com/getkuby/kuby-core/wiki/Quick-Start-Guide)
@@ -18,7 +28,7 @@ See the [wiki](https://github.com/getkuby/kuby-core/wiki).
18
28
 
19
29
  ## Running Tests
20
30
 
21
- `bundle exec rspec` should do the trick... or at least it would if there were any tests. Don't worry, it's on my radar.
31
+ `bundle exec rspec` should do the trick. Test coverage is very minimal at the moment, however.
22
32
 
23
33
  ## License
24
34
 
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'kuby'
4
+ exit Kuby::Commands.run(ARGV)
@@ -14,19 +14,22 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency 'colorize', '~> 0.8'
16
16
  s.add_dependency 'docker-remote', '~> 0.1'
17
+ s.add_dependency 'gli', '~> 2.0'
18
+ s.add_dependency 'helm-cli', '~> 0.3'
17
19
  # See: https://github.com/Shopify/krane/pull/720
18
20
  # See: https://github.com/Shopify/krane/blob/master/CHANGELOG.md#114
19
21
  s.add_dependency 'krane', '>= 1.1.4', '< 2.0'
20
22
  s.add_dependency 'kuby-cert-manager', '>= 0.3'
21
23
  s.add_dependency 'kube-dsl', '~> 0.3'
22
- s.add_dependency 'kuby-kube-db', '>= 0.5'
23
- s.add_dependency 'kubernetes-cli', '~> 0.2'
24
+ s.add_dependency 'kuby-kube-db', '>= 0.6'
25
+ s.add_dependency 'kubernetes-cli', '~> 0.3'
24
26
  s.add_dependency 'railties', '>= 5.1'
25
27
  s.add_dependency 'rouge', '~> 3.0'
26
28
 
27
29
  s.add_development_dependency 'rspec'
28
30
 
29
31
  s.require_path = 'lib'
32
+ s.executables << 'kuby'
30
33
 
31
34
  s.files = Dir['{lib,spec}/**/*', 'Gemfile', 'LICENSE', 'CHANGELOG.md', 'README.md', 'Rakefile', 'kuby-core.gemspec']
32
35
  end
@@ -6,26 +6,39 @@ rescue NameError
6
6
  end
7
7
 
8
8
  module Kuby
9
- autoload :BasicLogger, 'kuby/basic_logger'
10
- autoload :CLIBase, 'kuby/cli_base'
11
- autoload :Definition, 'kuby/definition'
12
- autoload :Docker, 'kuby/docker'
13
- autoload :Environment, 'kuby/environment'
14
- autoload :Kubernetes, 'kuby/kubernetes'
15
- autoload :Middleware, 'kuby/middleware'
16
- autoload :Plugin, 'kuby/plugin'
17
- autoload :Plugins, 'kuby/plugins'
18
- autoload :Tasks, 'kuby/tasks'
19
- autoload :TrailingHash, 'kuby/trailing_hash'
9
+ autoload :BasicLogger, 'kuby/basic_logger'
10
+ autoload :CLIBase, 'kuby/cli_base'
11
+ autoload :Commands, 'kuby/commands'
12
+ autoload :Definition, 'kuby/definition'
13
+ autoload :DevSetup, 'kuby/dev_setup'
14
+ autoload :Docker, 'kuby/docker'
15
+ autoload :Environment, 'kuby/environment'
16
+ autoload :Kubernetes, 'kuby/kubernetes'
17
+ autoload :Middleware, 'kuby/middleware'
18
+ autoload :Plugin, 'kuby/plugin'
19
+ autoload :PluginRegistry, 'kuby/plugin_registry'
20
+ autoload :Plugins, 'kuby/plugins'
21
+ autoload :RailsCommands, 'kuby/rails_commands'
22
+ autoload :Tasks, 'kuby/tasks'
23
+ autoload :TrailingHash, 'kuby/trailing_hash'
24
+
25
+ DEFAULT_ENV = 'development'.freeze
20
26
 
21
27
  class UndefinedEnvironmentError < StandardError; end
28
+ class MissingConfigError < StandardError; end
22
29
 
23
30
  class << self
24
31
  attr_reader :definition
25
32
  attr_writer :logger
26
33
 
27
- def load!
28
- require ENV['KUBY_CONFIG'] || File.join('.', 'kuby.rb')
34
+ def load!(config_file = nil)
35
+ config_file ||= ENV['KUBY_CONFIG'] || File.join('.', 'kuby.rb')
36
+
37
+ unless File.exist?(config_file)
38
+ raise MissingConfigError, "couldn't find Kuby config file at #{config_file}"
39
+ end
40
+
41
+ require config_file
29
42
  end
30
43
 
31
44
  def define(name, &block)
@@ -34,6 +47,17 @@ module Kuby
34
47
  @definition = Definition.new(name.to_s)
35
48
  @definition.instance_eval(&block)
36
49
 
50
+ # default development environment
51
+ @definition.environment(:development) do
52
+ kubernetes do
53
+ add_plugin(:rails_app) do
54
+ tls_enabled false
55
+ end
56
+
57
+ provider :docker_desktop
58
+ end
59
+ end
60
+
37
61
  @definition.environments.each do |_, env|
38
62
  env.kubernetes.after_configuration
39
63
  end
@@ -56,8 +80,8 @@ module Kuby
56
80
  @providers ||= {}
57
81
  end
58
82
 
59
- def register_plugin(plugin_name, plugin_klass)
60
- plugins[plugin_name] = plugin_klass
83
+ def register_plugin(*args, **kwargs)
84
+ plugins.register(*args, **kwargs)
61
85
  end
62
86
 
63
87
  def register_distro(distro_name, distro_klass)
@@ -69,7 +93,7 @@ module Kuby
69
93
  end
70
94
 
71
95
  def plugins
72
- @plugins ||= {}
96
+ @plugins ||= PluginRegistry.new
73
97
  end
74
98
 
75
99
  def logger
@@ -99,16 +123,20 @@ module Kuby
99
123
  @packages ||= {}
100
124
  end
101
125
 
126
+ def env=(env_name)
127
+ @env = env_name.to_s
128
+ end
129
+
102
130
  def env
103
131
  ENV.fetch('KUBY_ENV') do
104
- (definition.environments.keys.first || Rails.env).to_s
132
+ (@env || Rails.env rescue nil || DEFAULT_ENV).to_s
105
133
  end
106
134
  end
107
135
  end
108
136
  end
109
137
 
110
138
  # providers
111
- Kuby.register_provider(:minikube, Kuby::Kubernetes::MinikubeProvider)
139
+ Kuby.register_provider(:docker_desktop, Kuby::Kubernetes::DockerDesktopProvider)
112
140
 
113
141
  # plugins
114
142
  Kuby.register_plugin(:rails_app, Kuby::Plugins::RailsApp::Plugin)
@@ -18,5 +18,18 @@ module Kuby
18
18
  def fatal(msg, *args)
19
19
  super(ColorizedString[msg].red, *args)
20
20
  end
21
+
22
+ # adhere to the "CLI" interface
23
+ def with_pipes(out = STDOUT, err = STDERR)
24
+ previous_logdev = @logdev || STDERR
25
+ reopen(err)
26
+ yield
27
+ ensure
28
+ reopen(previous_logdev)
29
+ end
30
+
31
+ def last_status
32
+ nil
33
+ end
21
34
  end
22
35
  end
@@ -17,17 +17,59 @@ module Kuby
17
17
  @after_execute << block
18
18
  end
19
19
 
20
+ def with_pipes(out = STDOUT, err = STDERR)
21
+ previous_stdout = self.stdout
22
+ previous_stderr = self.stderr
23
+ self.stdout = out
24
+ self.stderr = err
25
+ yield
26
+ ensure
27
+ self.stdout = previous_stdout
28
+ self.stderr = previous_stderr
29
+ end
30
+
31
+ def stdout
32
+ Thread.current[stdout_key] || STDOUT
33
+ end
34
+
35
+ def stdout=(new_stdout)
36
+ Thread.current[stdout_key] = new_stdout
37
+ end
38
+
39
+ def stderr
40
+ Thread.current[stderr_key] || STDERR
41
+ end
42
+
43
+ def stderr=(new_stderr)
44
+ Thread.current[stderr_key] = new_stderr
45
+ end
46
+
20
47
  private
21
48
 
22
49
  def open3_w(env, cmd, opts = {}, &block)
23
50
  run_before_callbacks(cmd)
24
51
  cmd_s = cmd.join(' ')
25
52
 
26
- Open3.pipeline_w([env, cmd_s], opts) do |stdin, wait_threads|
27
- yield(stdin, wait_threads).tap do
28
- stdin.close
29
- self.last_status = wait_threads.last.value
53
+ Open3.popen3(env, cmd_s, opts) do |p_stdin, p_stdout, p_stderr, wait_thread|
54
+ Thread.new(stdout) do |t_stdout|
55
+ begin
56
+ p_stdout.each { |line| t_stdout.puts(line) }
57
+ rescue IOError
58
+ end
59
+ end
60
+
61
+ Thread.new(stderr) do |t_stderr|
62
+ begin
63
+ p_stderr.each { |line| t_stderr.puts(line) }
64
+ rescue IOError
65
+ end
66
+ end
67
+
68
+ yield(p_stdin).tap do
69
+ p_stdin.close
70
+ self.last_status = wait_thread.value
30
71
  run_after_callbacks(cmd)
72
+ wait_thread.join
31
73
  end
32
74
  end
33
75
  end
@@ -41,19 +83,42 @@ module Kuby
41
83
  def systemm(cmd)
42
84
  run_before_callbacks(cmd)
43
85
  cmd_s = cmd.join(' ')
44
- system(cmd_s).tap do
45
- self.last_status = $?
86
+
87
+ Open3.popen3(cmd_s) do |p_stdin, p_stdout, p_stderr, wait_thread|
88
+ Thread.new(stdout) do |t_stdout|
89
+ p_stdout.each { |line| t_stdout.puts(line) }
90
+ end
91
+
92
+ Thread.new(stderr) do |t_stderr|
93
+ p_stderr.each { |line| t_stderr.puts(line) }
94
+ end
95
+
96
+ self.last_status = wait_thread.value
46
97
  run_after_callbacks(cmd)
98
+ wait_thread.join
47
99
  end
48
100
  end
49
101
 
50
102
  def backticks(cmd)
51
103
  run_before_callbacks(cmd)
52
104
  cmd_s = cmd.join(' ')
53
- `#{cmd_s}`.tap do
54
- self.last_status = $?
105
+ result = StringIO.new
106
+
107
+ Open3.popen3(cmd_s) do |p_stdin, p_stdout, p_stderr, wait_thread|
108
+ Thread.new do
109
+ p_stdout.each { |line| result.puts(line) }
110
+ end
111
+
112
+ Thread.new(stderr) do |t_stderr|
113
+ p_stderr.each { |line| t_stderr.puts(line) }
114
+ end
115
+
116
+ self.last_status = wait_thread.value
55
117
  run_after_callbacks(cmd)
118
+ wait_thread.join
56
119
  end
120
+
121
+ result.string
57
122
  end
58
123
 
59
124
  def run_before_callbacks(cmd)
@@ -71,5 +136,13 @@ module Kuby
71
136
  def status_key
72
137
  raise NotImplementedError, "#{__method__} must be defined in derived classes"
73
138
  end
139
+
140
+ def stdout_key
141
+ raise NotImplementedError, "#{__method__} must be defined in derived classes"
142
+ end
143
+
144
+ def stderr_key
145
+ raise NotImplementedError, "#{__method__} must be defined in derived classes"
146
+ end
74
147
  end
75
148
  end
@@ -0,0 +1,220 @@
1
+ require 'kuby/version'
2
+ require 'gli'
3
+
4
+ module Kuby
5
+ class Commands
6
+ extend GLI::App
7
+
8
+ # GLI doesn't have a wildcard option, so it's impossible to tell it to
9
+ # slurp up all args after a certain point. In our case, we want to be
10
+ # able to invoke `rails` commands and pass through all the original
11
+ # flags, switches, etc. To get around GLI's limitations, we identify
12
+ # `rails` commands in this hijacked `run` method and only use GLI to
13
+ # parse global options (like -e). The rest of the Rails options are
14
+ # captured in an instance variable and thereby made available to the
15
+ # Rails command handlers defined below. We use Module#prepend here to
16
+ # avoid the usual series of cryptic alias_method calls (note that there
17
+ # is no singleton class version of #prepend in the Ruby language).
18
+ singleton_class.send(:prepend, Module.new do
19
+ def run(args)
20
+ if idx = args.index('rails')
21
+ @rails_options = args[(idx + 1)..-1]
22
+ super(args[0..(idx + 1)])
23
+ else
24
+ super
25
+ end
26
+ end
27
+ end)
28
+
29
+ def self.tasks
30
+ Kuby::Tasks.new(Kuby.definition.environment)
31
+ end
32
+
33
+ program_desc 'Kuby command-line interface. Kuby is a convention '\
34
+ 'over configuration approach for running Rails apps in Kubernetes.'
35
+
36
+ version Kuby::VERSION
37
+
38
+ subcommand_option_handling :normal
39
+ arguments :loose
40
+
41
+ desc 'The Kuby environment to use. Overrides KUBY_ENV.'
42
+ flag [:e, :environment], type: String, required: false
43
+
44
+ desc 'Path to your Kuby config file. Overrides KUBY_CONFIG.'
45
+ default_value './kuby.rb'
46
+ flag [:c, :config]
47
+
48
+ pre do |global_options, options, args|
49
+ Kuby.env = global_options[:environment] if global_options[:environment]
50
+ Kuby.load!(global_options[:config])
51
+
52
+ # GLI will abort unless this block returns a truthy value
53
+ true
54
+ end
55
+
56
+ # These are only stubs included to fill out the help screens. Rails
57
+ # commands are handled by the RailsCommands class.
58
+ desc 'Runs a Rails command.'
59
+ command :rails do |rc|
60
+ rc.desc 'Runs the rails server (run `rails server --help` for options)'
61
+ rc.command [:server, :s] do |c|
62
+ c.action do |global_options, options, args|
63
+ exit 1 unless tasks.dev_deployment_ok
64
+ Kuby::RailsCommands.run(@rails_options)
65
+ end
66
+ end
67
+
68
+ rc.desc 'Runs a script in the Rails environment (run `rails runner --help` for options)'
69
+ rc.command [:runner, :r] do |c|
70
+ c.action do |global_options, options, args|
71
+ exit 1 unless tasks.dev_deployment_ok
72
+ Kuby::RailsCommands.run(@rails_options)
73
+ end
74
+ end
75
+
76
+ rc.desc 'Starts an interactive Ruby console with the Rails environment loaded '\
77
+ '(run `rails console --help` for options)'
78
+ rc.command [:console, :c] do |c|
79
+ c.action do |global_options, options, args|
80
+ exit 1 unless tasks.dev_deployment_ok
81
+ Kuby::RailsCommands.run(@rails_options)
82
+ end
83
+ end
84
+ end
85
+
86
+ desc 'Builds the Docker image.'
87
+ command :build do |c|
88
+ c.action do |global_options, options, args|
89
+ tasks.build
90
+ end
91
+ end
92
+
93
+ desc 'Pushes the Docker image to the configured registry.'
94
+ command :push do |c|
95
+ c.action do |global_options, options, args|
96
+ tasks.push
97
+ end
98
+ end
99
+
100
+ desc 'Gets your Kubernetes cluster ready to run your Rails app.'
101
+ command :setup do |c|
102
+ c.action do |global_options, options, args|
103
+ tasks.setup
104
+ end
105
+ end
106
+
107
+ desc 'Prints the effective Dockerfile used to build the Docker image.'
108
+ command :dockerfile do |c|
109
+ c.action do |global_options, options, args|
110
+ tasks.print_dockerfile
111
+ end
112
+ end
113
+
114
+ desc 'Deploys the application.'
115
+ command :deploy do |c|
116
+ c.desc 'The Docker tag to deploy. Defaults to the most recent tag.'
117
+ c.flag [:t, :tag], required: false
118
+ c.action do |global_options, options, args|
119
+ tasks.deploy(options[:tag])
120
+ end
121
+ end
122
+
123
+ desc 'Rolls back to the previous Docker tag.'
124
+ command :rollback do |c|
125
+ c.action do |global_options, options, args|
126
+ tasks.rollback
127
+ end
128
+ end
129
+
130
+ desc 'Prints the effective Kubernetes resources that will be applied on deploy.'
131
+ command :resources do |c|
132
+ c.action do |global_options, options, args|
133
+ tasks.print_resources
134
+ end
135
+ end
136
+
137
+ desc 'Prints out the contents of the kubeconfig Kuby is using to communicate with your cluster.'
138
+ command :kubeconfig do |c|
139
+ c.action do |global_options, options, args|
140
+ tasks.print_kubeconfig
141
+ end
142
+ end
143
+
144
+ desc 'Runs an arbitrary kubectl command.'
145
+ command :kubectl do |c|
146
+ c.desc 'Prefixes the kubectl command with the namespace associated with '\
147
+ 'the current environment. For example, if the Kuby env is "production", '\
148
+ 'this option will prefix the kubectl command with "-n myapp-production".'
149
+ c.switch [:N, :namespaced], default: false
150
+ c.action do |global_options, options, args|
151
+ if options[:namespaced]
152
+ # sorry Demeter
153
+ namespace = Kuby.definition.environment.kubernetes.namespace.metadata.name
154
+ args = ['-n', namespace, *args]
155
+ end
156
+
157
+ tasks.kubectl(*args)
158
+ end
159
+ end
160
+
161
+ desc 'Runs commands, etc against the Kubernetes cluster.'
162
+ command :remote do |rc|
163
+ rc.desc 'Tails (i.e. continuously streams) the Rails log from your running application.'
164
+ rc.command :logs do |c|
165
+ c.action do |global_options, options, args|
166
+ exit 1 unless tasks.dev_deployment_ok
167
+ tasks.remote_logs
168
+ end
169
+ end
170
+
171
+ rc.desc 'Lists running Kubernetes pods.'
172
+ rc.command :status do |c|
173
+ c.action do |global_options, options, args|
174
+ exit 1 unless tasks.dev_deployment_ok
175
+ tasks.remote_status
176
+ end
177
+ end
178
+
179
+ rc.desc 'Runs an arbitrary command inside a running Rails pod.'
180
+ rc.command :exec do |c|
181
+ c.action do |global_options, options, args|
182
+ exit 1 unless tasks.dev_deployment_ok
183
+ tasks.remote_exec(args)
184
+ end
185
+ end
186
+
187
+ rc.desc 'Establishes a shell inside a running Rails pod.'
188
+ rc.command :shell do |c|
189
+ c.action do |global_options, options, args|
190
+ exit 1 unless tasks.dev_deployment_ok
191
+ tasks.remote_shell
192
+ end
193
+ end
194
+
195
+ rc.desc 'Establishes a Rails console inside a running Rails pod.'
196
+ rc.command :console do |c|
197
+ c.action do |global_options, options, args|
198
+ exit 1 unless tasks.dev_deployment_ok
199
+ tasks.remote_console
200
+ end
201
+ end
202
+
203
+ rc.desc 'Establishes a database console inside a running Rails pod.'
204
+ rc.command :dbconsole do |c|
205
+ c.action do |global_options, options, args|
206
+ exit 1 unless tasks.dev_deployment_ok
207
+ tasks.remote_dbconsole
208
+ end
209
+ end
210
+
211
+ rc.desc "Restarts the Rails app's web pods."
212
+ rc.command :restart do |c|
213
+ c.action do |global_options, options, args|
214
+ exit 1 unless tasks.dev_deployment_ok
215
+ tasks.remote_restart
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end