Garage (S3)
Table of Contents
FreeBSD (via Linux Docker)
sudo pkg install -y podman-suitesudo zfs create -o mountpoint=/var/db/containers zroot/containers
sudo sysctl net.pf.filter_local=1 # makes pf process packets that originate _and_ stay on the local machinesudo pfilctl link -o pf:default-out inet-local # links pf's outbound ruleset to hook for packets generated by the local host, so pf actually processes host-originated packets — not just forwarded onesprintf 'sysctl net.pf.filter_local=1\npfilctl link -o pf:default-out inet-local\n' | sudo tee -a /etc/rc.local # to preserve that
sudo sysrc linux_enable=YESsudo service linux enable && sudo service linux start
# Podman & Linux setup# sudo sysrc podman_enable=YES # optional, depends on the setupsudo tee -a /etc/fstab << 'EOF'fdesc /dev/fd fdescfs rw 0 0EOFsudo mount -amount | grep fdescfs | wc -l
# ZFS for Garage
sudo zfs set quota=10T reservation=5T tank/s3-garage # set limits as required
sudo zfs create tank/s3-garagesudo zfs create tank/s3-garage/metasudo zfs create tank/s3-garage/data
sudo zfs set compression=lz4 tank/s3-garage/datasudo zfs set compression=lz4 tank/s3-garage/metasudo zfs set atime=off tank/s3-garage/data
# Garage setup nowsudo tee /tank/s3-garage/garage.toml << 'EOF'metadata_dir = "/tank/garage/meta"data_dir = "/tank/garage/data"db_engine = "sqlite"metadata_auto_snapshot_interval = "6h"
replication_factor = 1 # replicate across nodes
compression=lz4
rpc_bind_addr = "127.0.0.1:3901"rpc_public_addr = "127.0.0.1:3901"rpc_secret = "<generated-rpc-secret>" # openssl rand -hex 32
[s3_api]s3_region = "garage"api_bind_addr = "127.0.0.1:3900"root_domain = ".s3.garage"EOF
sudo tee /tank/s3-garage/docker-compose.yml << 'EOF'services: s3-garage: image: dxflrs/garage:v2.2.0 container_name: s3-garage restart: unless-stopped volumes: - ./garage.toml:/tank/s3-garage/garage.toml - /tank/garage/meta:/var/lib/garage/meta - /tank/garage/data:/var/lib/garage/data expose: - "3900" # S3 API - "3901" # Admin API - "3903" # Metrics/Admin HTTP ports: - "127.0.0.1:3900:3900"EOFTo start it:
cd /tank/s3-garage && sudo podman compose up -dreverse proxy (haproxy)
==> follow the instructions inside FreeBSD bare metal
Linux
# Linuxalias garage="docker exec -ti s3-garage /garage"# or# FreeBSDalias garage="sudo podman exec -ti s3-garage /garage"
garage statusgarage layout assign -z dc1 -c 10T 679316a0bafde61b # 10Tb on node_id from the statusgarage layout show # that gives the version to apply for the next commandgarage layout apply --version 1garage status # shall demonstrate zone, capacity, etc
garage bucket listgarage bucket create app-uploadsgarage bucket info app-uploads
garage key create app-uploads-keygarage key listgarage key info app-uploads-key
garage bucket allow --read --write --owner app-uploads --key app-uploads-key
garage bucket info app-uploadshere is the rclone’s config file (key & access keys are not encrypted):
[s3_storage]type = s3provider = Otheraccess_key_id = ...secret_access_key = ...endpoint = https://s3.example.com/region = garageacl = privatebucket_acl = privateCreate new user
user="app-user"bucket="app-backups"
garage key create "${user}-key"garage bucket allow --read --write --owner "$bucket" --key "${user}-key"garage bucket info "$bucket"Create new bucket
bucket="app-uploads"garage bucket create "$bucket"