blg.tch.re – Getting started with Garage - part 1 (Apr. 19, 2024)

Getting started with Garage - part 1

Garage is an opensource distributed storage service. It supports a part of the AWS S3 API and it is tailored for self-hosting.

The server is written in Rust by DeuxFleurs.

A nice additional feature is the avaibility of a KV storage.

The Quick start is very eaysy do use and the doc contains cookbooks covering many examples.

Installation

I picked the v1.0.0 release build to install directly on my home server, an old laptop running Debian.

$ wget https://garagehq.deuxfleurs.fr/_releases/v1.0.0/x86_64-unknown-linux-musl/garage
$ chmod a+x garage
$ sudo mv garage /usr/local/bin/garage
$ garage --version
garage v1.0.0 [features: k2v, lmdb, sqlite, consul-discovery, kubernetes-discovery, metrics, telemetry-otlp, bundled-libs]

Configuration

According with the quick start guide I created a default configuration in /etc/garage.toml.

The only changes are metadata_dir and data_dir I set in /var/lib/garage dir to enable the Systemd DynamicUser feature.

I also replace the $(openssl ...) values with generated ones.

metadata_dir = "/var/lib/garage/meta"
data_dir = "/var/lib/garage/data"
db_engine = "sqlite"

replication_factor = 1

rpc_bind_addr = "[::]:3901"
rpc_public_addr = "127.0.0.1:3901"
rpc_secret = "$(openssl rand -hex 32)"

[s3_api]
s3_region = "garage"
api_bind_addr = "[::]:3900"
root_domain = ".s3.garage.tch.re"

[s3_web]
bind_addr = "[::]:3902"
root_domain = ".web.garage.tch.re"
index = "index.html"

[k2v_api]
api_bind_addr = "[::]:3904"

[admin]
api_bind_addr = "[::]:3903"
admin_token = "$(openssl rand -base64 32)"
metrics_token = "$(openssl rand -base64 32)"

Systemd service

A complete Systemd guide is available in the doc. I simply followed it.

$ sudo systemctl daemon-reload
$ sudo systemctl start garage
sudo systemctl enable garage
$ sudo garage status
==== HEALTHY NODES ====
ID                Hostname  Address         Tags  Zone  Capacity          DataAvail
e35e988317464628  uma       127.0.0.1:3901              NO ROLE ASSIGNED

Cluster layout

You have to set a layout to the node running with the command layout assign. You must define the zone and the capacity of the node.

In my case, I will have 2 servers in the cluster at home, but I will eventually have another outside.

$ sudo garage layout assign -z b63 -c 1G <node id>

You can check the layout details with sudo garage layout show.

Then apply the new layout.

$ sudo garage layout apply --version=1
$ sudo garage status
==== HEALTHY NODES ====
ID                Hostname  Address           Tags  Zone  Capacity   DataAvail
e35e988317464628  uma       127.0.0.1:3901    []    b63   1000.0 MB  191.4 GB (84.2%)

To be continued

Next time I will try to access my instance with a client.