Garage S3 Object Storage
Relevant source files
- infrastructure/terraform/s3/garage/README.md
- infrastructure/terraform/s3/garage/main.tf
- infrastructure/terraform/s3/garage/modules/garage/main.tf
- infrastructure/terraform/s3/garage/modules/garage/outputs.tf
- infrastructure/terraform/s3/garage/modules/garage/variables.tf
- infrastructure/terraform/s3/garage/providers.tf
- infrastructure/terraform/s3/garage/variables.tf
- infrastructure/terraform/s3/staticgarage/main.tf
- infrastructure/terraform/s3/staticgarage/providers.tf
- infrastructure/terraform/s3/staticgarage/variables.tf
- kubernetes/apps/storage/garage/app/externalsecret.yaml
- kubernetes/apps/storage/garage/app/helmrelease.yaml
- kubernetes/apps/storage/garage/app/kustomization.yaml
- kubernetes/apps/storage/garage/app/resources/garage.toml
- kubernetes/apps/storage/garage/ks.yaml
- kubernetes/apps/storage/garage/webui/kustomization.yaml
- kubernetes/apps/storage/staticgarage/app/externalsecret.yaml
- kubernetes/apps/storage/staticgarage/app/helmrelease.yaml
- kubernetes/apps/storage/staticgarage/app/kustomization.yaml
- kubernetes/apps/storage/staticgarage/app/resources/garage.toml
- kubernetes/apps/storage/staticgarage/ks.yaml
- kubernetes/apps/storage/staticgarage/webui/externalsecret.yaml
- kubernetes/apps/storage/staticgarage/webui/kustomization.yaml
- kubernetes/apps/storage/staticgarage/webui/terraform.yaml
Garage is a lightweight, distributed S3-compatible storage service designed for self-hosting. In this repository, Garage provides the primary object storage backend for internal cluster services (like database backups and WAL archiving) and serves static web content.
Deployment Architecture
The infrastructure utilizes two distinct Garage instances:
- Primary Garage (
garage): Handles high-performance and critical data for services likepostgresql(CloudNativePG) anddragonflyinfrastructure/terraform/s3/garage/main.tf7-9 - Static Garage (
staticgarage): Dedicated to serving static websites, such as the cluster documentation wiki and schemas infrastructure/terraform/s3/staticgarage/main.tf1-6
Both instances are deployed using the bjw-s/app-template Helm chart kubernetes/apps/storage/garage/app/helmrelease.yaml10 and utilize LoadBalancer services with fixed IP addresses assigned via Cilium L2 announcements kubernetes/apps/storage/garage/app/helmrelease.yaml43-45
Component Relationship Diagram
This diagram illustrates how the Kubernetes resources, configuration files, and Terraform modules interact to provide the S3 service.
[Flowchart Diagram]
Sources:kubernetes/apps/storage/garage/app/helmrelease.yaml108-129kubernetes/apps/storage/garage/app/externalsecret.yaml1-40infrastructure/terraform/s3/garage/modules/garage/main.tf10-20
Configuration (garage.toml)
Garage is configured via a garage.toml file, which is managed as a template inside an ExternalSecret. This allows the injection of sensitive tokens (RPC secrets, Admin tokens) directly into the configuration file at runtime.
Key Configuration Parameters
-
Storage Engines: Uses
lmdbfor the metadata database kubernetes/apps/storage/garage/app/resources/garage.toml3 -
Replication: Configured with a
replication_factorof 1 for this specific single-node deployment kubernetes/apps/storage/garage/app/resources/garage.toml6 -
API Bindings:
-
S3 API: Port
3900kubernetes/apps/storage/garage/app/resources/garage.toml15 -
S3 Web: Port
3902for static website hosting kubernetes/apps/storage/garage/app/resources/garage.toml19 -
Admin API: Port
3903used by the Terraform provider kubernetes/apps/storage/garage/app/resources/garage.toml24
Sources:kubernetes/apps/storage/garage/app/resources/garage.toml1-27kubernetes/apps/storage/staticgarage/app/externalsecret.yaml8-15
Terraform Provisioning
Buckets and access keys are managed as Infrastructure-as-Code using the schwitzd/garage Terraform provider infrastructure/terraform/s3/garage/providers.tf20-23
Resource Management Flow
The modules/garage module encapsulates the creation of a bucket, its primary access key, and the association between them.
[Flowchart Diagram]
Managed Buckets
- Primary Instance:
dragonfly,postgresql,opencloudinfrastructure/terraform/s3/garage/main.tf7-9 - Static Instance:
wiki,schemainfrastructure/terraform/s3/staticgarage/main.tf2-5
Sources:infrastructure/terraform/s3/garage/modules/garage/main.tf10-35infrastructure/terraform/s3/garage/main.tf1-23infrastructure/terraform/s3/staticgarage/main.tf1-27
Service Consumption
Services interact with Garage through the internal Envoy Gateway ingress or direct LoadBalancer IPs.
Data Flow: CloudNativePG WAL Archiving
CloudNativePG (CNPG) uses the postgresql bucket for Write-Ahead Log (WAL) archiving and cluster backups.
- Request: CNPG instance sends S3 API calls to
s3.cloudjur.comkubernetes/apps/storage/garage/app/helmrelease.yaml59 - Ingress:
envoy-internalroutes the traffic to thegarageservice on port3900kubernetes/apps/storage/garage/app/helmrelease.yaml61-66 - Storage: Garage writes the data to the persistent NFS volume mounted at
/datakubernetes/apps/storage/garage/app/helmrelease.yaml121-123
Static Web Hosting
The staticgarage instance is configured to serve web content directly from buckets.
- Wiki: Accessible via
wiki.cloudjur.comkubernetes/apps/storage/staticgarage/app/helmrelease.yaml80 - Schema: Accessible via
schema.cloudjur.comkubernetes/apps/storage/staticgarage/app/helmrelease.yaml66 - Index/Error Documents: Configured in Terraform to default to
index.htmlanderror.htmlinfrastructure/terraform/s3/garage/modules/garage/main.tf13-14
Sources:kubernetes/apps/storage/garage/app/helmrelease.yaml53-107kubernetes/apps/storage/staticgarage/app/helmrelease.yaml53-101infrastructure/terraform/s3/garage/modules/garage/main.tf10-16
Persistence and Storage Tiering
Garage data is not stored on local NVMe but is offloaded to the bulk storage pool (/tank) via NFS to ensure high capacity for object storage.
| Mount Path | Source (NFS) | Purpose |
|---|---|---|
/data | smb.cloudjur.com:/tank/Apps/Garage/data | Block data storage kubernetes/apps/storage/garage/app/helmrelease.yaml121-123 |
/meta | smb.cloudjur.com:/tank/Apps/Garage/meta | Metadata and LMDB database kubernetes/apps/storage/garage/app/helmrelease.yaml127-129 |
Sources:kubernetes/apps/storage/garage/app/helmrelease.yaml117-130kubernetes/apps/storage/staticgarage/app/helmrelease.yaml110-123