Commit Graph
75 Commits
Author SHA1 Message Date
Donal McBreen 7f15fd143f 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.
2024-09-17 13:02:02 +01:00
Donal McBreen 267b526438 Switch proxy/hosts to proxy/host
The proxy only supports a single host per app for nowm so make the
config match that.
2024-09-16 20:45:09 +01:00
Donal McBreen 1f721739d6 Use version 0.1.0 of kamal-proxy and add minimum version check 2024-09-16 16:44:58 +01:00
Donal McBreen 6c51e596ae Put locks directories in .kamal so they leave no trace when deleted 2024-09-16 16:44:58 +01:00
Donal McBreen 7f31510aec Set hosts via config rather than options 2024-09-16 16:44:58 +01:00
Donal McBreen e8ff233e81 Fix default log header tests 2024-09-16 16:44:58 +01:00
Donal McBreen a316e51eda Add user agent to default headers 2024-09-16 16:44:58 +01:00
Donal McBreen bf91d6c1ca Fix command description 2024-09-16 16:44:58 +01:00
Donal McBreen a84ee6315f Rename service -> app directory 2024-09-16 16:44:58 +01:00
Donal McBreen 3c39086613 Not experimental 2024-09-16 16:44:58 +01:00
Donal McBreen 8b965b0a31 Handle polling without the healthcheck config 2024-09-16 16:44:58 +01:00
Donal McBreen d2672c771e Remove redundant call to env remove 2024-09-16 16:44:58 +01:00
Donal McBreen 24031fefb0 Remove proxy only if no apps are installed 2024-09-16 16:44:58 +01:00
Donal McBreen 35fe9c154d Move audits back to run dir so they survive kamal remove 2024-09-16 16:44:58 +01:00
Donal McBreen b8972a6833 Remove service directory on kamal remove 2024-09-16 16:44:58 +01:00
Donal McBreen d7d6fa34b0 Use Volume for kamal proxy config volume 2024-09-16 16:44:58 +01:00
Donal McBreen c21757f747 Move all files on the host under a common directory
This will make running kamal remove simpler, we can just clean up that
directory.
2024-09-16 16:44:58 +01:00
Donal McBreen cb73c730f9 No need for run_id 2024-09-16 16:44:58 +01:00
Donal McBreen 109339189a Fix up integration app_test.rb 2024-09-16 16:44:58 +01:00
Donal McBreen 33834a266a Drop sleep after container healthy 2024-09-16 16:44:58 +01:00
Donal McBreen e1016b2469 No need to wait_for_healthy 2024-09-16 16:44:58 +01:00
Donal McBreen a40b644145 Check that there's no traefik hooks left behind 2024-09-16 16:44:58 +01:00
Donal McBreen ccb7424197 Remove stray exit! 2024-09-16 16:44:58 +01:00
Donal McBreen 2125327d54 proxy/host -> proxy/hosts 2024-09-16 16:44:58 +01:00
Donal McBreen f4d309c5cc Rip out Traefik 2024-09-16 16:44:55 +01:00
Donal McBreen 5bca8015bc Map kamal proxy config into .kamal/proxy/config
This will allow us to share files with the proxy via the host.
2024-09-16 16:44:41 +01:00
Donal McBreen 27a7b339a6 Drop run_directory configuration option
We need to drop to be fixed so multiple applications put the config in
the same place.
2024-09-16 16:44:41 +01:00
Donal McBreen dcd4778dd9 Port -> app_port 2024-09-16 16:44:41 +01:00
Donal McBreen 6f2eaed398 Work out the host and port for the container
Avoid docker inspect:
1. Use the container ID as the host
2. Configure the port, default to 3000
2024-09-16 16:44:41 +01:00
Donal McBreen e9d480b514 Add the proxy/ssl config and pass on to kamal-proxy 2024-09-16 16:44:41 +01:00
Donal McBreen 2fdc59a3aa Fix tests 2024-09-16 16:44:41 +01:00
Donal McBreen b33c999125 Remove envify, make proxy booting work with env files 2024-09-16 16:44:41 +01:00
Donal McBreen 2056351c38 Use kamal network for accessories 2024-09-16 16:44:41 +01:00
Donal McBreen 9c2d5f83f7 Boot latest version when upgrading proxy 2024-09-16 16:44:41 +01:00
Donal McBreen f347ef7e44 Add proxy upgrade command 2024-09-16 16:44:41 +01:00
Donal McBreen 63ebeda489 Create proxy and app containers in a kamal network 2024-09-16 16:44:41 +01:00
Donal McBreen 13bdf50ceb Fix tests for proxy defaults and required builder arch 2024-09-16 16:44:41 +01:00
Donal McBreen bd6558630f Fix merge error 2024-09-16 16:44:39 +01:00
Donal McBreen 6bbbd81da1 Add a mutex around loading secrets
Loading secrets may ask for use input, so we need to ensure only one
thread does it at a time.
2024-09-16 14:44:39 +01:00
Donal McBreen dc1bbac3c8 Override the entrypoint when extracting assets
When overriding the command, docker will still run the entrypoint. We
want to avoid that here - we just want to get the assets out as quickly
as possible. Otherwise maybe something important is going on when we
stop the container.
2024-09-12 19:31:18 +01:00
Donal McBreen 0660895e75 Don't exit from failed secrets commands
We can let the exception bubble up. We'll still get an error message and
it ensures that any cleanup we need is done (i.e. releasing deploy locks).
2024-09-11 16:10:52 +01:00
Donal McBreen 9089c41f30 Add secrets-common for shared secrets
Add a shared secrets file used across all destinations. Useful for
things Github tokens or registry passwords.

