Skip to content

cwchen-twn/hcloud

Repository files navigation

hcloud

VPS management on Hetzner Cloud

Quick Start

# Install wrangler to interact with cloudflare
bun install
# Create the R2 bucket to store the terraform state
bun run create

# Copy and fill in the R2 backend credentials
cp backend.hcl.example backend.hcl

# Copy and fill in terraform variables (hcloud token, cloudflare token, subdomains, purelymail_ownership_proof, etc.)
cp terraform.tfvars.example terraform.tfvars

terraform init -backend-config=backend.hcl
terraform plan
terraform apply
terraform destroy

Hetzner server DNS A/AAAA records, and PurelyMail email DNS records (MX, SPF, DKIM, DMARC) are all managed in the same Terraform root via modules/cloudflare.

How to find available images

  1. Use curl
curl \
	-H "Authorization: Bearer $H_API_TOKEN" \
	"https://api.hetzner.cloud/v1/images"

curl \
	-H "Authorization: Bearer $H_API_TOKEN" \
	"https://api.hetzner.cloud/v1/images/$ID"
  1. Use hcloud cli
hcloud context create <ur-project-name>
hcloud image list -t system -a x86

SSH Tunnels

To access the remote Postgres and K3S cluster without modifying the firewall rules, which only open 80, 443, and ssh for security concerns, we can use the ssh tunnel enabling the connection from the local machine to the remote services.

The sshtunnels folder has the systemd configurations and installation bash, following the commands will install the systemd services.

cd sshtunnels/
# Ensure the SSH_USER and REMOTE_HOST are configured in tne env
# e.g., 
# - export SSH_USER=xxx
# - export REMOTE_HOST=xxx
bash install_tunnel.sh

# Check the install services
systemctl status --user postgres-tunnel.service
systemctl status --user k3s-ssh-tunnel.service
# To see the logs
journalctl --user --unit=postgres-tunnel.service --no-pager
journalctl --user --unit=k3s-ssh-tunnel.service --no-pager

Reference

About

VPS management on Hetzner Cloud using Terraform and cloud-init

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors