Replace Traefik with kamal-proxy

[kamal-proxy](https://github.com/basecamp/kamal-proxy) is a custom
minimal proxy designed specifically for Kamal.

It has some advantages over Traefik:
1. Imperative deployments - we tell it to switch from container A to
   container B, and it waits for container B to start then switches. No
   need to poll for health checks ourselves or mess around with forcing
   health checks to fail.
2. Support for multiple apps - as much as possible, configuration is
   supplied at runtime by the deploy command, allowing us to have
   multiple apps share a proxy without conflicting config.
3. First class support for Kamal operations - rather than trying to
   work out how to make Traefik do what we want, we can build features
   directly into the proxy, making configuration simpler and avoiding
   obscure errors
This commit is contained in:
Donal McBreen
2024-03-08 08:19:48 +00:00
parent 90ecb6a12a
commit 6568cef868
66 changed files with 746 additions and 1161 deletions

View File

@@ -1,14 +1,15 @@
require_relative "integration_test"
class MainTest < IntegrationTest
class IntegrationMainTest < IntegrationTest
test "envify, deploy, redeploy, rollback, details and audit" do
kamal :server, :bootstrap
kamal :envify
assert_env_files
remove_local_env_file
first_version = latest_app_version
assert_app_is_down
assert_app_is_down response_code: "502"
kamal :deploy
assert_app_is_up version: first_version
@@ -28,11 +29,11 @@ class MainTest < IntegrationTest
assert_app_is_up version: first_version
details = kamal :details, capture: true
assert_match /Traefik Host: vm1/, details
assert_match /Traefik Host: vm2/, details
assert_match /Proxy Host: vm1/, details
assert_match /Proxy Host: vm2/, details
assert_match /App Host: vm1/, details
assert_match /App Host: vm2/, details
assert_match /traefik:v2.10/, details
assert_match /basecamp\/kamal-proxy:latest/, details
assert_match /registry:4443\/app:#{first_version}/, details
audit = kamal :audit, capture: true
@@ -45,11 +46,12 @@ class MainTest < IntegrationTest
test "app with roles" do
@app = "app_with_roles"
kamal :server, :bootstrap
kamal :envify
version = latest_app_version
assert_app_is_down
assert_app_is_down response_code: "502"
kamal :deploy
@@ -79,7 +81,6 @@ class MainTest < IntegrationTest
assert_equal({ user: "root", port: 22, keepalive: true, keepalive_interval: 30, log_level: :fatal }, config[:ssh_options])
assert_equal({ "multiarch" => false, "args" => { "COMMIT_SHA" => version } }, config[:builder])
assert_equal [ "--log-opt", "max-size=\"10m\"" ], config[:logging]
assert_equal({ "path" => "/up", "port" => 3000, "max_attempts" => 3, "cord"=>"/tmp/kamal-cord", "log_lines" => 50, "cmd"=>"wget -qO- http://localhost > /dev/null || exit 1" }, config[:healthcheck])
end
test "setup and remove" do