Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/luizkowalski/terraform-hetzner

Set up two (or more) servers on Hetzner Cloud
https://github.com/luizkowalski/terraform-hetzner

hetzner-cloud kamal terraform

Last synced: 6 days ago
JSON representation

Set up two (or more) servers on Hetzner Cloud

Awesome Lists containing this project

README

        

## Production-Grade (ish) server orchestration with Kamal

This is the architecture of our small cluster:

![Architecture](arch.png)

### Architecture

It creates two servers: `web` where our application lives and `accessories` where our dependencies like databases and caches live.
`web` exposes ports 80, 22 and 443, while `accessories` is not accessible from the outside. Root access is disabled on both machines and only the `kamal` user can SSH into them.

You can create more servers by updating `web_servers_count` or `accessories_count` in `variables.tf`. If there is more than one web server, a load balancer will be created and all the web servers will be added to it.

In case multiple servers of different types are created, the naming will be `web-1`, `web-2`, `accessories-1`, and `accessories-2`, as opposed to `web`, `accessories`, the default naming convention.

> [!IMPORTANT]
> If you are copying this workflow, you should change the SSH keys in `cloudinit/base.yml` to your own.
> It is defined on `ssh_import_id` and imports the SSH keys from your GitHub account.

### Connecting to the servers

After running `terraform apply`, the script will output an SSH configuration that can be copied to your `~/.ssh/config` file. This is to help you connect to servers since accessory servers are not accessible from the outside, you need to use the web server as a jump host. It looks like this:

```ssh-config
ssh_01_web_config = <