I am thinking of trying out Hetzner for hosting front-ends, back-ends. I have some questions about the workflow on Hetzner.
How do you
- deploy from source repo? Terraform?
- keep software up to date? ex: Postgres, OS
- do load balancing? built-in load balancer?
- handle scaling? Terraform?
- automate backups? ex: databases, storage. Do you use provided backups and snapshots?
- maintain security? built-in firewall and DDoS protection?
If there is any open source automation scripts please share.
OTOH it's quite slow when used for deployments. There's no way you would be getting 5 second deployments with it.
My favorite middle ground between shell scripts and Ansible is Fabric (https://www.fabfile.org/).
It can be. It also can not-be. I'd recommend anybody to start looking once they reach more than 2 machines, but yeah, depending on what you are doing it can add value when you have 1 or 2 machines too.
To expand a little bit:
- It's a very small service
- I use sqlite db
- Preparation step before the restart ensures all the deps are downloaded for the new repo state. I.e. "a build step"
- I use simple nginx in front of the web server itself
- Backups are implemented as a cron job that sends my whole db as an email attachment to myself
- journalctl shows how it restarted so I see it's working
- bastion host: custom port for ssh open to the public
- virtual private cloud (vpc): inside I put my web-server and my db server. These servers are not accessible to the public, but the bastion host has access to the vpc
- another server for my nginx. This is public and it redirects requests to my web-server in the vpc
I know it sounds overkill! But somehow it gives me the (illusion?) of being more secure. Am I right with this setup or I'm just wasting my time (and money)? I know perhaps that a VPN could be better... but somehow I found the idea of bastion+vpc quite simple and effective.
You don't need to put anymore security over it, like changing ssh port or running fail2ban, unless you want to reduce CPU load spent behind handling automated port scanners and bots.
You're only ever more secure if you reduce the attack surface. These days, with WireGuard's simple and secure tunnels, I'd say a VPN may be an improvement, but I'm not all that worried about SSH on my servers. Either disabling password logins or using secure passwords should be fine in most cases.
I personally change the SSH port as well, not really for security but mostly because it keeps the logs clean. Port scans will still happen but you won't get bombarded by thousands of pi@server.com sessions failing every day of the week.
If you want to go to crazy lengths to hide your ssh then do port knocking or something.
> deploy from source repo? Terraform?
I use Dokku (https://dokku.com/), then the workflow is the same as if you'd be using Heroku
> keep software up to date? ex: Postgres, OS
Automattic ubuntu updates + I once a week SSH to it and apt-get update, etc.
> do load balancing? built-in load balancer?
I just don't. I don't need for the load of my projects.
> handle scaling? Terraform?
Just vertical scaling for now. A single powerful server can do great before you might need to add more servers.
> automate backups? ex: databases, storage. Do you use provided backups and snapshots?
I just enable the "backup" feature on their admin panel. Adds 20% to the cost but works great and it's easy.
> maintain security? built-in firewall and DDoS protection?
I only expose the HTTP(s) and SSH ports, and I also have setup fail2ban for bruteforce attacks.
> If there is any open source automation scripts please share.
Dokku.
- install machines with ansible (using hetzner scripts for OS install)
- machines communicate over vswitch/vlans, external interfaces disabled whenever possible. Pay attention to the custom mtu trick.
- harden machines, unattended-upgrades mandatory on each machine
- ssh open with IP whitelists from iptables on gateways
- machines organized as k8s clusters, took ~1 year to have everything working cleanly
- everything deployed as k8s resources (kustomize, fluxcd, gitops)
- use keepalived for external IPs with floating IPs for ingress on 3 machines per cluster
Machines are managed as cattle, it takes <1h+ hetzner provisioning time to add as many machines as we need.
I wish Hetzner made this more clear up front. Maybe a big red banner on the vSwitch page. I can't count the number of hours I've spent troubleshooting network issues at Hetzner that came down to MTU.
> Introducing MRSK - 37signals way to deploy
Thttps://www.youtube.com/watch?v=LL1cV2FXZ5I
* https://github.com/kube-hetzner/terraform-hcloud-kube-hetzne... (Terraform, Kubernetes bootstrap)
* Flux for CI
* nginx-ingress + Hetzner Loadbalancer (thanks to https://github.com/hetznercloud/hcloud-cloud-controller-mana...)
* Hetzner storage volumes (thanks to https://github.com/hetznercloud/csi-driver)
Kube-Hetzner supports Hetzner Cloud loadbalancers and volumes out of the box, though it also supports other components.