dash 3.2.0 → 3.2.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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/dash +2 -2
- data/lib/{kamal → dash}/cli/accessory.rb +24 -24
- data/lib/dash/cli/alias/command.rb +10 -0
- data/lib/{kamal → dash}/cli/app/assets.rb +2 -2
- data/lib/{kamal → dash}/cli/app/boot.rb +15 -15
- data/lib/{kamal → dash}/cli/app/error_pages.rb +6 -6
- data/lib/{kamal → dash}/cli/app/rollout_boot.rb +6 -6
- data/lib/{kamal → dash}/cli/app/ssl_certificates.rb +3 -3
- data/lib/{kamal → dash}/cli/app.rb +86 -86
- data/lib/{kamal → dash}/cli/base.rb +71 -47
- data/lib/dash/cli/build/clone.rb +59 -0
- data/lib/{kamal → dash}/cli/build/port_forwarding.rb +1 -1
- data/lib/{kamal → dash}/cli/build.rb +45 -45
- data/lib/{kamal → dash}/cli/doctor/config_checks.rb +3 -3
- data/lib/{kamal → dash}/cli/doctor/endpoint_checks.rb +25 -7
- data/lib/{kamal → dash}/cli/doctor/host_checks.rb +18 -18
- data/lib/{kamal → dash}/cli/doctor.rb +9 -9
- data/lib/{kamal → dash}/cli/healthcheck/barrier.rb +2 -2
- data/lib/{kamal → dash}/cli/healthcheck/drift_error.rb +2 -2
- data/lib/dash/cli/healthcheck/error.rb +2 -0
- data/lib/{kamal → dash}/cli/healthcheck/poller.rb +7 -7
- data/lib/{kamal → dash}/cli/lock.rb +1 -1
- data/lib/dash/cli/main/migrate.rb +77 -0
- data/lib/{kamal → dash}/cli/main.rb +77 -66
- data/lib/{kamal → dash}/cli/proxy/drift.rb +3 -3
- data/lib/{kamal → dash}/cli/proxy/loadbalancer_claim.rb +3 -3
- data/lib/{kamal → dash}/cli/proxy/loadbalancer_reboot.rb +22 -22
- data/lib/{kamal → dash}/cli/proxy/reboot.rb +15 -15
- data/lib/{kamal → dash}/cli/proxy.rb +166 -154
- data/lib/{kamal → dash}/cli/prune.rb +10 -10
- data/lib/{kamal → dash}/cli/registry.rb +11 -11
- data/lib/{kamal → dash}/cli/secrets.rb +3 -3
- data/lib/{kamal → dash}/cli/server.rb +14 -14
- data/lib/{kamal → dash}/cli/templates/deploy.yml +4 -4
- data/lib/dash/cli/templates/sample_hooks/docker-setup.sample +3 -0
- data/lib/dash/cli/templates/sample_hooks/post-app-boot.sample +3 -0
- data/lib/dash/cli/templates/sample_hooks/post-app-stop.sample +9 -0
- data/lib/dash/cli/templates/sample_hooks/post-deploy.sample +14 -0
- data/lib/dash/cli/templates/sample_hooks/post-proxy-deploy.sample +3 -0
- data/lib/dash/cli/templates/sample_hooks/post-proxy-reboot.sample +3 -0
- data/lib/dash/cli/templates/sample_hooks/pre-app-boot.sample +3 -0
- data/lib/{kamal → dash}/cli/templates/sample_hooks/pre-app-stop.sample +2 -2
- data/lib/{kamal → dash}/cli/templates/sample_hooks/pre-build.sample +8 -8
- data/lib/{kamal → dash}/cli/templates/sample_hooks/pre-connect.sample +8 -8
- data/lib/{kamal → dash}/cli/templates/sample_hooks/pre-deploy.sample +9 -9
- data/lib/dash/cli/templates/sample_hooks/pre-proxy-deploy.sample +3 -0
- data/lib/dash/cli/templates/sample_hooks/pre-proxy-reboot.sample +3 -0
- data/lib/{kamal → dash}/cli/templates/secrets +6 -6
- data/lib/{kamal → dash}/cli.rb +2 -2
- data/lib/{kamal → dash}/commander/specifics.rb +2 -2
- data/lib/{kamal → dash}/commander.rb +31 -23
- data/lib/{kamal → dash}/commands/accessory/proxy.rb +1 -1
- data/lib/{kamal → dash}/commands/accessory.rb +2 -2
- data/lib/{kamal → dash}/commands/app/assets.rb +1 -1
- data/lib/{kamal → dash}/commands/app/containers.rb +1 -1
- data/lib/{kamal → dash}/commands/app/error_pages.rb +2 -2
- data/lib/{kamal → dash}/commands/app/execution.rb +1 -1
- data/lib/{kamal → dash}/commands/app/images.rb +1 -1
- data/lib/{kamal → dash}/commands/app/logging.rb +1 -1
- data/lib/{kamal → dash}/commands/app/proxy.rb +1 -1
- data/lib/{kamal → dash}/commands/app.rb +1 -1
- data/lib/{kamal → dash}/commands/auditor.rb +3 -7
- data/lib/{kamal → dash}/commands/base.rb +39 -3
- data/lib/{kamal → dash}/commands/builder/base.rb +2 -2
- data/lib/{kamal → dash}/commands/builder/clone.rb +3 -3
- data/lib/{kamal → dash}/commands/builder/cloud.rb +1 -1
- data/lib/{kamal → dash}/commands/builder/hybrid.rb +1 -1
- data/lib/{kamal → dash}/commands/builder/local.rb +1 -1
- data/lib/{kamal → dash}/commands/builder/pack.rb +1 -1
- data/lib/{kamal → dash}/commands/builder/remote.rb +1 -1
- data/lib/{kamal → dash}/commands/builder.rb +7 -7
- data/lib/{kamal → dash}/commands/docker.rb +1 -1
- data/lib/{kamal → dash}/commands/hook.rb +1 -1
- data/lib/{kamal → dash}/commands/loadbalancer.rb +9 -8
- data/lib/{kamal → dash}/commands/lock.rb +2 -2
- data/lib/{kamal → dash}/commands/proxy/cert_transfer.rb +2 -2
- data/lib/{kamal → dash}/commands/proxy.rb +20 -10
- data/lib/{kamal → dash}/commands/prune.rb +1 -1
- data/lib/dash/commands/registry.rb +44 -0
- data/lib/{kamal → dash}/commands/server.rb +1 -5
- data/lib/dash/commands.rb +2 -0
- data/lib/{kamal → dash}/configuration/accessory.rb +11 -11
- data/lib/{kamal → dash}/configuration/alias.rb +3 -3
- data/lib/{kamal → dash}/configuration/boot.rb +2 -2
- data/lib/{kamal → dash}/configuration/builder.rb +7 -7
- data/lib/{kamal → dash}/configuration/docs/builder.yml +3 -3
- data/lib/{kamal → dash}/configuration/docs/configuration.yml +12 -5
- data/lib/{kamal → dash}/configuration/docs/env.yml +10 -10
- data/lib/{kamal → dash}/configuration/docs/proxy.yml +31 -8
- data/lib/{kamal → dash}/configuration/docs/registry.yml +5 -5
- data/lib/{kamal → dash}/configuration/env/tag.rb +2 -2
- data/lib/{kamal → dash}/configuration/env.rb +5 -5
- data/lib/{kamal → dash}/configuration/loadbalancer.rb +3 -3
- data/lib/{kamal → dash}/configuration/logging.rb +3 -3
- data/lib/{kamal → dash}/configuration/output.rb +4 -4
- data/lib/{kamal → dash}/configuration/proxy/acme.rb +4 -3
- data/lib/{kamal → dash}/configuration/proxy/boot.rb +7 -7
- data/lib/{kamal → dash}/configuration/proxy/run.rb +11 -11
- data/lib/{kamal → dash}/configuration/proxy.rb +15 -15
- data/lib/{kamal → dash}/configuration/registry.rb +3 -3
- data/lib/{kamal → dash}/configuration/role/healthcheck.rb +3 -3
- data/lib/{kamal → dash}/configuration/role.rb +12 -12
- data/lib/{kamal → dash}/configuration/servers.rb +4 -4
- data/lib/{kamal → dash}/configuration/ssh.rb +2 -2
- data/lib/{kamal → dash}/configuration/sshkit.rb +2 -2
- data/lib/{kamal → dash}/configuration/validation.rb +2 -2
- data/lib/{kamal → dash}/configuration/validator/accessory.rb +1 -1
- data/lib/{kamal → dash}/configuration/validator/alias.rb +2 -2
- data/lib/{kamal → dash}/configuration/validator/builder.rb +1 -1
- data/lib/dash/configuration/validator/configuration.rb +6 -0
- data/lib/{kamal → dash}/configuration/validator/env.rb +2 -2
- data/lib/{kamal → dash}/configuration/validator/proxy.rb +8 -8
- data/lib/{kamal → dash}/configuration/validator/registry.rb +1 -1
- data/lib/{kamal → dash}/configuration/validator/role.rb +1 -1
- data/lib/{kamal → dash}/configuration/validator/servers.rb +1 -1
- data/lib/{kamal → dash}/configuration/validator.rb +4 -4
- data/lib/{kamal → dash}/configuration/volume.rb +2 -2
- data/lib/{kamal → dash}/configuration.rb +39 -29
- data/lib/{kamal → dash}/docker.rb +1 -1
- data/lib/{kamal → dash}/env_file.rb +1 -1
- data/lib/{kamal → dash}/git.rb +1 -1
- data/lib/{kamal → dash}/otel_shipper.rb +3 -3
- data/lib/{kamal → dash}/output/base_logger.rb +1 -1
- data/lib/{kamal → dash}/output/file_logger.rb +1 -1
- data/lib/{kamal → dash}/output/formatter.rb +1 -1
- data/lib/{kamal → dash}/output/otel_logger.rb +3 -3
- data/lib/dash/project_directory.rb +28 -0
- data/lib/{kamal → dash}/secrets/adapters/aws_secrets_manager.rb +1 -1
- data/lib/{kamal → dash}/secrets/adapters/base.rb +2 -2
- data/lib/{kamal → dash}/secrets/adapters/bitwarden.rb +1 -1
- data/lib/{kamal → dash}/secrets/adapters/bitwarden_secrets_manager.rb +1 -1
- data/lib/{kamal → dash}/secrets/adapters/doppler.rb +1 -1
- data/lib/{kamal → dash}/secrets/adapters/enpass.rb +1 -1
- data/lib/{kamal → dash}/secrets/adapters/gcp_secret_manager.rb +1 -1
- data/lib/{kamal → dash}/secrets/adapters/last_pass.rb +1 -1
- data/lib/{kamal → dash}/secrets/adapters/one_password.rb +2 -2
- data/lib/{kamal → dash}/secrets/adapters/passbolt.rb +1 -1
- data/lib/{kamal → dash}/secrets/adapters/test.rb +1 -1
- data/lib/{kamal → dash}/secrets/adapters.rb +2 -2
- data/lib/{kamal → dash}/secrets/dotenv/inline_command_substitution.rb +2 -2
- data/lib/{kamal → dash}/secrets.rb +6 -6
- data/lib/{kamal → dash}/tags.rb +8 -3
- data/lib/{kamal → dash}/utils/sensitive.rb +1 -1
- data/lib/{kamal → dash}/utils.rb +15 -5
- data/lib/dash/version.rb +3 -0
- data/lib/{kamal.rb → dash.rb} +4 -4
- metadata +156 -154
- data/lib/kamal/cli/alias/command.rb +0 -10
- data/lib/kamal/cli/build/clone.rb +0 -59
- data/lib/kamal/cli/healthcheck/error.rb +0 -2
- data/lib/kamal/cli/templates/sample_hooks/docker-setup.sample +0 -3
- data/lib/kamal/cli/templates/sample_hooks/post-app-boot.sample +0 -3
- data/lib/kamal/cli/templates/sample_hooks/post-app-stop.sample +0 -9
- data/lib/kamal/cli/templates/sample_hooks/post-deploy.sample +0 -14
- data/lib/kamal/cli/templates/sample_hooks/post-proxy-deploy.sample +0 -3
- data/lib/kamal/cli/templates/sample_hooks/post-proxy-reboot.sample +0 -3
- data/lib/kamal/cli/templates/sample_hooks/pre-app-boot.sample +0 -3
- data/lib/kamal/cli/templates/sample_hooks/pre-proxy-deploy.sample +0 -3
- data/lib/kamal/cli/templates/sample_hooks/pre-proxy-reboot.sample +0 -3
- data/lib/kamal/commands/registry.rb +0 -38
- data/lib/kamal/commands.rb +0 -2
- data/lib/kamal/configuration/validator/configuration.rb +0 -6
- data/lib/kamal/version.rb +0 -3
- /data/lib/{kamal → dash}/configuration/docs/accessory.yml +0 -0
- /data/lib/{kamal → dash}/configuration/docs/alias.yml +0 -0
- /data/lib/{kamal → dash}/configuration/docs/boot.yml +0 -0
- /data/lib/{kamal → dash}/configuration/docs/logging.yml +0 -0
- /data/lib/{kamal → dash}/configuration/docs/output.yml +0 -0
- /data/lib/{kamal → dash}/configuration/docs/role.yml +0 -0
- /data/lib/{kamal → dash}/configuration/docs/servers.yml +0 -0
- /data/lib/{kamal → dash}/configuration/docs/ssh.yml +0 -0
- /data/lib/{kamal → dash}/configuration/docs/sshkit.yml +0 -0
- /data/lib/{kamal → dash}/sshkit_with_ext.rb +0 -0
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
class
|
|
1
|
+
class Dash::Cli::Proxy < Dash::Cli::Base
|
|
2
2
|
desc "boot", "Boot proxy on servers"
|
|
3
3
|
def boot
|
|
4
4
|
modify(lock: true, server_lock: true) do
|
|
5
|
-
on(
|
|
6
|
-
execute *
|
|
5
|
+
on(DASH.hosts) do |host|
|
|
6
|
+
execute *DASH.docker.create_network
|
|
7
7
|
rescue SSHKit::Command::Failed => e
|
|
8
8
|
raise unless e.message.include?("already exists")
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
# Skip proxy on loadbalancer host - the loadbalancer will handle it
|
|
12
|
-
proxy_hosts =
|
|
13
|
-
if
|
|
14
|
-
proxy_hosts = proxy_hosts - [
|
|
12
|
+
proxy_hosts = DASH.proxy_hosts
|
|
13
|
+
if DASH.config.proxy.loadbalancer_on_proxy_host?
|
|
14
|
+
proxy_hosts = proxy_hosts - [ DASH.config.proxy.effective_loadbalancer ]
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
drifted_hosts = Concurrent::Array.new
|
|
18
18
|
stale_hosts = Concurrent::Array.new
|
|
19
|
-
auto_reboot =
|
|
19
|
+
auto_reboot = DASH.config.proxy.reboot_on_deploy?
|
|
20
20
|
|
|
21
21
|
on(proxy_hosts) do |host|
|
|
22
|
-
execute *
|
|
22
|
+
execute *DASH.registry.login
|
|
23
23
|
|
|
24
|
-
proxy =
|
|
25
|
-
drift =
|
|
24
|
+
proxy = DASH.proxy(host)
|
|
25
|
+
drift = Dash::Cli::Proxy::Drift.new(host, self)
|
|
26
26
|
|
|
27
27
|
if drift.drifted? && auto_reboot
|
|
28
28
|
# Leave the old proxy serving until its serial reboot slot below.
|
|
@@ -32,8 +32,8 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
32
32
|
|
|
33
33
|
version = capture_with_info(*proxy.version).strip.presence
|
|
34
34
|
|
|
35
|
-
if version &&
|
|
36
|
-
raise "kamal-proxy version #{version} is too old, run `dash proxy reboot` in order to update to at least #{
|
|
35
|
+
if version && Dash::Utils.older_version?(version, Dash::Configuration::Proxy::Run::MINIMUM_VERSION)
|
|
36
|
+
raise "kamal-proxy version #{version} is too old, run `dash proxy reboot` in order to update to at least #{Dash::Configuration::Proxy::Run::MINIMUM_VERSION}"
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
if (run_config = proxy.proxy_run_config)&.secrets?
|
|
@@ -59,56 +59,56 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
59
59
|
say "kamal-proxy configuration changed, rebooting on #{host}...", :magenta
|
|
60
60
|
run_hook "pre-proxy-reboot", hosts: host
|
|
61
61
|
on(host) do |h|
|
|
62
|
-
|
|
62
|
+
Dash::Cli::Proxy::Reboot.new(h, self).run
|
|
63
63
|
end
|
|
64
64
|
run_hook "post-proxy-reboot", hosts: host
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
if
|
|
67
|
+
if DASH.config.proxy.load_balancing?
|
|
68
68
|
lb_drifted = Concurrent::Array.new
|
|
69
69
|
lb_stale = Concurrent::Array.new
|
|
70
70
|
|
|
71
|
-
on(
|
|
71
|
+
on(DASH.config.proxy.effective_loadbalancer) do |host|
|
|
72
72
|
info "Starting loadbalancer on #{host}..."
|
|
73
|
-
execute *
|
|
73
|
+
execute *DASH.registry.login
|
|
74
74
|
|
|
75
75
|
# The load balancer terminates TLS and owns the cache, so its host
|
|
76
76
|
# needs the proxy secrets (acme credentials, cache store) just like
|
|
77
77
|
# the proxy hosts do.
|
|
78
|
-
if (lb_run =
|
|
79
|
-
execute *
|
|
78
|
+
if (lb_run = DASH.loadbalancer_config.run).secrets?
|
|
79
|
+
execute *DASH.loadbalancer.ensure_proxy_directory
|
|
80
80
|
upload! lb_run.secrets_io, lb_run.secrets_path, mode: "0600"
|
|
81
81
|
else
|
|
82
|
-
execute *
|
|
82
|
+
execute *DASH.loadbalancer.remove_proxy_secrets_file, raise_on_non_zero_exit: false
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
execute *
|
|
85
|
+
execute *DASH.loadbalancer.ensure_apps_config_directory
|
|
86
86
|
|
|
87
87
|
# TLS terminates at the load balancer, so the TLS material the app
|
|
88
88
|
# hosts get - custom certificates and the mTLS client CA - must
|
|
89
89
|
# reach this host too; the LB container reads it through the same
|
|
90
90
|
# apps-config mount the per-host proxies use.
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
DASH.config.roles.select(&:running_proxy?).each do |role|
|
|
92
|
+
Dash::Cli::App::SslCertificates.new(host, role, self).run
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
# The same drift detection the proxy hosts get: a loadbalancer booted
|
|
96
96
|
# with a different config digest reboots below (or warns, when
|
|
97
97
|
# automatic reboot is off) instead of serving a stale config forever.
|
|
98
|
-
container_id = capture_with_info(*
|
|
99
|
-
current_digest = capture_with_info(*
|
|
98
|
+
container_id = capture_with_info(*DASH.loadbalancer.container_id, raise_on_non_zero_exit: false).strip
|
|
99
|
+
current_digest = capture_with_info(*DASH.loadbalancer.config_digest, raise_on_non_zero_exit: false).strip
|
|
100
100
|
|
|
101
|
-
if container_id.present? && current_digest !=
|
|
101
|
+
if container_id.present? && current_digest != DASH.loadbalancer_config.run_config_digest
|
|
102
102
|
if auto_reboot
|
|
103
103
|
# Leave the old loadbalancer serving until its reboot below.
|
|
104
104
|
lb_drifted << host.to_s
|
|
105
105
|
else
|
|
106
106
|
lb_stale << host.to_s
|
|
107
|
-
execute *
|
|
107
|
+
execute *DASH.loadbalancer.start_or_run
|
|
108
108
|
end
|
|
109
109
|
else
|
|
110
|
-
|
|
111
|
-
execute *
|
|
110
|
+
Dash::Cli::Proxy::LoadbalancerClaim.new(host, self).claim_run_config
|
|
111
|
+
execute *DASH.loadbalancer.start_or_run
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
|
|
@@ -121,7 +121,7 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
121
121
|
say "Loadbalancer configuration changed, rebooting on #{host}...", :magenta
|
|
122
122
|
run_hook "pre-loadbalancer-reboot", hosts: host
|
|
123
123
|
on(host) do |h|
|
|
124
|
-
|
|
124
|
+
Dash::Cli::Proxy::LoadbalancerReboot.new(h, self).run
|
|
125
125
|
end
|
|
126
126
|
run_hook "post-loadbalancer-reboot", hosts: host
|
|
127
127
|
end
|
|
@@ -132,9 +132,9 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
132
132
|
desc "boot_config <set|get|reset>", "Manage kamal-proxy boot configuration"
|
|
133
133
|
option :publish, type: :boolean, default: true, desc: "Publish the proxy ports on the host"
|
|
134
134
|
option :publish_host_ip, type: :string, repeatable: true, default: nil, desc: "Host IP address to bind HTTP/HTTPS traffic to. Defaults to all interfaces"
|
|
135
|
-
option :http_port, type: :numeric, default:
|
|
136
|
-
option :https_port, type: :numeric, default:
|
|
137
|
-
option :log_max_size, type: :string, default:
|
|
135
|
+
option :http_port, type: :numeric, default: Dash::Configuration::Proxy::Run::DEFAULT_HTTP_PORT, desc: "HTTP port to publish on the host"
|
|
136
|
+
option :https_port, type: :numeric, default: Dash::Configuration::Proxy::Run::DEFAULT_HTTPS_PORT, desc: "HTTPS port to publish on the host"
|
|
137
|
+
option :log_max_size, type: :string, default: Dash::Configuration::Proxy::Run::DEFAULT_LOG_MAX_SIZE, desc: "Max size of proxy logs"
|
|
138
138
|
option :registry, type: :string, default: nil, desc: "Registry to use for the proxy image"
|
|
139
139
|
option :repository, type: :string, default: nil, desc: "Repository for the proxy image"
|
|
140
140
|
option :image_version, type: :string, default: nil, desc: "Version of the proxy to run"
|
|
@@ -143,7 +143,7 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
143
143
|
option :docker_options, type: :array, default: [], desc: "Docker options to pass to the proxy container", banner: "option=value option2=value2"
|
|
144
144
|
def boot_config(subcommand)
|
|
145
145
|
say "The proxy boot_config command is deprecated - set the config in the deploy YAML at proxy/run instead", :yellow
|
|
146
|
-
proxy_boot_config =
|
|
146
|
+
proxy_boot_config = DASH.config.proxy_boot
|
|
147
147
|
|
|
148
148
|
case subcommand
|
|
149
149
|
when "set"
|
|
@@ -163,10 +163,10 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
163
163
|
image_version = options[:image_version]
|
|
164
164
|
|
|
165
165
|
run_command_options = { debug: options[:debug] || nil, "metrics-port": options[:metrics_port] }.compact
|
|
166
|
-
run_command = "kamal-proxy run #{
|
|
166
|
+
run_command = "kamal-proxy run #{Dash::Utils.optionize(run_command_options).join(" ")}" if run_command_options.any?
|
|
167
167
|
|
|
168
|
-
on(
|
|
169
|
-
proxy =
|
|
168
|
+
on(DASH.proxy_hosts) do |host|
|
|
169
|
+
proxy = DASH.proxy(host)
|
|
170
170
|
execute(*proxy.ensure_proxy_directory)
|
|
171
171
|
if boot_options != proxy_boot_config.default_boot_options
|
|
172
172
|
upload! StringIO.new(boot_options.join(" ")), proxy_boot_config.options_file
|
|
@@ -194,12 +194,12 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
194
194
|
end
|
|
195
195
|
when "get"
|
|
196
196
|
|
|
197
|
-
on(
|
|
198
|
-
puts "Host #{host}: #{capture_with_info(*
|
|
197
|
+
on(DASH.proxy_hosts) do |host|
|
|
198
|
+
puts "Host #{host}: #{capture_with_info(*DASH.proxy(host).boot_config)}"
|
|
199
199
|
end
|
|
200
200
|
when "reset"
|
|
201
|
-
on(
|
|
202
|
-
proxy =
|
|
201
|
+
on(DASH.proxy_hosts) do |host|
|
|
202
|
+
proxy = DASH.proxy(host)
|
|
203
203
|
execute *proxy.reset_boot_options, raise_on_non_zero_exit: false
|
|
204
204
|
execute *proxy.reset_image, raise_on_non_zero_exit: false
|
|
205
205
|
execute *proxy.reset_image_version, raise_on_non_zero_exit: false
|
|
@@ -217,9 +217,9 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
217
217
|
confirming "This will cause a brief outage on each host. Are you sure?" do
|
|
218
218
|
modify(lock: true, server_lock: true) do
|
|
219
219
|
# Skip proxy on loadbalancer host - it will be handled by loadbalancer reboot
|
|
220
|
-
proxy_hosts =
|
|
221
|
-
if
|
|
222
|
-
proxy_hosts = proxy_hosts - [
|
|
220
|
+
proxy_hosts = DASH.proxy_hosts
|
|
221
|
+
if DASH.config.proxy.loadbalancer_on_proxy_host?
|
|
222
|
+
proxy_hosts = proxy_hosts - [ DASH.config.proxy.effective_loadbalancer ]
|
|
223
223
|
end
|
|
224
224
|
|
|
225
225
|
host_groups = options[:rolling] ? proxy_hosts : [ proxy_hosts ]
|
|
@@ -230,17 +230,17 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
230
230
|
run_hook "pre-proxy-reboot", hosts: host_list
|
|
231
231
|
on(hosts) do |host|
|
|
232
232
|
info "Rebooting kamal-proxy on #{host}..."
|
|
233
|
-
|
|
233
|
+
Dash::Cli::Proxy::Reboot.new(host, self).run
|
|
234
234
|
end
|
|
235
235
|
run_hook "post-proxy-reboot", hosts: host_list
|
|
236
236
|
end
|
|
237
237
|
|
|
238
|
-
if
|
|
239
|
-
lb_host =
|
|
238
|
+
if DASH.config.proxy.load_balancing?
|
|
239
|
+
lb_host = DASH.config.proxy.effective_loadbalancer
|
|
240
240
|
run_hook "pre-loadbalancer-reboot", hosts: lb_host
|
|
241
241
|
|
|
242
242
|
on(lb_host) do |host|
|
|
243
|
-
|
|
243
|
+
Dash::Cli::Proxy::LoadbalancerReboot.new(host, self).run
|
|
244
244
|
end
|
|
245
245
|
|
|
246
246
|
run_hook "post-loadbalancer-reboot", hosts: lb_host
|
|
@@ -253,18 +253,18 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
253
253
|
option :rolling, type: :boolean, default: false, desc: "Reboot proxy on hosts in sequence, rather than in parallel"
|
|
254
254
|
option :confirmed, aliases: "-y", type: :boolean, default: false, desc: "Proceed without confirmation question"
|
|
255
255
|
def upgrade
|
|
256
|
-
invoke_options = { "version" =>
|
|
256
|
+
invoke_options = { "version" => DASH.config.latest_tag }.merge(options)
|
|
257
257
|
|
|
258
258
|
confirming "This will cause a brief outage on each host. Are you sure?" do
|
|
259
|
-
host_groups = options[:rolling] ?
|
|
259
|
+
host_groups = options[:rolling] ? DASH.hosts : [ DASH.hosts ]
|
|
260
260
|
host_groups.each do |hosts|
|
|
261
261
|
host_list = Array(hosts).join(",")
|
|
262
262
|
say "Upgrading proxy on #{host_list}...", :magenta
|
|
263
263
|
run_hook "pre-proxy-reboot", hosts: host_list
|
|
264
264
|
on(hosts) do |host|
|
|
265
|
-
proxy =
|
|
266
|
-
execute *
|
|
267
|
-
execute *
|
|
265
|
+
proxy = DASH.proxy(host)
|
|
266
|
+
execute *DASH.auditor.record("Rebooted proxy"), verbosity: :debug
|
|
267
|
+
execute *DASH.registry.login
|
|
268
268
|
|
|
269
269
|
info "Stopping and removing Traefik on #{host}, if running..."
|
|
270
270
|
execute *proxy.cleanup_traefik
|
|
@@ -275,13 +275,13 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
275
275
|
execute *proxy.remove_image
|
|
276
276
|
end
|
|
277
277
|
|
|
278
|
-
|
|
279
|
-
invoke "
|
|
280
|
-
reset_invocation(
|
|
281
|
-
invoke "
|
|
282
|
-
reset_invocation(
|
|
283
|
-
invoke "
|
|
284
|
-
reset_invocation(
|
|
278
|
+
DASH.with_specific_hosts(hosts) do
|
|
279
|
+
invoke "dash:cli:proxy:boot", [], invoke_options
|
|
280
|
+
reset_invocation(Dash::Cli::Proxy)
|
|
281
|
+
invoke "dash:cli:app:boot", [], invoke_options
|
|
282
|
+
reset_invocation(Dash::Cli::App)
|
|
283
|
+
invoke "dash:cli:prune:all", [], invoke_options
|
|
284
|
+
reset_invocation(Dash::Cli::Prune)
|
|
285
285
|
end
|
|
286
286
|
|
|
287
287
|
run_hook "post-proxy-reboot", hosts: host_list
|
|
@@ -293,15 +293,15 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
293
293
|
desc "start", "Start existing proxy container on servers"
|
|
294
294
|
def start
|
|
295
295
|
modify(lock: true, server_lock: true) do
|
|
296
|
-
on(
|
|
297
|
-
execute *
|
|
298
|
-
execute *
|
|
296
|
+
on(DASH.proxy_hosts) do |host|
|
|
297
|
+
execute *DASH.auditor.record("Started proxy"), verbosity: :debug
|
|
298
|
+
execute *DASH.proxy(host).start
|
|
299
299
|
end
|
|
300
300
|
|
|
301
|
-
if
|
|
302
|
-
on(
|
|
303
|
-
execute *
|
|
304
|
-
execute *
|
|
301
|
+
if DASH.config.proxy.load_balancing?
|
|
302
|
+
on(DASH.config.proxy.effective_loadbalancer) do
|
|
303
|
+
execute *DASH.auditor.record("Started loadbalancer"), verbosity: :debug
|
|
304
|
+
execute *DASH.loadbalancer.start, raise_on_non_zero_exit: false
|
|
305
305
|
end
|
|
306
306
|
end
|
|
307
307
|
end
|
|
@@ -310,18 +310,18 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
310
310
|
desc "stop", "Stop existing proxy container on servers"
|
|
311
311
|
def stop
|
|
312
312
|
modify(lock: true, server_lock: true) do
|
|
313
|
-
on(
|
|
314
|
-
execute *
|
|
315
|
-
execute *
|
|
313
|
+
on(DASH.proxy_hosts) do |host|
|
|
314
|
+
execute *DASH.auditor.record("Stopped proxy"), verbosity: :debug
|
|
315
|
+
execute *DASH.proxy(host).stop, raise_on_non_zero_exit: false
|
|
316
316
|
end
|
|
317
317
|
|
|
318
318
|
# `docker container prune` only collects stopped containers, so leaving the
|
|
319
319
|
# loadbalancer running would also leave `dash proxy remove` unable to
|
|
320
320
|
# remove it.
|
|
321
|
-
if
|
|
322
|
-
on(
|
|
323
|
-
execute *
|
|
324
|
-
execute *
|
|
321
|
+
if DASH.config.proxy.load_balancing?
|
|
322
|
+
on(DASH.config.proxy.effective_loadbalancer) do
|
|
323
|
+
execute *DASH.auditor.record("Stopped loadbalancer"), verbosity: :debug
|
|
324
|
+
execute *DASH.loadbalancer.stop, raise_on_non_zero_exit: false
|
|
325
325
|
end
|
|
326
326
|
end
|
|
327
327
|
end
|
|
@@ -338,11 +338,11 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
338
338
|
desc "details", "Show details about proxy container from servers"
|
|
339
339
|
def details
|
|
340
340
|
quiet = options[:quiet]
|
|
341
|
-
on(
|
|
341
|
+
on(DASH.proxy_hosts) { |host| puts_by_host host, capture_with_info(*DASH.proxy(host).info), type: "Proxy", quiet: quiet }
|
|
342
342
|
|
|
343
|
-
if
|
|
344
|
-
on(
|
|
345
|
-
puts_by_host host, capture_with_info(*
|
|
343
|
+
if DASH.config.proxy.load_balancing?
|
|
344
|
+
on(DASH.config.proxy.effective_loadbalancer) do |host|
|
|
345
|
+
puts_by_host host, capture_with_info(*DASH.loadbalancer.info), type: "Loadbalancer"
|
|
346
346
|
end
|
|
347
347
|
end
|
|
348
348
|
end
|
|
@@ -359,17 +359,17 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
359
359
|
|
|
360
360
|
if options[:follow]
|
|
361
361
|
run_locally do
|
|
362
|
-
proxy =
|
|
363
|
-
info "Following logs on #{
|
|
364
|
-
info proxy.follow_logs(host:
|
|
365
|
-
exec proxy.follow_logs(host:
|
|
362
|
+
proxy = DASH.proxy(DASH.primary_host)
|
|
363
|
+
info "Following logs on #{DASH.primary_host}..."
|
|
364
|
+
info proxy.follow_logs(host: DASH.primary_host, timestamps: timestamps, grep: grep)
|
|
365
|
+
exec proxy.follow_logs(host: DASH.primary_host, timestamps: timestamps, grep: grep)
|
|
366
366
|
end
|
|
367
367
|
else
|
|
368
368
|
since = options[:since]
|
|
369
369
|
lines = options[:lines].presence || ((since || grep) ? nil : 100) # Default to 100 lines if since or grep isn't set
|
|
370
370
|
|
|
371
|
-
on(
|
|
372
|
-
puts_by_host host, capture(*
|
|
371
|
+
on(DASH.proxy_hosts) do |host|
|
|
372
|
+
puts_by_host host, capture(*DASH.proxy(host).logs(timestamps: timestamps, since: since, lines: lines, grep: grep)), type: "Proxy"
|
|
373
373
|
end
|
|
374
374
|
end
|
|
375
375
|
end
|
|
@@ -391,47 +391,47 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
391
391
|
def loadbalancer(status)
|
|
392
392
|
case status
|
|
393
393
|
when "info"
|
|
394
|
-
if
|
|
395
|
-
on(
|
|
394
|
+
if DASH.config.proxy.load_balancing?
|
|
395
|
+
on(DASH.config.proxy.effective_loadbalancer) do |host|
|
|
396
396
|
puts "Loadbalancer status on #{host}:"
|
|
397
|
-
puts capture_with_info(*
|
|
397
|
+
puts capture_with_info(*DASH.loadbalancer.info)
|
|
398
398
|
end
|
|
399
399
|
else
|
|
400
400
|
puts "Load balancing is not configured"
|
|
401
401
|
end
|
|
402
402
|
when "start"
|
|
403
|
-
if
|
|
404
|
-
on(
|
|
405
|
-
execute *
|
|
406
|
-
execute *
|
|
403
|
+
if DASH.config.proxy.load_balancing?
|
|
404
|
+
on(DASH.config.proxy.effective_loadbalancer) do |host|
|
|
405
|
+
execute *DASH.registry.login
|
|
406
|
+
execute *DASH.loadbalancer.start_or_run
|
|
407
407
|
end
|
|
408
408
|
else
|
|
409
409
|
puts "Load balancing is not configured"
|
|
410
410
|
end
|
|
411
411
|
when "stop"
|
|
412
|
-
if
|
|
413
|
-
on(
|
|
414
|
-
execute *
|
|
412
|
+
if DASH.config.proxy.load_balancing?
|
|
413
|
+
on(DASH.config.proxy.effective_loadbalancer) do |host|
|
|
414
|
+
execute *DASH.loadbalancer.stop, raise_on_non_zero_exit: false
|
|
415
415
|
end
|
|
416
416
|
else
|
|
417
417
|
puts "Load balancing is not configured"
|
|
418
418
|
end
|
|
419
419
|
when "logs"
|
|
420
|
-
if
|
|
421
|
-
on(
|
|
422
|
-
puts_by_host host, capture(*
|
|
420
|
+
if DASH.config.proxy.load_balancing?
|
|
421
|
+
on(DASH.config.proxy.effective_loadbalancer) do |host|
|
|
422
|
+
puts_by_host host, capture(*DASH.loadbalancer.logs(timestamps: true)), type: "Loadbalancer"
|
|
423
423
|
end
|
|
424
424
|
else
|
|
425
425
|
puts "Load balancing is not configured"
|
|
426
426
|
end
|
|
427
427
|
when "deploy"
|
|
428
|
-
if
|
|
429
|
-
targets =
|
|
428
|
+
if DASH.config.proxy.load_balancing?
|
|
429
|
+
targets = DASH.loadbalancer_config.target_hosts
|
|
430
430
|
|
|
431
|
-
on(
|
|
432
|
-
|
|
431
|
+
on(DASH.config.proxy.effective_loadbalancer) do |host|
|
|
432
|
+
Dash::Cli::Proxy::LoadbalancerClaim.new(host, self).claim_service
|
|
433
433
|
info "Deploying to loadbalancer on #{host} with targets: #{targets.join(', ')}"
|
|
434
|
-
execute *
|
|
434
|
+
execute *DASH.loadbalancer.deploy(targets: targets)
|
|
435
435
|
end
|
|
436
436
|
else
|
|
437
437
|
puts "Load balancing is not configured"
|
|
@@ -453,29 +453,29 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
453
453
|
# The cache lives where its policy applies: at the loadbalancer when
|
|
454
454
|
# load balancing (cache is edge-only in the layering contract),
|
|
455
455
|
# otherwise on each proxy host.
|
|
456
|
-
if
|
|
457
|
-
on(
|
|
458
|
-
puts_by_host host, capture_with_info(*
|
|
456
|
+
if DASH.config.proxy.load_balancing?
|
|
457
|
+
on(DASH.config.proxy.effective_loadbalancer) do |host|
|
|
458
|
+
puts_by_host host, capture_with_info(*DASH.loadbalancer.cache_stats(count: count, json: json)), type: "Loadbalancer"
|
|
459
459
|
end
|
|
460
460
|
else
|
|
461
|
-
on(
|
|
462
|
-
puts_by_host host, capture_with_info(*
|
|
461
|
+
on(DASH.proxy_hosts) do |host|
|
|
462
|
+
puts_by_host host, capture_with_info(*DASH.proxy(host).cache_stats(count: count, json: json)), type: "Proxy"
|
|
463
463
|
end
|
|
464
464
|
end
|
|
465
465
|
when "purge"
|
|
466
|
-
if
|
|
466
|
+
if DASH.config.proxy.load_balancing?
|
|
467
467
|
# The loadbalancer registers one service under the bare service name.
|
|
468
|
-
on(
|
|
469
|
-
execute *
|
|
470
|
-
puts_by_host host, capture_with_info(*
|
|
468
|
+
on(DASH.config.proxy.effective_loadbalancer) do |host|
|
|
469
|
+
execute *DASH.auditor.record("Purged the response cache"), verbosity: :debug
|
|
470
|
+
puts_by_host host, capture_with_info(*DASH.loadbalancer.cache_purge(DASH.config.service, path_prefix: path_prefix)), type: "Loadbalancer"
|
|
471
471
|
end
|
|
472
472
|
else
|
|
473
473
|
# Each proxied role registered its own service, so purge walks them.
|
|
474
|
-
on(
|
|
475
|
-
execute *
|
|
474
|
+
on(DASH.proxy_hosts) do |host|
|
|
475
|
+
execute *DASH.auditor.record("Purged the response cache"), verbosity: :debug
|
|
476
476
|
|
|
477
|
-
|
|
478
|
-
puts_by_host host, capture_with_info(*
|
|
477
|
+
DASH.roles_on(host).select(&:running_proxy?).each do |role|
|
|
478
|
+
puts_by_host host, capture_with_info(*DASH.proxy(host).cache_purge(role.container_prefix, path_prefix: path_prefix)), type: "Proxy"
|
|
479
479
|
end
|
|
480
480
|
end
|
|
481
481
|
end
|
|
@@ -484,37 +484,49 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
484
484
|
end
|
|
485
485
|
end
|
|
486
486
|
|
|
487
|
-
desc "domains SUBCOMMAND", "
|
|
488
|
-
|
|
487
|
+
desc "domains SUBCOMMAND [ARGS]", "Inspect TLS domains and their certificate issuance (refresh, list, stats, retry)"
|
|
488
|
+
long_desc <<~DESC
|
|
489
|
+
Inspect the TLS domains this proxy serves, and the state of their certificates.
|
|
490
|
+
|
|
491
|
+
`list` shows every domain — both those learned from a domain source and the
|
|
492
|
+
hosts named in deploy.yml — with whether it holds a certificate and, if
|
|
493
|
+
issuance is held, when the hold lifts and why.
|
|
494
|
+
|
|
495
|
+
A hold normally clears itself: the proxy re-checks held domains and issues as
|
|
496
|
+
soon as the domain points at it, so a DNS cutover needs no intervention.
|
|
497
|
+
`retry HOST` (or `retry --all`) is for when you already know the cause is
|
|
498
|
+
fixed and would rather not wait.
|
|
499
|
+
DESC
|
|
500
|
+
def domains(subcommand, *args)
|
|
489
501
|
case subcommand
|
|
490
|
-
when "refresh", "list", "stats"
|
|
502
|
+
when "refresh", "list", "stats", "retry"
|
|
491
503
|
# TLS terminates at the load balancer when load balancing, so the
|
|
492
504
|
# dynamic domain set lives there rather than on the per-host proxies.
|
|
493
|
-
if
|
|
494
|
-
on(
|
|
495
|
-
puts_by_host host, capture_with_info(*
|
|
505
|
+
if DASH.config.proxy.load_balancing?
|
|
506
|
+
on(DASH.config.proxy.effective_loadbalancer) do |host|
|
|
507
|
+
puts_by_host host, capture_with_info(*DASH.loadbalancer.domains(subcommand, *args)), type: "Loadbalancer"
|
|
496
508
|
end
|
|
497
509
|
else
|
|
498
|
-
on(
|
|
499
|
-
puts_by_host host, capture_with_info(*
|
|
510
|
+
on(DASH.proxy_hosts) do |host|
|
|
511
|
+
puts_by_host host, capture_with_info(*DASH.proxy(host).domains(subcommand, *args)), type: "Proxy"
|
|
500
512
|
end
|
|
501
513
|
end
|
|
502
514
|
else
|
|
503
|
-
puts "Unknown domains subcommand: #{subcommand}. Available: refresh, list, stats"
|
|
515
|
+
puts "Unknown domains subcommand: #{subcommand}. Available: refresh, list, stats, retry"
|
|
504
516
|
end
|
|
505
517
|
end
|
|
506
518
|
|
|
507
519
|
desc "export_certs LOCAL_PATH", "Export the TLS certificate store to a local archive (contains private keys)"
|
|
508
520
|
def export_certs(local_path)
|
|
509
|
-
load_balancing =
|
|
521
|
+
load_balancing = DASH.config.proxy.load_balancing?
|
|
510
522
|
|
|
511
523
|
# Under the deploy lock: a concurrent deploy could boot or reboot the
|
|
512
524
|
# proxy mid-export, and the offline read below would archive a torn store.
|
|
513
525
|
modify(lock: true, server_lock: true) do
|
|
514
526
|
on(cert_store_host) do |host|
|
|
515
|
-
execute *
|
|
527
|
+
execute *DASH.auditor.record("Exported the proxy certificate store"), verbosity: :debug
|
|
516
528
|
|
|
517
|
-
commands = load_balancing ?
|
|
529
|
+
commands = load_balancing ? DASH.loadbalancer : DASH.proxy(host)
|
|
518
530
|
execute *commands.ensure_apps_config_directory
|
|
519
531
|
|
|
520
532
|
# Running: export through the container's RPC socket, under the proxy's
|
|
@@ -523,7 +535,7 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
523
535
|
if capture_with_info(*commands.container_id(only_running: true), raise_on_non_zero_exit: false).strip.present?
|
|
524
536
|
puts capture_with_info(*commands.export_certs)
|
|
525
537
|
else
|
|
526
|
-
execute *
|
|
538
|
+
execute *DASH.registry.login
|
|
527
539
|
puts capture_with_info(*commands.export_certs_offline)
|
|
528
540
|
end
|
|
529
541
|
|
|
@@ -548,11 +560,11 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
548
560
|
source = options[:traefik_acme] || options[:archive]
|
|
549
561
|
traefik_acme, resolver = options[:traefik_acme].present?, options[:resolver]
|
|
550
562
|
force, verify = options[:force], options[:verify]
|
|
551
|
-
load_balancing =
|
|
563
|
+
load_balancing = DASH.config.proxy.load_balancing?
|
|
552
564
|
|
|
553
565
|
modify(lock: true, server_lock: true) do
|
|
554
566
|
on(cert_store_host) do |host|
|
|
555
|
-
commands = load_balancing ?
|
|
567
|
+
commands = load_balancing ? DASH.loadbalancer : DASH.proxy(host)
|
|
556
568
|
|
|
557
569
|
# kamal-proxy import runs offline against the data directory - importing
|
|
558
570
|
# under a live proxy risks a torn store. --verify only reads the archive.
|
|
@@ -564,8 +576,8 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
564
576
|
end
|
|
565
577
|
end
|
|
566
578
|
|
|
567
|
-
execute *
|
|
568
|
-
execute *
|
|
579
|
+
execute *DASH.auditor.record("Imported certificates into the proxy certificate store"), verbosity: :debug
|
|
580
|
+
execute *DASH.registry.login
|
|
569
581
|
execute *commands.ensure_proxy_directory
|
|
570
582
|
|
|
571
583
|
# upload! inside the ensure's reach: a failed or partial upload must
|
|
@@ -584,15 +596,15 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
584
596
|
desc "remove_container", "Remove proxy container from servers", hide: true
|
|
585
597
|
def remove_container
|
|
586
598
|
modify(lock: true, server_lock: true) do
|
|
587
|
-
on(
|
|
588
|
-
execute *
|
|
589
|
-
execute *
|
|
599
|
+
on(DASH.proxy_hosts) do
|
|
600
|
+
execute *DASH.auditor.record("Removed proxy container"), verbosity: :debug
|
|
601
|
+
execute *DASH.proxy(host).remove_container
|
|
590
602
|
end
|
|
591
603
|
|
|
592
|
-
if
|
|
593
|
-
on(
|
|
594
|
-
execute *
|
|
595
|
-
execute *
|
|
604
|
+
if DASH.config.proxy.load_balancing?
|
|
605
|
+
on(DASH.config.proxy.effective_loadbalancer) do
|
|
606
|
+
execute *DASH.auditor.record("Removed loadbalancer container"), verbosity: :debug
|
|
607
|
+
execute *DASH.loadbalancer.remove_container
|
|
596
608
|
end
|
|
597
609
|
end
|
|
598
610
|
end
|
|
@@ -601,15 +613,15 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
601
613
|
desc "remove_image", "Remove proxy image from servers", hide: true
|
|
602
614
|
def remove_image
|
|
603
615
|
modify(lock: true, server_lock: true) do
|
|
604
|
-
on(
|
|
605
|
-
execute *
|
|
606
|
-
execute *
|
|
616
|
+
on(DASH.proxy_hosts) do
|
|
617
|
+
execute *DASH.auditor.record("Removed proxy image"), verbosity: :debug
|
|
618
|
+
execute *DASH.proxy(host).remove_image
|
|
607
619
|
end
|
|
608
620
|
|
|
609
|
-
if
|
|
610
|
-
on(
|
|
611
|
-
execute *
|
|
612
|
-
execute *
|
|
621
|
+
if DASH.config.proxy.load_balancing?
|
|
622
|
+
on(DASH.config.proxy.effective_loadbalancer) do
|
|
623
|
+
execute *DASH.auditor.record("Removed loadbalancer image"), verbosity: :debug
|
|
624
|
+
execute *DASH.loadbalancer.remove_image
|
|
613
625
|
end
|
|
614
626
|
end
|
|
615
627
|
end
|
|
@@ -618,15 +630,15 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
618
630
|
desc "remove_proxy_directory", "Remove the proxy directory from servers", hide: true
|
|
619
631
|
def remove_proxy_directory
|
|
620
632
|
modify(lock: true, server_lock: true) do
|
|
621
|
-
on(
|
|
622
|
-
execute *
|
|
633
|
+
on(DASH.proxy_hosts) do
|
|
634
|
+
execute *DASH.proxy(host).remove_proxy_directory, raise_on_non_zero_exit: false
|
|
623
635
|
end
|
|
624
636
|
|
|
625
637
|
# Otherwise the ownership registry outlives the load balancer and a later
|
|
626
638
|
# boot would fail against an owner that no longer exists.
|
|
627
|
-
if
|
|
628
|
-
on(
|
|
629
|
-
execute *
|
|
639
|
+
if DASH.config.proxy.load_balancing?
|
|
640
|
+
on(DASH.config.proxy.effective_loadbalancer) do
|
|
641
|
+
execute *DASH.loadbalancer.remove_directory, raise_on_non_zero_exit: false
|
|
630
642
|
end
|
|
631
643
|
end
|
|
632
644
|
end
|
|
@@ -637,7 +649,7 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
637
649
|
# host when load balancing (TLS terminates at the edge), else the primary
|
|
638
650
|
# host - the same host `loadbalancer: true` would resolve to.
|
|
639
651
|
def cert_store_host
|
|
640
|
-
|
|
652
|
+
DASH.config.proxy.load_balancing? ? DASH.config.proxy.effective_loadbalancer : DASH.primary_host
|
|
641
653
|
end
|
|
642
654
|
|
|
643
655
|
# Mirrors kamal-proxy's own flag groups (import.go), so a contradictory
|
|
@@ -664,14 +676,14 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base
|
|
|
664
676
|
# has to cover the load balancer host too - `remove_container` and
|
|
665
677
|
# `remove_image` both act on it.
|
|
666
678
|
def removal_hosts
|
|
667
|
-
hosts =
|
|
668
|
-
hosts |= [
|
|
679
|
+
hosts = DASH.proxy_hosts.to_a
|
|
680
|
+
hosts |= [ DASH.config.proxy.effective_loadbalancer ] if DASH.config.proxy.load_balancing?
|
|
669
681
|
hosts
|
|
670
682
|
end
|
|
671
683
|
|
|
672
684
|
def removal_allowed?(force)
|
|
673
685
|
on(removal_hosts) do |host|
|
|
674
|
-
app_count = capture_with_info(*
|
|
686
|
+
app_count = capture_with_info(*DASH.server.app_directory_count).chomp.to_i
|
|
675
687
|
raise "The are other applications installed on #{host}" if app_count > 0
|
|
676
688
|
end
|
|
677
689
|
|