Upgrade commands for Kamal 1.x -> 2.0
Adds: - `kamal upgrade` to upgrade all app hosts and accessory hosts - `kamal proxy upgrade` to upgrade the proxy on all hosts - `kamal accessory upgrade [name]` to upgrade accessories on all hosts Upgrade takes rolling and confirmed options and calls `proxy upgrade` and `accessory upgrade` in turn. To just upgrade a single host add -h [host] to the command. But the upgrade should run on all hosts, not just those running the proxy. Calling upgrade on a host that has already been upgraded should work ok. Upgrading hosts causes downtime but you can avoid if you run multiple hosts by: 1. Implementing the pre-proxy-reboot and post-proxy-reboot hooks to remove the host from external load balancers 2. Running the upgrade with the --rolling option **kamal proxy upgrade** 1. Creates a `kamal` network if required 2. Stops and removes the old proxy (whether Traefik or kamal-proxy) 3. Starts a kamal-proxy container in the `kamal` network 4. Reboots the app containers in the `kamal` network **kamal accessory upgrade [name]** 1. Creates a `kamal` network if required 2. Reboots the accessory containers in the `kamal` network A matching `downgrade` command will be added to Kamal 1.9.
This commit is contained in:
@@ -486,6 +486,34 @@ class CliMainTest < CliTestCase
|
||||
end
|
||||
end
|
||||
|
||||
test "upgrade" do
|
||||
invoke_options = { "config_file" => "test/fixtures/deploy_with_accessories.yml", "skip_hooks" => false, "confirmed" => true, "rolling" => false }
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:proxy:upgrade", [], invoke_options)
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:accessory:upgrade", [ "all" ], invoke_options)
|
||||
|
||||
run_command("upgrade", "-y", config_file: "deploy_with_accessories").tap do |output|
|
||||
assert_match "Upgrading all hosts...", output
|
||||
assert_match "Upgraded all hosts", output
|
||||
end
|
||||
end
|
||||
|
||||
test "upgrade rolling" do
|
||||
invoke_options = { "config_file" => "test/fixtures/deploy_with_accessories.yml", "skip_hooks" => false, "confirmed" => true, "rolling" => false }
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:proxy:upgrade", [], invoke_options).times(4)
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:accessory:upgrade", [ "all" ], invoke_options).times(4)
|
||||
|
||||
run_command("upgrade", "--rolling", "-y", config_file: "deploy_with_accessories").tap do |output|
|
||||
assert_match "Upgrading 1.1.1.1...", output
|
||||
assert_match "Upgraded 1.1.1.1", output
|
||||
assert_match "Upgrading 1.1.1.2...", output
|
||||
assert_match "Upgraded 1.1.1.2", output
|
||||
assert_match "Upgrading 1.1.1.3...", output
|
||||
assert_match "Upgraded 1.1.1.3", output
|
||||
assert_match "Upgrading 1.1.1.4...", output
|
||||
assert_match "Upgraded 1.1.1.4", output
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def run_command(*command, config_file: "deploy_simple")
|
||||
with_argv([ *command, "-c", "test/fixtures/#{config_file}.yml" ]) do
|
||||
|
||||
Reference in New Issue
Block a user