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