The secrets are added to a new file called `secrets-common` to highlight
they are shared, and to avoid acciedentally inheriting a secret from the
`secrets` file to `secrets.destination`.
2024-09-11 13:41:36 +01:00
Donal McBreen 0cb69a84f5 Don't git ignore .kamal/secrets
Secrets should be interpolated at runtime so we do want the file in git.

But add a warning at the top to avoid adding secrets or git ignore the
file if you do.

Also provide examples of the three options for interpolating secrets.
2024-09-11 12:16:18 +01:00
Donal McBreen aa630f156a Hide the 1password login error
Avoid outputting this login error message, it wasn't an error and you
don't need to follow those instructions.

```
[ERROR] 2024/09/11 11:57:08 You are not currently signed in. Please run `op signin --help` for instructions
```
2024-09-11 12:02:53 +01:00
Donal McBreen 06f4caa866 Make the secrets commands inline aware
Rather than redirecting the global $stdout, which is not never clever in
a threaded program, we'll make the secrets commands aware they are
being inlined, so they return the value instead of printing it.

Additionally we no longer need to interrupt the parent process on error
as we've inlined the command - exit 1 is enough.
2024-09-10 10:39:44 +01:00
Donal McBreen aed2ef99d0 Use env files for secrets
Add env files back in for secrets - hides them from process lists and
allows you to pick up the latest env file when running
`kamal app exec` without reusing.
2024-09-09 14:43:12 +01:00
Donal McBreen 57cbf7cdb5 Inline dotenv kamal secrets calls 2024-09-06 16:56:54 +01:00
Donal McBreen 8ad6a0ed16 Add .kamal/secrets on kamal init 2024-09-06 11:54:12 +01:00
Donal McBreen 8b62e2694a Test non-ascii secret interpolation 2024-09-05 10:01:56 +01:00
Donal McBreen be1df4356a fetch_from_vault -> fetch_secrets 2024-09-05 09:53:33 +01:00
Donal McBreen 8210e8e768 Drop redundant rescue 2024-09-05 09:53:18 +01:00
Donal McBreen 9b96ef2412 Shellescape command input 2024-09-05 08:37:50 +01:00
Donal McBreen 1522d94ac9 Pass secrets to pre/post deploy hooks 2024-09-04 16:24:10 +01:00
Donal McBreen a68294c384 Remote test adapter from test_helper.rb 2024-09-04 12:57:25 +01:00
Donal McBreen 31a347c285 Move int parent comment 2024-09-04 12:52:30 +01:00
Donal McBreen 3d502ab12d Add test adapter and interpolate secrets in integration tests 2024-09-04 12:40:27 +01:00
Donal McBreen 5226d52f8a Interrupting parent on error 2024-09-04 12:14:47 +01:00
Donal McBreen 9deb8af4a0 Don't hide command 2024-09-04 09:32:45 +01:00
Donal McBreen 068aaa0bd0 Fix options 2024-09-04 09:32:45 +01:00
Donal McBreen a726a86a17 Add lastpass, bitwarden adapters 2024-09-04 09:32:45 +01:00
Donal McBreen b2e1a4d4c1 Secrets test 2024-09-04 09:32:45 +01:00
Donal McBreen 9ade79fc84 OnePassword, LastPass + Bitwarden adapters 2024-09-04 09:32:45 +01:00
Donal McBreen 79731da619 Single fetch command 2024-09-04 09:32:45 +01:00
Donal McBreen 0ae8046905 Add secret tests 2024-09-04 09:32:45 +01:00
Donal McBreen d5ecca0fd4 Add tests 2024-09-04 09:32:45 +01:00
Donal McBreen a2549b1f60 Allow disabling of local builds
To disable local builds set:
```
builder:
   local: false
   remote: ssh://docker@docker-builder
```
2024-09-03 14:33:25 +01:00
Donal McBreen e557eea79c Build and clean remote builders correctly
Check that the builder and context match what we expect, and if not
remove and re-create them.
2024-09-02 15:12:19 +01:00
Donal McBreen 9f0b10425c Fix aliases tests 2024-08-29 09:16:07 +01:00
Donal McBreen 5f2384f123 Use docker info to get arch 2024-08-29 08:46:18 +01:00
Donal McBreen eab7d3adc5 Keep buildx build, in case of old docker versions which don't default to buildkit 2024-08-29 08:45:51 +01:00
Donal McBreen d2d0223c37 Require an arch to be set, and default to amd64 in the template 2024-08-29 08:45:51 +01:00
Donal McBreen 2515bd705c Switch the version on main to 2.0.0.alpha
All development is now for the 2.0.0 release.
2024-08-29 08:33:21 +01:00
Donal McBreen 579e169be2 Allow multiple arguments for exec commands
If you can have an alias like:

```
aliases:
  rails: app exec -p rails
```

Then `kamal rails db:migrate:status` will execute
`kamal app exec -p rails db:migrate:status`.

So this works, we'll allow multiple arguments `app exec` and
`server exec` to accept multiple arguments.

The arguments are combined by simply joining them with a space. This
means that these are equivalent:

```
kamal app exec -p rails db:migrate:status
kamal app exec -p "rails db:migrate:status"
```

If you want to pass an argument with spaces, you'll need to quote it:

```
kamal app exec -p "git commit -am \"My comment\""
kamal app exec -p git commit -am "\"My comment\""
```
2024-08-28 10:58:25 +01:00
Donal McBreen d6f5da92be Bump version for 1.8.2 2024-08-28 09:43:06 +01:00
Donal McBreen 9ccfe20b10 Fix up tests 2024-08-26 11:20:26 +01:00