Skip to content

Quickstart

This page creates a small Garage cluster, a bucket, and an S3 key that can only use that bucket. GarageCluster is v1beta2 in the example. The other resources are v1beta1.

1. Create the admin token

The operator uses this token to call Garage's Admin API. The Secret must be in the same namespace as the GarageCluster.

kubectl create namespace garage
kubectl create secret generic garage-admin-token -n garage \
  --from-literal=admin-token="$(openssl rand -hex 32)"

2. Apply a cluster

apiVersion: garage.rajsingh.info/v1beta2
kind: GarageCluster
metadata:
  name: garage
  namespace: garage
spec:
  image: dxflrs/garage:v2.6.0@sha256:4b5a318fc9fe2fbec5d3af590eeafe05d83492e6411266fa0b9e215c20264013
  zone: lab
  replication:
    factor: 3
    consistencyMode: consistent
  storage:
    replicas: 3
    metadata:
      size: 10Gi
    data:
      size: 100Gi
  network:
    rpcBindPort: 3901
    service:
      type: ClusterIP
  s3Api:
    bindPort: 3900
    region: garage
  admin:
    adminTokenSecretRef:
      name: garage-admin-token
      key: admin-token

Save it as garagecluster.yaml and apply it:

kubectl apply -f garagecluster.yaml
kubectl wait --for=condition=Ready garagecluster/garage -n garage --timeout=10m

Three replicas with factor: 3 only protect your data if the pods land in three separate failure domains and have enough disk. On a single-node test cluster, use factor: 1 with EmptyDir and treat the data as disposable.

3. Inspect the operator's view

kubectl get garagecluster,garagenode -n garage
kubectl get garagecluster garage -n garage \
  -o jsonpath='{.status.phase}{"\n"}{.status.layoutDiagnosis}{"\n"}'
kubectl get garagecluster garage -n garage \
  -o jsonpath='{.status.conditions}'

Ready=True means the cluster matches what you asked for. It says nothing about backups or the health of a federation peer. For those, read the health conditions and the day-2 guide.

4. Create a bucket and key

apiVersion: garage.rajsingh.info/v1beta1
kind: GarageBucket
metadata:
  name: app-data
  namespace: garage
spec:
  clusterRef:
    name: garage
  quotas:
    maxSize: 10Gi
---
apiVersion: garage.rajsingh.info/v1beta1
kind: GarageKey
metadata:
  name: app-key
  namespace: garage
spec:
  clusterRef:
    name: garage
  bucketPermissions:
    - bucketRef:
        name: app-data
      read: true
      write: true

Save both documents as bucket-and-key.yaml, then apply them:

kubectl apply -f bucket-and-key.yaml
kubectl wait --for=condition=Ready garagebucket/app-data -n garage --timeout=5m
kubectl wait --for=condition=Ready garagekey/app-key -n garage --timeout=5m
kubectl get secret app-key -n garage \
  -o jsonpath='{.data.endpoint}' | base64 --decode; echo

The Secret has access-key-id, secret-access-key, endpoint, host, scheme and region, unless a secretTemplate renames or drops some. Buckets and credentials covers narrower permissions and importing existing keys.

5. Test S3 access

Use an S3 client in a Pod that can reach the cluster's Service. In this example the endpoint is http://garage.garage.svc:3900.

kubectl -n garage get secret app-key \
  -o jsonpath='{.data.access-key-id}' | base64 -d; echo
kubectl -n garage get secret app-key \
  -o jsonpath='{.data.secret-access-key}' | base64 -d; echo

Don't expose the Admin API or the RPC port to untrusted networks. To publish S3, use the Service, a gateway, an Ingress or the Gateway API.

Next steps